![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsBoundingBox.hpp 00003 ******************************************************************************/ 00018 /****************************************************************************** 00019 SUKITTI PUNAK (08/26/2010) 00020 UPDATE (09/07/2010) 00021 ******************************************************************************/ 00022 #ifndef TAPs_BOUNDING_BOX_HPP 00023 #define TAPs_BOUNDING_BOX_HPP 00024 00025 #include "TAPsBoundingVolume.hpp" // Is A 00026 00027 BEGIN_NAMESPACE_TAPs 00028 //============================================================================= 00029 template <typename T> 00030 class BoundingBox : public /*virtual*/ BoundingVolume<T> { 00031 //============================================================================= 00032 // Member Functions 00033 public: 00034 //------------------------------------------------------------------------- 00035 // Output Operator << 00036 friend std::ostream & operator<< ( std::ostream &output, BoundingBox<T> const &obj ) 00037 { 00038 output << obj.StrInfo(); 00039 return output; 00040 } 00041 //------------------------------------------------------------------------- 00043 BoundingBox (); 00045 BoundingBox ( int id ); 00047 BoundingBox ( const BoundingBox<T> & orig ); 00049 virtual ~BoundingBox (); 00050 //------------------------------------------------------------------------- 00052 virtual std::string StrInfo () const; 00053 //------------------------------------------------------------------------- 00055 inline BoundingBox<T> & operator= ( BoundingBox<T> const & orig ); 00056 //------------------------------------------------------------------------- 00057 // Get/Set Cylinder Bounding Volume 00058 inline virtual T GetWidth () const {return m_tHalfWidth_x * T(2); } 00059 inline virtual void SetWidth ( T width ) { m_tHalfWidth_x = width * T(0.5); } 00060 inline virtual T GetHeight () const {return m_tHalfHeight_y * T(2); } 00061 inline virtual void SetHeight ( T height ) { m_tHalfHeight_y = height * T(0.5); } 00062 inline virtual T GetDepth () const {return m_tHalfDepth_z * T(2); } 00063 inline virtual void SetDepth ( T depth ) { m_tHalfDepth_z = depth * T(0.5); } 00064 //------------------------------------------------------------------------- 00066 virtual void ScaledBy ( T val ); 00067 //------------------------------------------------------------------------- 00068 00081 virtual bool TestPointLocation ( 00082 Vector3<T> const & point, 00083 Vector3<T> * const pvDistance = NULL ) const; 00084 00099 virtual bool TestPointLocation ( 00100 Vector3<T> const & point, 00101 TransformationSupport<T> const * const pTransform, 00102 Vector3<T> * const pvDistance = NULL ) const; 00103 00104 //------------------------------------------------------------------------- 00105 00118 virtual bool TestSphereLocation ( 00119 Vector3<T> const & sphereCenter, 00120 T sphereRadius, 00121 Vector3<T> * const pvDistance = NULL 00122 ) const; 00123 00138 virtual bool TestSphereLocation ( 00139 Vector3<T> const & sphereCenter, 00140 T sphereRadius, 00141 TransformationSupport<T> const * const pTransform, 00142 Vector3<T> * const pvDistance = NULL 00143 ) const; 00144 00145 //------------------------------------------------------------------------- 00149 virtual T TestOverlapWith ( BoundingVolume<T> const * const that ) const; 00150 00151 /* 00152 //------------------------------------------------------------------------- 00153 virtual T TestOverlapWith ( BVHNode<T> const * const that ) const; 00154 //------------------------------------------------------------------------- 00155 virtual T TestOverlapWithTillLeafNodes ( BVHNode<T> const * const that ) const; 00156 //------------------------------------------------------------------------- 00157 protected: 00158 // returning minus means overlap 00159 // returning zero means contact 00160 // returning plus means separate 00161 //========================================================================= 00162 // Binary Spheres 00163 //------------------------------------------------------------------------- 00164 inline virtual T TestOverlapSphereWithSphere ( BVHNode<T> const * const that ) const; 00165 inline virtual T TestOverlapSphereWithSphere ( BVHNode<T> const * const that, 00166 Matrix4x4<T> const & thatTransform ) const; 00167 inline virtual T TestOverlapSphereWithSphere ( Matrix4x4<T> const & thisTransform, 00168 BVHNode<T> const * const that ) const; 00169 inline virtual T TestOverlapSphereWithSphere ( Matrix4x4<T> const & thisTransform, 00170 BVHNode<T> const * const that, 00171 Matrix4x4<T> const & thatTransform ) const; 00172 //------------------------------------------------------------------------- 00173 // No Primitive-Primitive Intersection Test 00174 // Stop at Leaf-Leaf-Node Intersection Test 00175 inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( BVHNode<T> const * const that ) const; 00176 inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( BVHNode<T> const * const that, 00177 Matrix4x4<T> const & thatTransform ) const; 00178 inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( Matrix4x4<T> const & thisTransform, 00179 BVHNode<T> const * const that ) const; 00180 inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( Matrix4x4<T> const & thisTransform, 00181 BVHNode<T> const * const that, 00182 Matrix4x4<T> const & thatTransform ) const; 00183 //*/ 00184 //========================================================================= 00185 //------------------------------------------------------------------------- 00186 // With OpenGL 00187 #if defined(__gl_h_) || defined(__GL_H__) 00188 public: 00192 virtual void Draw ( 00193 GLenum drawStyle = GLU_LINE, 00194 Vector4<T> color = Vector4<T>( 0.77, 0.85, 0.75, 0.75 ) 00195 ); 00196 00200 virtual void DrawByOpenGL ( 00201 GLenum drawStyle = GLU_LINE, 00202 Vector4<T> color = Vector4<T>( 0.77, 0.85, 0.75, 0.75 ) 00203 ) { Draw( drawStyle, color ); } 00204 00205 //--------------------------------------------------------------- 00206 static GLuint g_uiDisplayList; // for OpenGL drawing 00207 static GLenum g_eDrawStyle; // for OpenGL drawing 00208 #endif 00209 //------------------------------------------------------------------------- 00210 //========================================================================= 00211 //============================================================================= 00212 //----------------------------------------------------------------------------- 00213 // Data Members -------------------------------------------------------------- 00214 protected: 00215 //-------------------------------------------------------------------- 00216 // Data Members 00217 T m_tHalfWidth_x; 00218 T m_tHalfHeight_y; 00219 T m_tHalfDepth_z; 00220 //------------------------------------------------------------------------- 00221 }; // END CLASS BoundingBox 00222 //============================================================================= 00223 END_NAMESPACE_TAPs 00224 //----------------------------------------------------------------------------- 00225 // Include definition if TAPs_USE_EXPORT is not defined 00226 //#if !defined( TAPs_USE_EXPORT ) 00227 #include "TAPsBoundingBox.cpp" 00228 //#endif 00229 //----------------------------------------------------------------------------- 00230 #endif 00231 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00232 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----