ShadowExplorer.h

Go to the documentation of this file.
00001 /* $Id: HiddenPointExplorer.h,v 1.2 2002/11/05 14:31:15 anonymous Exp $ */
00002 
00003 #ifndef __SHADOW_EXPLORER_H
00004 #define __SHADOW_EXPLORER_H
00005 
00006 #include <esg/Definitions.h>
00007 #include <esg/explorer/RayIntExplorer.h>
00008 #include <esg/LightArray.h>
00009 
00010 /*
00011  * The result() method returns true if and only if the point of interest
00012  * (ray origin) is shadowed by some object in given direction (ray direction),
00013  * i.e. if there exists a point of intersection
00014  * of given ray with some object in scene and if this intersection
00015  * is closer than maximal distance (parametter m in constructor)
00016  */
00017 
00018 namespace esg {
00019 
00020 class OGSCENE_EXPORT ShadowExplorer : public RayIntExplorer {
00021 protected:
00022     PointEnv                  _env;       // aux. variable
00023     Geometry                * _pGeometry; // aux. variable
00024     SceneGraphObject::OID     _lightOID;  // OID of light source itself
00025     LightArray::BlockingObj   _blockingObj;
00026 
00027 protected:
00028     // Functionality of _iterate(), _process_leaf() and
00029     // _accept_new_transformation() methods is moved directly into
00030     // the redefined _explore() function to get the tests a little bit faster
00031     virtual bool _explore                   (SceneGraphObject&);
00032     virtual bool _iterate                   (SceneGraphObject&) {return false;}
00033     virtual bool _process_leaf              (SceneGraphObject&) {return false;}
00034     virtual void _accept_new_transformation (const Matrix4&)    {}
00035 
00036 public:
00037     ShadowExplorer(const Vector3&        o,  // ray's origin
00038                    const Vector3&        d,  // direction to light source
00039                    SceneGraphObject::OID oid,
00040                    float                 m = MAXFLOAT) // light source distance
00041         : RayIntExplorer(o, d, NULL, m), _lightOID(oid) {}
00042 
00043     virtual void explore (SceneGraphObject&);
00044 
00045     bool result () { return (_blockingObj.pObj != NULL); }
00046 
00047     const LightArray::BlockingObj& getBlockingObj (void) const { return _blockingObj; }
00048 
00049     virtual void reinit (const Vector3&        o,
00050                          const Vector3&        d,
00051                          SceneGraphObject::OID oid,
00052                          Intersector*          pI = NULL,
00053                          float                 m = MAXFLOAT)
00054     {
00055         _transformed = false;
00056         _origin.set(o);
00057         _direction.set(d);
00058         _trOrigin.set(o);
00059         _trDirection.set(d);
00060         _maxDist = m;
00061         _blockingObj.pObj = NULL;
00062         _blockingObj.transformed = false;
00063         _lightOID = oid;
00064     }
00065 
00066     virtual void reinit (const Vector3&        o,
00067                          const Vector3&        d,
00068                          SceneGraphObject::OID oid,
00069                          float                 m = MAXFLOAT)
00070     {
00071         _transformed = false;
00072         _origin.set(o);
00073         _direction.set(d);
00074         _trOrigin.set(o);
00075         _trDirection.set(d);
00076         _maxDist = m;
00077         _blockingObj.pObj = NULL;
00078         _blockingObj.transformed = false;
00079         _lightOID = oid;
00080     }
00081 };
00082 
00083 }; // namespace
00084 
00085 #endif // __SHADOW_POINT_EXPLORER_H

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