Ignore:
Timestamp:
02/08/07 15:46:23 (17 years ago)
Author:
bittner
Message:

simple ray separated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/Ray.h

    r1989 r2105  
    4747          Intersectable *mObject; 
    4848 
    49                 /// the face of the intersectable 
     49        /// the face of the intersectable 
    5050          int mFace; 
    5151 
     
    315315}; 
    316316 
    317 struct SimpleRay 
    318 { 
    319   Vector3 mOrigin; 
    320   Vector3 mDirection; 
    321   short mType; 
    322   short mDistribution; 
    323   // generator Id -> relative to the generating distribution! 
    324   int mGeneratorId; 
    325   float mPdf; 
    326    
    327   SimpleRay(): mType(Ray::LOCAL_RAY) { 
    328   } 
    329    
    330   SimpleRay(const Vector3 &o, 
    331                         const Vector3 &d, 
    332                         const short distribution, 
    333                         const float weight 
    334                         ): 
    335         mOrigin(o), 
    336         mDirection(d), 
    337         mType(Ray::LOCAL_RAY), 
    338         mDistribution(distribution), 
    339         mPdf(weight) 
    340   {      
    341         //      mId = sSimpleRayId++; 
    342   } 
    343  
    344   float GetParam(const int axis) const { 
    345         if (axis < 3) 
    346           return mOrigin[axis]; 
    347         else 
    348           return mDirection[axis-3]; 
    349   } 
    350    
    351   Vector3 Extrap(const float t) const { 
    352           return mOrigin + mDirection * t; 
    353   } 
    354  
    355   friend ostream &operator<<(ostream &s, const SimpleRay &r) 
    356   { 
    357           return s << "origin=" << r.mOrigin << " dir=" << r.mDirection; 
    358   }; 
    359 }; 
    360  
    361 class SimpleRayContainer : public vector<SimpleRay> 
    362 { 
    363 public: 
    364      
    365   SimpleRayContainer():vector<SimpleRay>() {} 
    366    
    367   void NormalizePdf(float scale = 1.0f) { 
    368         iterator it = begin(); 
    369         float sumPdf = 0.0f; 
    370         for (; it != end(); it++) 
    371           sumPdf += (*it).mPdf; 
    372  
    373         float c = scale/sumPdf; 
    374          
    375         for (it = begin(); it != end(); it++) { 
    376           (*it).mPdf*=c; 
    377         } 
    378   } 
    379    
    380   void AddRay(const SimpleRay &ray) { 
    381         push_back(ray); 
    382   } 
    383 }; 
    384317 
    385318} 
Note: See TracChangeset for help on using the changeset viewer.