TAPs 0.7.7.3
TAPsBVHNodeLeaf.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsBVHNodeLeaf.hpp
00003 
00004 SUKITTI PUNAK   (10/14/2009)
00005 UPDATE          (10/14/2009)
00006 ******************************************************************************/
00007 #ifndef TAPs_BVH_NODE_LEAF_HPP
00008 #define TAPs_BVH_NODE_LEAF_HPP
00009 
00020 #include "TAPsBVHNode.hpp"
00021 
00022 //#include <list>   // DEBUG
00023 
00025 template <typename T> class BVHTree;
00026 
00027 BEGIN_NAMESPACE_TAPs
00028 //=============================================================================
00029 template <typename T>
00030 class BVHNodeLeaf : public /*virtual*/ BVHNode<T> {
00031 //=============================================================================
00032 // Data Members
00033     friend class BVHTree<T>;
00034 public:
00035 protected:
00036 public:
00037 //=============================================================================
00038 // Member Functions
00039 public:
00040     //-------------------------------------------------------------------------
00041     // Output Operator <<
00042     friend std::ostream & operator<< ( std::ostream &output, BVHNodeLeaf<T> const &node )
00043     {
00044         output << node.StrInfo();
00045         return output;
00046     }
00047     //-------------------------------------------------------------------------
00048     // Constructor(s) and Destructor
00049     BVHNodeLeaf ( 
00050             Enum::CD type, 
00051             int id                 = -1, 
00052             BVHNode<T> * parent    = NULL );
00053     //-------------------------------------------------------------------------
00054 public:
00055     virtual ~BVHNodeLeaf ();
00056     //-------------------------------------------------------------------------
00058     virtual std::string StrInfo () const;
00059     //-------------------------------------------------------------------------
00060     // Get/Set Fn(s)
00061     inline virtual BVHNode<T> const * const Child ( int i ) const
00062         {   return NULL;    }
00063 //protected:
00064     inline virtual BVHNode<T> * Child ( int i )
00065         {   return NULL;    }
00066     //-------------------------------------------------------------------------
00067     // Node Operations
00068 public:
00069     virtual T TestOverlapWith ( BVHNode<T> const * const that ) const;
00070     virtual void Update ();
00071 protected:
00072     inline virtual void UpdateSphere ();
00073     //---------------------------------------------------------------
00074     // Get Primitive(s)
00075 protected:
00076 public:
00077     //=========================================================================
00078     // Sphere-Sphere Intersection Test
00079     //-------------------------------------------------------------------------
00095     inline virtual T TestOverlapSphereWithSphere ( 
00096                         BVHNode<T> const * const that       
00097                     ) const;
00098     inline virtual T TestOverlapSphereWithSphere ( 
00099                         BVHNode<T> const * const that,      
00100                         Matrix4x4<T> const & thatTransform  
00101                     ) const;
00102     inline virtual T TestOverlapSphereWithSphere ( 
00103                         Matrix4x4<T> const & thisTransform, 
00104                         BVHNode<T> const * const that       
00105                     ) const;
00106     inline virtual T TestOverlapSphereWithSphere ( 
00107                         Matrix4x4<T> const & thisTransform, 
00108                         BVHNode<T> const * const that,      
00109                         Matrix4x4<T> const & thatTransform  
00110                     ) const;
00111     //-------------------------------------------------------------------------
00112 
00113     //=========================================================================
00114     // Sphere-BVSphere Intersection Test (BinarySphereTree vs Sphere BV)
00115     //-------------------------------------------------------------------------
00131     inline virtual T TestOverlapSphereWithBVSphere ( 
00132                         Vector3<T> const & centerOfBVSphere,    
00133                         T radiusOfBVSphere                      
00134                     ) const;
00135     inline virtual T TestOverlapSphereWithBVSphere ( 
00136                         Matrix4x4<T> const & transformA,        
00137                         Vector3<T> const & centerOfBVSphere,    
00138                         T radiusOfBVSphere                      
00139                     ) const;
00140     //-------------------------------------------------------------------------
00141 
00142     //=========================================================================
00143     // Sphere-BVCylinder Intersection Test (BinarySphereTree vs Cylinder BV)
00144     //-------------------------------------------------------------------------
00160     inline virtual bool TestOverlapSphereWithBVCylinder_AtOrigin ( 
00161                         Vector3<T> const & centerOfBVCylinder,  
00162                         T radiusOfBVCylinder,                   
00163                         T heightOfBVCylinder                    
00164                     ) const;
00165     inline virtual bool TestOverlapSphereWithBVCylinder_AtOrigin ( 
00166                         Matrix4x4<T> const & transformA,        
00167                         Vector3<T> const & centerOfBVCylinder,  
00168                         T radiusOfBVCylinder,                   
00169                         T heightOfBVCylinder                    
00170                     ) const;
00171     //-------------------------------------------------------------------------
00172 
00173     //-------------------------------------------------------------------------
00174 #if defined(__gl_h_) || defined(__GL_H__)
00175 public:
00176     // DrawByOpenGL
00177     virtual void Draw () const  { DrawByOpenGL(); }
00178     virtual void DrawByOpenGL () const;
00179     virtual void DrawByOpenGL ( int currentLevel, int startLevel, int endLevel ) const;
00180 protected:
00181     virtual void DrawBV ( GLenum drawStyle = GLU_LINE ) const;
00182     virtual void DrawPrim ( GLenum drawStyle = GLU_LINE ) const {};     // DEBUG
00183 //  static GLuint   m_uiDisplayList;    // for OpenGL (sphere) drawing
00184 #endif
00185     //-------------------------------------------------------------------------
00186 }; // END CLASS BVHNodeLeaf
00187 //=============================================================================
00188 END_NAMESPACE_TAPs
00189 //-----------------------------------------------------------------------------
00190 // Include definition if TAPs_USE_EXPORT is not defined
00191 //#if !defined( TAPs_USE_EXPORT )
00192     #include "TAPsBVHNodeLeaf.cpp"
00193 //#endif
00194 //-----------------------------------------------------------------------------
00195 #endif
00196 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00197 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines