00001 /* $Id: RayIntExplorer.h,v 1.2 2002/11/05 14:31:15 anonymous Exp $ */ 00002 00003 #ifndef __RAY_INTERSECTION_EXPLORER_H 00004 #define __RAY_INTERSECTION_EXPLORER_H 00005 00006 #include <esg/Definitions.h> 00007 #include <esg/SceneGraphObject.h> 00008 #include <esg/Intersector.h> 00009 #include <esg/explorer/Explorer.h> 00010 #include <esg/Statistics.h> 00011 00012 namespace esg { 00013 00014 class OGSCENE_EXPORT RayIntExplorer : public Explorer { 00015 #ifdef ESG_STATISTICS 00016 private: 00017 unsigned long _primTestsCounter; 00018 unsigned long _primTestsSucCounter; 00019 #endif // ESG_STATISTICS 00020 00021 protected: 00022 Vector3 _origin; // Original origin 00023 Vector3 _direction; // Original direction 00024 Intersector* _pIntersector; 00025 float _maxDist; // Interferation points behind this value 00026 // are ignored 00027 Vector3 _trOrigin; // Aux. origin and direction used 00028 Vector3 _trDirection; // during traverrsal 00029 Matrix4 _accumMat; // Tr. mat. of found object 00030 bool _transformed; // _accumMat validity 00031 00032 // aux. global variables speeding-up traversal a little bit because 00033 // they heed not be allocated again and again in recursion 00034 SceneGraphObject * _pCandidate; // aux. variable speeding-up traversal 00035 bool _retVal; 00036 float _actDist; 00037 Matrix3 _rMat; 00038 const Vector3 * _tVec; 00039 const Vector3 * _sVec; 00040 00041 protected: 00042 // Functionality of _iterate(), _process_leaf() and 00043 // _accept_new_transformation() methods is moved directly into 00044 // the redefined _explore() function to get the intersection tests 00045 // a little bit faster 00046 virtual bool _explore (SceneGraphObject&); 00047 virtual bool _iterate (SceneGraphObject&) {return false;} 00048 virtual bool _process_leaf (SceneGraphObject&) {return false;} 00049 virtual void _accept_new_transformation (const Matrix4&) {} 00050 00051 public: 00052 // Intersector must be already initialized !!! 00053 RayIntExplorer (const Vector3& o, 00054 const Vector3& d, 00055 Intersector* pI, 00056 float m = MAXFLOAT); 00057 00058 virtual void explore (SceneGraphObject&); 00059 00060 virtual void reinit (const Vector3& o, 00061 const Vector3& d, 00062 Intersector* pI, 00063 float m = MAXFLOAT); 00064 00065 PointEnv* result (); 00066 }; 00067 00068 }; // namespace 00069 00070 #endif //__RAY_INTERSECTION_EXPLORER_H