TAPs 0.7.7.3
TAPsColDetSupport.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsColDetSupport.hpp
00003 
00004 A Base (Abstract) Collision Detection support.
00005 A Model should be inherited from this class for collision detection support.
00006 
00007 SUKITTI PUNAK   (04/25/2005)
00008 UPDATE          (07/26/2010)
00009 ******************************************************************************/
00010 #ifndef TAPs_COL_DET_SUPPORT_HPP
00011 #define TAPs_COL_DET_SUPPORT_HPP
00012 
00013 #include "../CD/TAPsCDLib.hpp"
00014 
00015 BEGIN_NAMESPACE_TAPs
00016 //=============================================================================
00017 template <typename T>
00018 class ColDetSupport {
00019 //-----------------------------------------------------------------------------
00020 // Member Functions ------------------------------------------------------------
00021 public:
00022     //-------------------------------------------------------------------------
00024     ColDetSupport ();
00025     //-------------------------------------------------------------------------
00027     virtual ~ColDetSupport ();
00028     //-------------------------------------------------------------------------
00029     // Get/Set Fn(s)
00030     inline Vector3<T> GetBoundingAABBLowPoint () const;
00031     inline Vector3<T> GetBoundingAABBHighPoint () const;
00032     inline void SetBoundingAABBLowPoint ( Vector3<T> pt );
00033     inline void SetBoundingAABBHighPoint ( Vector3<T> pt );
00034     inline Vector3<T> GetBoundingEllipsoid () const;
00035     inline T          GetBoundingSphere () const;
00036     //-------------------------------------------------------------------------
00037     // Collision Detection Fn(s)
00038     virtual void CalBoundingAABB ()      {};    // default fn
00039     virtual void CalBoundingEllipsoid () {};    // default fn
00040     virtual void CalBoundingSphere ()    {};    // default fn
00041     //-------------------------------------------------------------------------
00045     virtual void BuildBVHTree ( Enum::CD treeType ) { ClearBVHTree(); }
00046 
00048     BVHTree<T> const * const GetBVHTree () const    { return m_pBVHTree; }
00050     BVHTree<T> *             GetBVHTree ()          { return m_pBVHTree; };
00051 
00053     void ClearBVHTree ();
00054     //-------------------------------------------------------------------------
00055 #if defined(__gl_h_) || defined(__GL_H__)
00056 public:
00060     virtual void DrawBVH ()
00061     { if ( m_pBVHTree ) m_pBVHTree->DrawByOpenGL(); }
00062     virtual void DrawBVH ( int startLevel, int endLevel )
00063     { if ( m_pBVHTree ) m_pBVHTree->DrawByOpenGL( 0, startLevel, endLevel ); }
00064     virtual void DrawBVHOnlyEndLevel ()
00065     { if ( m_pBVHTree ) m_pBVHTree->DrawByOpenGLOnlyEndLevel(); }
00066 #endif
00067 //-----------------------------------------------------------------------------
00068 // Data Members  ---------------------------------------------------------------
00069 protected:
00070     // Axis-Aligned Bounding Box (0 for low & 1 for high values)
00071     Vector3<T>  m_paBoundingAABB[2];
00072     Vector3<T>  m_pBoundingEllipsoid;   // radii of bounding ellipsoid
00073     T           m_pBoundingSphere;      // radius of bounding sphere
00074     Vector3<T>  m_pBoundingCenter;      // center of the bounding volumes
00075     //-------------------------------------------------------------------------
00076     // Bounding Volume Hierarchy
00077     BVHTree<T> * m_pBVHTree;
00078 };
00079 //=============================================================================
00080 END_NAMESPACE_TAPs
00081 //-----------------------------------------------------------------------------
00082 // Include definition if TAPs_USE_EXPORT is not defined
00083 //#if !defined( TAPs_USE_EXPORT )
00084     #include "TAPsColDetSupport.cpp"
00085 //#endif
00086 //-----------------------------------------------------------------------------
00087 #endif
00088 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00089 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines