TAPs 0.7.7.3
TAPsBoundingSphere.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsBoundingSphere.hpp
00003 ******************************************************************************/
00017 /******************************************************************************
00018 SUKITTI PUNAK   (08/22/2006)
00019 UPDATE          (09/07/2010)
00020 ******************************************************************************/
00021 #ifndef TAPs_BOUNDING_SPHERE_HPP
00022 #define TAPs_BOUNDING_SPHERE_HPP
00023 
00024 #include "TAPsBoundingVolume.hpp"   // Is A
00025 
00026 BEGIN_NAMESPACE_TAPs
00027 //=============================================================================
00028 template <typename T>
00029 class BoundingSphere : public /*virtual*/ BoundingVolume<T> {
00030 //=============================================================================
00031 // Member Functions
00032 public:
00033     //-------------------------------------------------------------------------
00034     // Output Operator <<
00035     friend std::ostream & operator<< ( std::ostream &output, BoundingSphere<T> const &obj )
00036     {
00037         output << obj.StrInfo();
00038         return output;
00039     }
00040     //-------------------------------------------------------------------------
00042     BoundingSphere  ();
00043     BoundingSphere  ( int id );
00045     BoundingSphere  ( const BoundingSphere & orig );
00046     virtual ~BoundingSphere ();
00047     //-------------------------------------------------------------------------
00049     virtual std::string StrInfo () const;
00050     //-------------------------------------------------------------------------
00051     // Assignment Operator
00052     inline BoundingSphere<T> & operator= ( BoundingSphere<T> const & orig );
00053     //-------------------------------------------------------------------------
00054     // Get/Set Sphere Bounding Volume
00055     inline virtual T            GetRadius () const {return m_tRadius; }
00056     inline virtual void         SetRadius ( T radius ) { m_tRadius = radius; }
00057     //-------------------------------------------------------------------------
00058     // Scale the bounding volume
00059     virtual void ScaledBy ( T val );
00060     //-------------------------------------------------------------------------
00061 
00074     virtual bool TestPointLocation ( 
00075         Vector3<T> const & point,
00076         Vector3<T> * const pvDistance = NULL ) const;
00077 
00092     virtual bool TestPointLocation ( 
00093         Vector3<T> const & point,
00094         TransformationSupport<T> const * const pTransform, 
00095         Vector3<T> * const pvDistance = NULL ) const;
00096 
00097     //-------------------------------------------------------------------------
00098 
00111     virtual bool TestSphereLocation ( 
00112         Vector3<T> const & sphereCenter,
00113         T   sphereRadius,
00114         Vector3<T> * const pvDistance = NULL 
00115     ) const;
00116 
00131     virtual bool TestSphereLocation ( 
00132         Vector3<T> const & sphereCenter,
00133         T   sphereRadius,
00134         TransformationSupport<T> const * const pTransform, 
00135         Vector3<T> * const pvDistance = NULL 
00136     ) const;
00137 
00138     //-------------------------------------------------------------------------
00142     virtual T TestOverlapWith ( BoundingVolume<T> const * const that ) const;
00143 
00144 /*
00145     //-------------------------------------------------------------------------
00146     virtual T TestOverlapWith ( BVHNode<T> const * const that ) const;
00147     //-------------------------------------------------------------------------
00148     virtual T TestOverlapWithTillLeafNodes ( BVHNode<T> const * const that ) const;
00149     //-------------------------------------------------------------------------
00150 protected:
00151     // returning minus means overlap
00152     // returning zero  means contact
00153     // returning plus  means separate
00154     //=========================================================================
00155     // Binary Spheres
00156     //-------------------------------------------------------------------------
00157     inline virtual T TestOverlapSphereWithSphere ( BVHNode<T> const * const that ) const;
00158     inline virtual T TestOverlapSphereWithSphere ( BVHNode<T> const * const that, 
00159                                             Matrix4x4<T> const & thatTransform ) const;
00160     inline virtual T TestOverlapSphereWithSphere ( Matrix4x4<T> const & thisTransform, 
00161                                             BVHNode<T> const * const that ) const;
00162     inline virtual T TestOverlapSphereWithSphere ( Matrix4x4<T> const & thisTransform, 
00163                                             BVHNode<T> const * const that, 
00164                                             Matrix4x4<T> const & thatTransform ) const;
00165     //-------------------------------------------------------------------------
00166     // No Primitive-Primitive Intersection Test
00167     // Stop at Leaf-Leaf-Node Intersection Test
00168     inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( BVHNode<T> const * const that ) const;
00169     inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( BVHNode<T> const * const that, 
00170                                             Matrix4x4<T> const & thatTransform ) const;
00171     inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( Matrix4x4<T> const & thisTransform, 
00172                                             BVHNode<T> const * const that ) const;
00173     inline virtual T TestOverlapSphereWithSphereTillLeafNodes ( Matrix4x4<T> const & thisTransform, 
00174                                             BVHNode<T> const * const that, 
00175                                             Matrix4x4<T> const & thatTransform ) const;
00176 //*/
00177     //=========================================================================
00178     //-------------------------------------------------------------------------
00179     // With OpenGL
00180 #if defined(__gl_h_) || defined(__GL_H__)
00181 public:
00185     virtual void Draw (
00186                 GLenum drawStyle = GLU_LINE, 
00187                 Vector4<T> color = Vector4<T>( 0.77, 0.85, 0.75, 0.75 ) 
00188     );
00189 
00193     virtual void DrawByOpenGL (
00194                 GLenum drawStyle = GLU_LINE, 
00195                 Vector4<T> color = Vector4<T>( 0.77, 0.85, 0.75, 0.75 ) 
00196     )   { Draw( drawStyle, color ); }
00197 
00198     //---------------------------------------------------------------
00199     static GLuint   g_uiDisplayList;    // for OpenGL drawing
00200     static GLenum   g_eDrawStyle;       // for OpenGL drawing
00201 #endif
00202     //-------------------------------------------------------------------------
00203     //=========================================================================
00204 //=============================================================================
00205 //-----------------------------------------------------------------------------
00206 // Data Members  --------------------------------------------------------------
00207 protected:
00208     //--------------------------------------------------------------------
00209     // Data Members
00210     T           m_tRadius;      // Radius
00211     //-------------------------------------------------------------------------
00212 }; // END CLASS BoundingSphere
00213 //=============================================================================
00214 END_NAMESPACE_TAPs
00215 //-----------------------------------------------------------------------------
00216 // Include definition if TAPs_USE_EXPORT is not defined
00217 //#if !defined( TAPs_USE_EXPORT )
00218     #include "TAPsBoundingSphere.cpp"
00219 //#endif
00220 //-----------------------------------------------------------------------------
00221 #endif
00222 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00223 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines