PointEnv.h

Go to the documentation of this file.
00001 /* $Id:$ */
00002 
00003 #ifndef __POINT_ENV_H
00004 #define __POINT_ENV_H
00005 
00006 #include <esg/Definitions.h>
00007 
00008 namespace esg {
00009 
00014 #define ENV_WANT_NOTHING        (0<<0)  
00015 #define ENV_WANT_INTERFERENCE   (1<<0)  
00016 #define ENV_WANT_INTERSECTION   (1<<1)  
00017 #define ENV_WANT_SURFACE_POINT  (1<<1)  
00018 #define ENV_WANT_NORMAL         (1<<2)  
00019 #define ENV_WANT_ASOC_PRIMITIVE (1<<3)  
00020 #define ENV_WANT_DISTANCE       (1<<4)  
00021 #define ENV_WANT_TRANSFORMATION (1<<5)  
00022 #define ENV_WANT_ENERGY         (1<<6)  
00023 #define ENV_WANT_N_DOT_D        (1<<7)  
00024 #define ENV_WANT_N_DOT_O        (1<<8)  
00025 #define ENV_WANT_UV_COORD       (1<<9)  
00026 #define ENV_WANT_VIEWER_DIR     (1<<10) 
00027 
00028 
00042 #define ENV_USE_CACHE           (1<<11) 
00043 
00044 
00049 #define ENV_HAVE_NOTHING        ENV_WANT_NOTHING        
00050 #define ENV_HAVE_INTERFERENCE   ENV_WANT_INTERFERENCE   
00051 #define ENV_HAVE_INTERSECTION   ENV_WANT_INTERSECTION   
00052 #define ENV_HAVE_SURFACE_POINT  ENV_WANT_SURFACE_POINT  
00053 #define ENV_HAVE_NORMAL         ENV_WANT_NORMAL         
00054 #define ENV_HAVE_ASOC_PRIMITIVE ENV_WANT_ASOC_PRIMITIVE 
00055 #define ENV_HAVE_DISTANCE       ENV_WANT_DISTANCE       
00056 #define ENV_HAVE_TRANSFORMATION ENV_WANT_TRANSFORMATION 
00057 #define ENV_HAVE_ENERGY         ENV_WANT_ENERGY         
00058 #define ENV_HAVE_N_DOT_D        ENV_WANT_N_DOT_D        
00059 #define ENV_HAVE_N_DOT_O        ENV_WANT_N_DOT_O        
00060 #define ENV_HAVE_UV_COORD       ENV_WANT_UV_COORD       
00061 #define ENV_HAVE_VIEWER_DIR     (1<<10)                 
00062 
00063 
00070 // Visitable object means node of scene graph allowing its instection
00071 // by VISITOR pattern, typically it is primitive or its specialization
00072 class OGSCENE_EXPORT PointEnv {
00073 public:
00074         /*
00075          * Normal at the PoI can be either oriented outwards the object,
00076          * inward the object or can be unknown (random)
00077          */
00078         enum NormalOrientation {
00079             OUTWARDS_NORMAL,
00080             INWARDS_NORMAL,
00081             RANDOM_NORMAL
00082         };
00083         
00084 public:
00085         Color3f    energy;          
00086         Vector3    intersection;    
00087         Vector2    uvCoord;         
00088         Vector3    normal;          
00089         SceneGraphObject* pVisitableObj; 
00090         int        mask;            
00091         NormalOrientation normalOrientation; 
00092         Matrix4    trMat;           
00093         Vector3    viewerDir;       
00094         double     distance;        
00095         double     nd;              
00096         double     no;              
00097         Cache*     pCache;          
00098 
00099 public:
00103         PointEnv ()
00104             : pVisitableObj(NULL),
00105               mask(ENV_HAVE_NOTHING),
00106               normalOrientation(RANDOM_NORMAL),
00107               pCache(NULL)
00108               {
00109                   trMat.setIdentity();
00110               }
00111 
00115         virtual ~PointEnv() { if (pCache)  delete pCache; }
00116 
00117         /*
00118     inline void init (void)
00119     {
00120         _mask = ENV_HAVE_NOTHING;
00121         _pVisitableObj = NULL;
00122         _pCache = NULL;
00123     }
00124 
00125     inline void setEnergy (const Color3f& c)
00126     {
00127         _energy.set(c);
00128         _mask |= ENV_HAVE_ENERGY;
00129     }
00130     
00131     inline void setIntersection (const Vector3& i)
00132     {
00133         _intersection.set(i);
00134         _mask |= ENV_HAVE_INTERSECTION|ENV_HAVE_INTERFERENCE;
00135     }
00136 
00137     inline void setUVCoord (const Vector2& c)
00138     {
00139         _uvCoord.set(c);
00140         _mask |= ENV_HAVE_UV_COORD;
00141     }
00142 
00143     inline void setUVCoord (float u, float v)
00144     {
00145         _uvCoord.set(u, v);
00146         _mask |= ENV_HAVE_UV_COORD;
00147     }
00148 
00149     inline void setUVCoord (double u, double v)
00150     {
00151         _uvCoord.set(u, v);
00152         _mask |= ENV_HAVE_UV_COORD;
00153     }
00154 
00155     inline void setNormal (const Vector3& n, NormalOrientation o)
00156     {
00157         _normal.set(n);
00158         _normalOrientation = o;
00159         _mask |= ENV_HAVE_NORMAL;
00160     }
00161 
00162     inline void setVisitableObject (SceneGraphObject* o)
00163     {
00164         _pVisitableObj = o;
00165         ((o)
00166          ? _mask |= ENV_HAVE_ASOC_PRIMITIVE
00167          : _mask &= ~ENV_HAVE_ASOC_PRIMITIVE);
00168     }
00169 
00170     inline void setTransform (const Matrix4& m)
00171     {
00172         _trMat.set(m);
00173         _mask |= ENV_HAVE_TRANSFORMATION;
00174     }
00175 
00176     inline void setDistance (double d)
00177     {
00178         _distance = d;
00179         _mask |= ENV_HAVE_DISTANCE;
00180     }
00181 
00182     inline void setAngleND (double a)
00183     {
00184         _nd = a;
00185         _mask |= ENV_HAVE_N_DOT_D;
00186     }
00187 
00188     inline void setAngleNO (double a)
00189     {
00190         _no = a;
00191         _mask |= ENV_HAVE_N_DOT_O;
00192     }
00193 
00194     inline void setInterference (void)
00195     {
00196         _mask |= ENV_HAVE_INTERFERENCE;
00197     }
00198 
00199     inline void setViewerDir (const Vector3& v)
00200     {
00201         _viewerDir.set(v);
00202         _mask |= ENV_HAVE_VIEWER_DIR;
00203     }
00204 
00205     inline void setCache (Cache* c)
00206     {
00207         _pCache = c;
00208     }
00209 
00210     inline const Color3f& energy       (void) const { return _energy;       }
00211     inline const Vector3& intersection (void) const { return _intersection; }
00212     inline const Vector2& uvCoord      (void) const { return _uvCoord;      }
00213     inline const Vector3& normal       (void) const { return _normal;       }
00214     inline const Matrix4& transform    (void) const { return _trMat;        }
00215     inline const Vector3& viewerDir    (void) const { return _viewerDir;    }
00216     inline const double   distance     (void) const { return _distance;     }
00217     inline const double   angleND      (void) const { return _nd;           }
00218     inline const double   angleNO      (void) const { return _no;           }
00219     inline const NormalOrientation normalOrientation (void) const {
00220         return _normalOrientation;
00221     }
00222     inline SceneGraphObject* visitableObject (void) { return _pVisitableObj; }
00223     inline Cache* cache (void) { return _pCache; }
00224     //inline int mask (void) const { return _mask; }
00225     */
00226     
00227 };
00228 
00229 }; // namespace
00230 
00231 #endif // __POINT_ENV_H

Generated on Wed Jun 28 12:24:28 2006 for esg by  doxygen 1.4.6