Ignore:
Timestamp:
01/03/06 23:33:45 (18 years ago)
Author:
bittner
Message:

Large merge - viewcells seem not functional now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/Vector3.cpp

    r448 r492  
    191191 
    192192Vector3 
    193 UniformRandomVector(const Vector3 &normal) 
    194 { 
    195         //  float r1 = RandomValue(0.0f, 1.0f); 
    196         //  float r2 = RandomValue(0.0f, 1.0f); 
    197         float r1, r2; 
     193UniformRandomVector() 
     194{ 
     195  //  float r1 = RandomValue(0.0f, 1.0f); 
     196  //  float r2 = RandomValue(0.0f, 1.0f); 
     197  float r1, r2; 
    198198         
    199         halton2.GetNext(r1, r2); 
     199  halton2.GetNext(r1, r2); 
    200200         
    201201         
    202         float cosTheta = 1.0f - r1; 
     202  float cosTheta = 1.0f - 2*r1; 
    203203  float sinTheta = sqrt(1 - sqr(cosTheta)); 
    204204  float fi = 2.0f*M_PI*r2; 
    205205   
    206206  Vector3 dir(sinTheta*sin(fi), 
    207                                                         cosTheta, 
    208                                                         sinTheta*cos(fi)); 
    209          
     207                          cosTheta, 
     208                          sinTheta*cos(fi)); 
     209   
     210  return dir; 
     211} 
     212 
     213Vector3 
     214UniformRandomVector(const Vector3 &normal) 
     215{ 
     216  //  float r1 = RandomValue(0.0f, 1.0f); 
     217  //  float r2 = RandomValue(0.0f, 1.0f); 
     218  float r1, r2; 
     219   
     220  halton2.GetNext(r1, r2); 
     221   
     222   
     223  float cosTheta = 1.0f - r1; 
     224  float sinTheta = sqrt(1 - sqr(cosTheta)); 
     225  float fi = 2.0f*M_PI*r2; 
     226   
     227  Vector3 dir(sinTheta*sin(fi), 
     228                          cosTheta, 
     229                          sinTheta*cos(fi)); 
     230   
    210231   
    211232  //  return Normalize(dir); 
    212          
     233   
    213234  Matrix4x4 m = RotationVectorsMatrix( 
    214                                                                                                                                                         normal, 
    215                                                                                                                                                         Vector3(0,1,0)); 
     235                                                                          normal, 
     236                                                                          Vector3(0,1,0)); 
    216237  Matrix4x4 mi = Invert(m); 
    217238  m = m*RotationVectorsMatrix( 
    218                                                                                                                         Vector3(0,1,0), 
    219                                                                                                                         Normalize(dir))*mi; 
     239                                                          Vector3(0,1,0), 
     240                                                          Normalize(dir))*mi; 
    220241   
    221242  return TransformNormal(m, normal); 
    222243   
    223         //    return TransformNormal( 
    224         //                       RotationVectorsMatrix( 
    225         //                                             Vector3(0,1,0), 
    226         //                                             Normalize(dir) 
    227         //                                             ), 
    228         //                       normal 
    229         //                       ); 
    230 } 
     244  //    return TransformNormal( 
     245  //                     RotationVectorsMatrix( 
     246  //                                           Vector3(0,1,0), 
     247  //                                           Normalize(dir) 
     248  //                                           ), 
     249  //                     normal 
     250  //                     ); 
     251} 
     252 
Note: See TracChangeset for help on using the changeset viewer.