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