![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsMultiBoundingVolume.hpp 00003 ******************************************************************************/ 00008 /****************************************************************************** 00009 SUKITTI PUNAK (08/22/2006) 00010 UPDATE (04/13/2010) 00011 ******************************************************************************/ 00012 #ifndef TAPs_MULTI_BOUNDING_VOLUME_HPP 00013 #define TAPs_MULTI_BOUNDING_VOLUME_HPP 00014 00015 #include "../Core/TAPsLib.hpp" 00016 // Inheritance 00017 //#include "../Support/TAPsColDetSupport.hpp" // Is A 00018 #include "../Support/TAPsPhysicsSupport.hpp" // Is A 00019 // Association 00020 #include "../Support/TAPsTransformationSupport.hpp" // Has A 00021 #include "TAPsBoundingVolumeList.hpp" // Has A 00022 00023 BEGIN_NAMESPACE_TAPs 00024 //============================================================================= 00025 template <typename T> 00026 class MultiBoundingVolume : public /*virtual*/ PhysicsSupport<T> { 00027 //============================================================================= 00028 // Member Functions 00029 public: 00030 //------------------------------------------------------------------------- 00031 // Output Operator << 00032 friend std::ostream & operator<< ( std::ostream &output, MultiBoundingVolume<T> const &obj ) 00033 { 00034 output << "MultiBoundingVolume<" << typeid(T).name() << ">"; 00035 output << "\nID: " << obj.m_iID; 00036 output << "\nName: " << obj.m_strName; 00037 output << "\n Trx: " << obj.GetTransform(); 00038 output << "\nBounding Volume List (of size " << static_cast<unsigned int>(obj.m_vBoundingVolumePtrList.size()) << "):\n"; 00039 output << "------------------------------------------------------------\n"; 00040 //------------------------------------------------- 00041 std::vector< BoundingVolume<T> * >::const_iterator pos = 00042 obj.m_vBoundingVolumePtrList.begin(); 00043 while ( pos != obj.m_vBoundingVolumePtrList.end() ) { 00044 assert( *pos != NULL ); 00045 output << **pos; 00046 ++pos; 00047 if ( pos != obj.m_vBoundingVolumePtrList.end() ) output << "\n"; 00048 } 00049 //------------------------------------------------- 00050 output << "------------------------------------------------------------\n"; 00051 return output; 00052 } 00053 //------------------------------------------------------------------------- 00055 MultiBoundingVolume (); 00056 MultiBoundingVolume ( int id ); 00058 //MultiBoundingVolume ( const MultiBoundingVolume<T> & orig ); 00059 virtual ~MultiBoundingVolume (); 00060 //------------------------------------------------------------------------- 00063 virtual void CalAndSetPhysicsCenterOfMass () 00064 { 00065 std::cout << "MultiBoundingVolume::CalAndSetPhysicsCenterOfMass() need to be coded!!!\n"; 00066 SetPhyPropCenterOfMass( 0, 0, 0 ); 00067 } 00068 //------------------------------------------------------------------------- 00069 // Get/Set Fn(s) 00070 inline std::string const & GetName () const; 00071 inline void SetName ( std::string const & name ); 00072 inline int GetID () const; 00073 inline void SetID ( int id ); 00074 //------------------------------------------------------------------------- 00075 // Get/Set Model List Fn(s) 00076 std::vector< BoundingVolume<T> * > const & GetBoundingVolumeList () const 00077 { return m_vBoundingVolumePtrList; } 00078 std::vector< BoundingVolume<T> * > & GetBoundingVolumeList () 00079 { return m_vBoundingVolumePtrList; } 00080 //------------------------------------------- 00081 // virtual void TransformByTranslationRatationAndScale (); 00082 //------------------------------------------------------------------------- 00083 // Get/Set Transformation Fn(s) 00084 TransformationSupport<T> const & GetTransform () const 00085 { return m_refTransform; } 00086 TransformationSupport<T> & GetTransform () 00087 { return m_refTransform; } 00088 //------------------------------------------------------------------------- 00089 void ScaledBy ( T val ); 00090 //------------------------------------------------------------------------- 00091 virtual T TestOverlapWith ( BoundingVolume<T> const * const that ) const; 00092 virtual T TestOverlapWith ( MultiBoundingVolume<T> const * const that ) const; 00093 //------------------------------------------------------------------------- 00094 // virtual T TestOverlapWith ( BVHNode<T> const * const that ) const; 00095 //------------------------------------------------------------------------- 00096 // virtual T TestOverlapWithTillLeafNodes ( BVHNode<T> const * const that ) const; 00097 //------------------------------------------------------------------------- 00098 /* 00099 protected: 00100 // returning minus means overlap 00101 // returning zero means contact 00102 // returning plus means separate 00103 //========================================================================= 00104 // Binary Spheres 00105 //------------------------------------------------------------------------- 00106 inline virtual T TestOverlapSphereWithSphere ( BVHNode<T> const * const that ) const; 00107 inline virtual T TestOverlapSphereWithSphere ( BVHNode<T> const * const that, 00108 Matrix4x4<T> const & thatTransform ) const; 00109 inline virtual T TestOverlapSphereWithSphere ( Matrix4x4<T> const & thisTransform, 00110 BVHNode<T> const * const that ) const; 00111 inline virtual T TestOverlapSphereWithSphere ( Matrix4x4<T> const & thisTransform, 00112 BVHNode<T> const * const that, 00113 Matrix4x4<T> const & thatTransform ) const; 00114 //------------------------------------------------------------------------- 00115 // No Primitive-Primitive Intersection Test 00116 // Stop at Leaf-Leaf-Node Intersection Test 00117 inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( BVHNode<T> const * const that ) const; 00118 inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( BVHNode<T> const * const that, 00119 Matrix4x4<T> const & thatTransform ) const; 00120 inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( Matrix4x4<T> const & thisTransform, 00121 BVHNode<T> const * const that ) const; 00122 inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( Matrix4x4<T> const & thisTransform, 00123 BVHNode<T> const * const that, 00124 Matrix4x4<T> const & thatTransform ) const; 00125 //*/ 00126 //========================================================================= 00127 //------------------------------------------------------------------------- 00128 // With OpenGL 00129 #if defined(__gl_h_) || defined(__GL_H__) 00130 public: 00132 virtual void DrawByOpenGL ( 00133 GLenum drawStyle = GLU_FILL, 00134 Vector4<T> color = Vector4<T>( 0.77, 0.85, 0.75, 0.75 ) 00135 ) { Draw( drawStyle, color ); } 00136 00138 virtual void Draw ( 00139 GLenum drawStyle = GLU_FILL, 00140 Vector4<T> color = Vector4<T>( 0.77, 0.85, 0.75, 0.75 ) 00141 ); 00142 //------------------------------------------------------------------------- 00143 //========================================================================= 00144 #endif 00145 //============================================================================= 00146 //----------------------------------------------------------------------------- 00147 // Data Members -------------------------------------------------------------- 00148 protected: 00149 //-------------------------------------------------------------------- 00150 // Data Members 00151 static int m_iTotal; // total number of models 00152 int m_iID; // ID 00153 std::string m_strName; // name 00154 //------------------------------------------------------------------------- 00155 // Bounding Volume List 00156 std::vector< BoundingVolume<T> * > m_vBoundingVolumePtrList; 00157 //------------------------------------------------------------------------- 00158 // Transformation Support (from class TransformationSupport<T> 00159 TransformationSupport<T> & m_refTransform; 00160 static TransformationSupport<T> g_dummyTransformation; 00161 //------------------------------------------------------------------------- 00162 }; // END CLASS MultiBoundingVolume 00163 //============================================================================= 00164 END_NAMESPACE_TAPs 00165 //----------------------------------------------------------------------------- 00166 // Include definition if TAPs_USE_EXPORT is not defined 00167 //#if !defined( TAPs_USE_EXPORT ) 00168 #include "TAPsMultiBoundingVolume.cpp" 00169 //#endif 00170 //----------------------------------------------------------------------------- 00171 #endif 00172 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00173 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----