Ignore:
Timestamp:
01/21/06 18:32:30 (18 years ago)
Author:
bittner
Message:

rss sampling changes, preprocessor::GenerateRays?

File:
1 edited

Legend:

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

    r556 r563  
    3333Preprocessor::~Preprocessor() 
    3434{ 
    35   cerr<<"Deleting view cells manager...\n"; 
     35  Debug<<"Deleting view cells manager...\n"; 
    3636  DEL_PTR(mViewCellsManager); 
    37   cerr<<"done.\n"; 
    38   cerr<<"Deleting bsp tree...\n"; 
     37  Debug<<"done.\n"; 
     38  Debug<<"Deleting bsp tree...\n"; 
    3939  DEL_PTR(mBspTree); 
    40   cerr<<"done.\n"; 
    41   cerr<<"Deleting kd tree...\n"; 
     40  Debug<<"done.\n"; 
     41  Debug<<"Deleting kd tree...\n"; 
    4242  DEL_PTR(mKdTree); 
    43   cerr<<"done.\n"; 
    44   cerr<<"Deleting vspkd tree...\n"; 
     43  Debug<<"done.\n"; 
     44  Debug<<"Deleting vspkd tree...\n"; 
    4545  DEL_PTR(mVspKdTree); 
    46   cerr<<"done.\n"; 
    47   cerr<<"Deleting vspbsp tree...\n"; 
     46  Debug<<"done.\n"; 
     47  Debug<<"Deleting vspbsp tree...\n"; 
    4848  DEL_PTR(mVspBspTree); 
    49   cerr<<"done.\n"; 
     49  Debug<<"done.\n"; 
    5050} 
    5151 
     
    429429        return true; 
    430430} 
     431 
     432 
     433 
     434bool 
     435Preprocessor::GenerateRays( 
     436                                                   const int number, 
     437                                                   const int sampleType, 
     438                                                   SimpleRayContainer &rays 
     439                                                   ) 
     440{ 
     441  Vector3 origin, direction;  
     442 
     443  for (int i=0; rays.size() < number; i++) { 
     444        mViewCellsManager->GetViewPoint(origin); 
     445         
     446         
     447        // now get the direction 
     448        switch (sampleType) { 
     449        case OBJECT_BASED_DISTRIBUTION: { 
     450          Vector3 point; 
     451          Vector3 normal; 
     452          int i = RandomValue(0, mObjects.size() - 1); 
     453          Intersectable *object = mObjects[i]; 
     454          object->GetRandomSurfacePoint(point, normal); 
     455          direction = point - origin; 
     456        } 
     457          break; 
     458        case DIRECTION_BASED_DISTRIBUTION: 
     459          direction = UniformRandomVector(); 
     460          break; 
     461        case DIRECTION_BOX_BASED_DISTRIBUTION: { 
     462          float alpha = RandomValue(0.0f, 2*M_PI); 
     463          float beta = RandomValue(-M_PI/2, M_PI/2); 
     464          direction = VssRay::GetDirection(alpha, beta); 
     465          break; 
     466        } 
     467        case SPATIAL_BOX_BASED_DISTRIBUTION: 
     468          direction = mKdTree->GetBox().GetRandomPoint() - origin; 
     469          break; 
     470        default: 
     471          // unsuported distribution type 
     472          return false; 
     473        } 
     474        // $$ jb the pdf is yet not correct for all sampling methods! 
     475        float pdf = 1.0f; 
     476        float c = Magnitude(direction); 
     477        if (c > Limits::Small) { 
     478          direction*=1.0f/c; 
     479          rays.AddRay(SimpleRay(origin, direction, pdf)); 
     480        } 
     481  } 
     482  return true; 
     483} 
Note: See TracChangeset for help on using the changeset viewer.