TAPs 0.7.7.3
TAPsBoundingSphere.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsBoundingSphere.hpp
00003 ******************************************************************************/
00007 /******************************************************************************
00008 SUKITTI PUNAK   (08/22/2006)
00009 UPDATE          (12/30/2010)
00010 ******************************************************************************/
00011 #include "TAPsBoundingSphere.hpp"
00012 // Using Inclusion Model (i.e. definitions are included in declarations)
00013 //                       (this name.cpp is included in name.hpp)
00014 // Each friend is defined directly inside its declaration.
00015 
00016 BEGIN_NAMESPACE_TAPs
00017 //=============================================================================
00018 // Constructor(s) and Destructor
00019 //-----------------------------------------------------------------------------
00020 template <typename T>
00021 BoundingSphere<T>::BoundingSphere ()
00022     : BoundingVolume<T>( Enum::BOUNDING_SPHERE ),
00023       m_tRadius( 1 )
00024 {}
00025 //-----------------------------------------------------------------------------
00026 template <typename T>
00027 BoundingSphere<T>::BoundingSphere ( int id )
00028     : BoundingVolume<T>( Enum::BOUNDING_SPHERE, id ),
00029       m_tRadius( 1 )
00030 {}
00031 //-----------------------------------------------------------------------------
00032 template <typename T>
00033 BoundingSphere<T>::BoundingSphere ( const BoundingSphere<T> & orig )
00034     : BoundingVolume<T>( orig ),
00035       m_vCenter( orig.m_vCenter ),
00036       m_tRadius( orig.m_tRadius )
00037 {
00038     m_vCenter = orig.m_vCenter;
00039 }
00040 //-----------------------------------------------------------------------------
00041 template <typename T>
00042 BoundingSphere<T>::~BoundingSphere ()
00043 {}
00044 //-----------------------------------------------------------------------------
00045 // Return this object info as a string
00046 template <typename T>
00047 std::string BoundingSphere<T>::StrInfo () const
00048 {
00049     std::string str = BoundingVolume<T>::StrInfo();
00050     std::ostringstream ss;
00051     ss << "\n  Radius: " << m_tRadius;
00052     return str + ss.str() + "\n";
00053 }
00054 //-----------------------------------------------------------------------------
00055 // Assignment Operator
00056 template <typename T>
00057 inline TAPs::BoundingSphere<T> & TAPs::BoundingSphere<T>::operator= ( 
00058     TAPs::BoundingSphere<T> const & orig )
00059 {   
00060     if ( this != &orig ) {
00061         m_vCenter = orig.m_vCenter;
00062         m_tRadius = orig.m_tRadius;
00063     }
00064     return *this;
00065 }
00066 //-----------------------------------------------------------------------------
00067 //-----------------------------------------------------------------------------
00068 // virtual void TransformByTranslationRatationAndScale ();
00069 //template <typename T>
00070 //void BoundingSphere<T>::TransformByTranslationRatationAndScale ()
00071 //{}
00072 //-----------------------------------------------------------------------------
00073 template <typename T>
00074 void BoundingSphere<T>::ScaledBy ( T val )
00075 {
00076     assert( 0.0 <= val );
00077     GetTransform().PreApplyUniformScale( val );
00078 }
00079 //-----------------------------------------------------------------------------
00080 //=============================================================================
00081 // Operations
00082 //-----------------------------------------------------------------------------
00083 template <typename T>
00084 bool BoundingSphere<T>::TestPointLocation ( 
00085     Vector3<T> const & point,
00086     Vector3<T> * const pvDistance ) const
00087 {
00088     bool isThePointInsideTheSphere = false;
00089     //---------------------------------------------------------------
00090     // In the local coordinate of the bounding sphere, 
00091     // the sphere's center is at the origin. 
00092     // The sphere has radius and center.
00093     //---------------------------------------------------------------
00094     // Transform point to the sphere BV local coordinate
00095     Vector3<T> location = point;
00096     location = (GetTransform().GetMatrixTransform().GetInverse() * Vector4<T>(location)).GetVector3();
00097     // Shift the location of point by the sphere BV center
00098     // i.e. shift the sphere BV to the origin (0,0,0)
00099     location -= GetCenter();
00100     //---------------------------------------------------------------
00101     // Now the sphere BV is centered at the origin.
00102     // And the input point has been transformed into the sphere BV coordinate.
00103     // The test can be performed below.
00104     T   ptRadius = location.Length();
00105     //===============================================================
00106     // If the point is INSIDE the sphere
00107     //---------------------------------------------------------------
00108     // If the point is within the sphere radius
00109     T distance = GetRadius() - ptRadius;
00110     if ( distance >= 0 ) { 
00111         if ( pvDistance ) {
00112             (*pvDistance) = location.Normalized() * distance;
00113             //-------------------------
00114             // Now rotate it back by the rotation matrix (from the transform matrix).
00115             // REMARK: Translation (from the transform matrix) is NOT applied back, 
00116             //         because pvDistance represents a displacement vector from 
00117             //         the input point to the sphere surface.
00118             (*pvDistance) = GetTransform().GetMatrixRotation() * (*pvDistance);
00119             //-------------------------
00120             isThePointInsideTheSphere = true;
00121         }
00122     }
00123     //===============================================================
00124     // If the point is NOT INSIDE the sphere radius
00125     //---------------------------------------------------------------
00126     else {
00127         if ( pvDistance ) {
00128             (*pvDistance).SetXYZ( 0, 0, 0 );
00129         }
00130     }
00131     //---------------------------------------------------------------
00132     return isThePointInsideTheSphere;
00133 }
00134 //-----------------------------------------------------------------------------
00135 template <typename T>
00136 bool BoundingSphere<T>::TestPointLocation ( 
00137     Vector3<T> const & point,
00138     TransformationSupport<T> const * const pTransform, 
00139     Vector3<T> * const pvDistance ) const
00140 {
00141     bool isThePointInsideTheSphere = false;
00142     //---------------------------------------------------------------
00143     TransformationSupport<T> transform; // default ctor is an identity
00144     //Matrix4x4<T> pureRotation;
00145     //pureRotation *= pTransform->GetMatrixRotation();
00146     transform.RefToMatrixTransform() *= pTransform->GetMatrixTransform();
00147     // The above statement is equivalent to the below statement
00148     //transform.ReturnMatrixTransform() = transform.GetMatrixTransform() * pTransform->GetMatrixTransform();
00149     //pureRotation *= GetTransform().GetMatrixRotation();
00150     transform.RefToMatrixTransform() *= GetTransform().GetMatrixTransform();
00151     // The above statement is equivalent to the below statement
00152     //transform.ReturnMatrixTransform() = transform.GetMatrixTransform() * GetTransform().GetMatrixTransform();
00153     //---------------------------------------------------------------
00154     // In the local coordinate of the bounding sphere, 
00155     // the sphere's center is at the origin. 
00156     // The sphere has radius and center.
00157     //---------------------------------------------------------------
00158     // Transform point to the sphere BV local coordinate
00159     Vector3<T> location = point;
00160     location = (transform.GetMatrixTransform().GetInverse() * Vector4<T>(location)).GetVector3();
00161     // Shift the location of point by the sphere BV center
00162     // i.e. shift the sphere BV to the origin (0,0,0)
00163     location -= GetCenter();
00164     //---------------------------------------------------------------
00165     // Now the sphere is centered at the origin.
00166     // And the input point has been transformed into the sphere coordinate.
00167     // The test can be performed below.
00168     T   ptRadius = location.Length();
00169     //===============================================================
00170     // If the point is INSIDE the sphere
00171     //---------------------------------------------------------------
00172     // If the point is within the sphere radius
00173     T distance = GetRadius() - ptRadius;
00174     if ( distance >= 0 ) { 
00175         if ( pvDistance ) {
00176             (*pvDistance) = location.Normalized() * distance;
00177             //-------------------------
00178             // Now rotate it back by the rotation matrix (from the transform matrix).
00179             // REMARK: Translation (from the transform matrix) is NOT applied back, 
00180             //         because pvDistance represents a displacement vector from 
00181             //         the input point to the sphere surface.
00182             (*pvDistance) = transform.GetMatrixRotation() * (*pvDistance);
00183             //(*pvDistance) = pureRotation * (*pvDistance);
00184             //-------------------------
00185             isThePointInsideTheSphere = true;
00186         }
00187     }
00188     //===============================================================
00189     // If the point is NOT INSIDE the sphere radius
00190     //---------------------------------------------------------------
00191     else {
00192         if ( pvDistance ) {
00193             (*pvDistance).SetXYZ( 0, 0, 0 );
00194         }
00195     }
00196     //---------------------------------------------------------------
00197     return isThePointInsideTheSphere;
00198 }
00199 //-----------------------------------------------------------------------------
00200 template <typename T>
00201 bool BoundingSphere<T>::TestSphereLocation ( 
00202     Vector3<T> const & sphereCenter,
00203     T   sphereRadius,
00204     Vector3<T> * const pvDistance ) const
00205 {
00206     bool isThePointInsideTheSphere = false;
00207     //---------------------------------------------------------------
00208     // In the local coordinate of the bounding sphere, 
00209     // the sphere's center is at the origin. 
00210     // The sphere has radius and center.
00211     //---------------------------------------------------------------
00212     // Transform the sphere center to the sphere BV local coordinate
00213     Vector3<T> location = sphereCenter;
00214     location = (GetTransform().GetMatrixTransform().GetInverse() * Vector4<T>(location)).GetVector3();
00215     // Shift the location of sphere center by the sphere BV center
00216     // i.e. shift the sphere BV to the origin (0,0,0)
00217     location -= GetCenter();
00218     //---------------------------------------------------------------
00219     // Now the sphere BV is centered at the origin.
00220     // And the input point has been transformed into the sphere BV coordinate.
00221     // The test can be performed below.
00222     T   ptRadius = location.Length() - sphereRadius;
00223     //===============================================================
00224     // If the point is INSIDE the sphere
00225     //---------------------------------------------------------------
00226     // If the point is within the sphere radius
00227     T distance = GetRadius() - ptRadius;
00228     if ( distance >= 0 ) { 
00229         if ( pvDistance ) {
00230             (*pvDistance) = location.Normalized() * distance;
00231             //-------------------------
00232             // Now rotate it back by the rotation matrix (from the transform matrix).
00233             // REMARK: Translation (from the transform matrix) is NOT applied back, 
00234             //         because pvDistance represents a displacement vector from 
00235             //         the input point to the sphere surface.
00236             (*pvDistance) = GetTransform().GetMatrixRotation() * (*pvDistance);
00237             //-------------------------
00238             isThePointInsideTheSphere = true;
00239         }
00240     }
00241     //===============================================================
00242     // If the point is NOT INSIDE the sphere radius
00243     //---------------------------------------------------------------
00244     else {
00245         if ( pvDistance ) {
00246             (*pvDistance).SetXYZ( 0, 0, 0 );
00247         }
00248     }
00249     //---------------------------------------------------------------
00250     return isThePointInsideTheSphere;
00251 }
00252 //-----------------------------------------------------------------------------
00253 template <typename T>
00254 bool BoundingSphere<T>::TestSphereLocation ( 
00255     Vector3<T> const & sphereCenter,
00256     T   sphereRadius,
00257     TransformationSupport<T> const * const pTransform, 
00258     Vector3<T> * const pvDistance ) const
00259 {
00260     bool isThePointInsideTheSphere = false;
00261     //---------------------------------------------------------------
00262     TransformationSupport<T> transform; // default ctor is an identity
00263     //Matrix4x4<T> pureRotation;
00264     //pureRotation *= pTransform->GetMatrixRotation();
00265     transform.RefToMatrixTransform() *= pTransform->GetMatrixTransform();
00266     // The above statement is equivalent to the below statement
00267     //transform.ReturnMatrixTransform() = transform.GetMatrixTransform() * pTransform->GetMatrixTransform();
00268     //pureRotation *= GetTransform().GetMatrixRotation();
00269     transform.RefToMatrixTransform() *= GetTransform().GetMatrixTransform();
00270     // The above statement is equivalent to the below statement
00271     //transform.ReturnMatrixTransform() = transform.GetMatrixTransform() * GetTransform().GetMatrixTransform();
00272     //---------------------------------------------------------------
00273     // In the local coordinate of the bounding sphere, 
00274     // the sphere's center is at the origin. 
00275     // The sphere has radius and center.
00276     //---------------------------------------------------------------
00277     // Transform the sphere center to the sphere BV local coordinate
00278     Vector3<T> location = sphereCenter;
00279     location = (transform.GetMatrixTransform().GetInverse() * Vector4<T>(location)).GetVector3();
00280     // Shift the location of point by the sphere BV center
00281     // i.e. shift the sphere BV to the origin (0,0,0)
00282     location -= GetCenter();
00283     //---------------------------------------------------------------
00284     // Now the sphere is centered at the origin.
00285     // And the input point has been transformed into the sphere coordinate.
00286     // The test can be performed below.
00287     T   ptRadius = location.Length() - sphereRadius;
00288     //===============================================================
00289     // If the point is INSIDE the sphere
00290     //---------------------------------------------------------------
00291     // If the point is within the sphere radius
00292     T distance = GetRadius() - ptRadius;
00293     if ( distance >= 0 ) { 
00294         if ( pvDistance ) {
00295             (*pvDistance) = location.Normalized() * distance;
00296             //-------------------------
00297             // Now rotate it back by the rotation matrix (from the transform matrix).
00298             // REMARK: Translation (from the transform matrix) is NOT applied back, 
00299             //         because pvDistance represents a displacement vector from 
00300             //         the input point to the sphere surface.
00301             (*pvDistance) = transform.GetMatrixRotation() * (*pvDistance);
00302             //(*pvDistance) = pureRotation * (*pvDistance);
00303             //-------------------------
00304             isThePointInsideTheSphere = true;
00305         }
00306     }
00307     //===============================================================
00308     // If the point is NOT INSIDE the sphere radius
00309     //---------------------------------------------------------------
00310     else {
00311         if ( pvDistance ) {
00312             (*pvDistance).SetXYZ( 0, 0, 0 );
00313         }
00314     }
00315     //---------------------------------------------------------------
00316     return isThePointInsideTheSphere;
00317 }
00318 //-----------------------------------------------------------------------------
00319 // TestOverlapWith
00320 template <typename T>
00321 T BoundingSphere<T>::TestOverlapWith ( BoundingVolume<T> const * const that ) const
00322 {
00323     std::cout << "BoundingSphere<T>::TestOverlapWith( BoundingVolume<T> ) -- NOT IMPLEMENTED YET!!!\n";
00324 
00325     switch ( that->GetType() ) {
00326     case Enum::BOUNDING_SPHERE:
00327         break;
00328     case Enum::BOUNDING_BOX:
00329         break;
00330     case Enum::BOUNDING_CYLINDER:
00331         break;
00332     }
00333 
00334     return 0;
00335 }
00336 /*
00337 //-----------------------------------------------------------------------------
00338 // TestOverlapWith
00339 template <typename T>
00340 T BVHNode<T>::TestOverlapWith ( BVHNode<T> const * const that ) const
00341 {
00342     switch ( m_eType ) {
00343         case Enum::BVH_NODE_BINARY_SPHERE:
00344         case Enum::BVH_NODE_QUAD_SPHERE:
00345         case Enum::BVH_NODE_OCTANT_SPHERE:
00346         case Enum::BVH_NODE_GENERIC_SPHERE:
00347         case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_APRIM:
00348         case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_PRIMS:
00349             switch ( that->m_eType ) {
00350                 case Enum::BVH_NODE_BINARY_SPHERE:
00351                 case Enum::BVH_NODE_QUAD_SPHERE:
00352                 case Enum::BVH_NODE_OCTANT_SPHERE:
00353                 case Enum::BVH_NODE_GENERIC_SPHERE:
00354                 case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_APRIM:
00355                     return    ( GetCenter() - that->GetCenter() ).Length() 
00356                             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00357                     break;
00358                 case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_PRIMS:
00359                     return    ( GetCenter() - that->GetCenter() ).Length() 
00360                             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00361                     break;
00362                 default:
00363                     std::cout << "Error: BVHNode<T>::TestOverlapWith Fn!" << std::endl;
00364                     assert( false );
00365                     break;
00366             }
00367             break;
00368         default:
00369             std::cout << "Error: BVHNode<T>::TestOverlapWith Fn!" << std::endl;
00370             assert( false );
00371             break;
00372     }
00373     return -777;    // -777 is an Error Code
00374 }
00375 //*/
00376 /*
00377 //-----------------------------------------------------------------------------
00378 // TestOverlapWithTillLeafNodes
00379 template <typename T>
00380 T BVHNode<T>::TestOverlapWithTillLeafNodes ( BVHNode<T> const * const that ) const
00381 {
00382     switch ( m_eType ) {
00383         case Enum::BVH_NODE_BINARY_SPHERE:
00384         case Enum::BVH_NODE_QUAD_SPHERE:
00385         case Enum::BVH_NODE_OCTANT_SPHERE:
00386         case Enum::BVH_NODE_GENERIC_SPHERE:
00387         case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_APRIM:
00388         case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_PRIMS:
00389             switch ( that->m_eType ) {
00390                 case Enum::BVH_NODE_BINARY_SPHERE:
00391                 case Enum::BVH_NODE_QUAD_SPHERE:
00392                 case Enum::BVH_NODE_OCTANT_SPHERE:
00393                 case Enum::BVH_NODE_GENERIC_SPHERE:
00394                 case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_APRIM:
00395                     return    ( GetCenter() - that->GetCenter() ).Length() 
00396                             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00397                     break;
00398                 case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_PRIMS:
00399                     return    ( GetCenter() - that->GetCenter() ).Length() 
00400                             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00401                     break;
00402                 default:
00403                     std::cout << "Error: BVHNode<T>::TestOverlapWith Fn!" << std::endl;
00404                     assert( false );
00405                     break;
00406             }
00407             break;
00408         default:
00409             std::cout << "Error: BVHNode<T>::TestOverlapWith Fn!" << std::endl;
00410             assert( false );
00411             break;
00412     }
00413     return -777;    // -777 is an Error Code
00414 }
00415 //*/
00416 /*
00417 //-----------------------------------------------------------------------------
00418 // TestOverlapSphereWithSphere #1
00419 template <typename T>
00420 T BVHNode<T>::TestOverlapSphereWithSphere ( BVHNode<T> const * const that ) const
00421 {
00422     return    ( GetCenter() - that->GetCenter() ).Length() 
00423             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00424 }
00425 //-----------------------------------------------------------------------------
00426 // TestOverlapSphereWithSphere #2
00427 template <typename T>
00428 T BVHNode<T>::TestOverlapSphereWithSphere ( 
00429                     BVHNode<T> const * const that, 
00430                     Matrix4x4<T> const & thatTransform ) const
00431 {
00432     return    (    GetCenter() 
00433                 - (thatTransform*that->GetCenter()).GetVector3() ).Length() 
00434             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00435 }
00436 //-----------------------------------------------------------------------------
00437 // TestOverlapSphereWithSphere #3
00438 template <typename T>
00439 T BVHNode<T>::TestOverlapSphereWithSphere ( 
00440                     Matrix4x4<T> const & thisTransform, 
00441                     BVHNode<T> const * const that ) const
00442 {
00443     return    (  (thisTransform*GetCenter()).GetVector3() 
00444                 - that->GetCenter() ).Length() 
00445             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00446 }
00447 //-----------------------------------------------------------------------------
00448 // TestOverlapSphereWithSphere #4
00449 template <typename T>
00450 T BVHNode<T>::TestOverlapSphereWithSphere ( 
00451                     Matrix4x4<T> const & thisTransform, 
00452                     BVHNode<T> const * const that, 
00453                     Matrix4x4<T> const & thatTransform ) const
00454 {
00455     return    (   (thisTransform*GetCenter()).GetVector3() 
00456                 - (thatTransform*that->GetCenter()).GetVector3() ).Length() 
00457             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00458 }
00459 //-----------------------------------------------------------------------------
00460 // TestOverlapSphereWithSphereTillLeafNodes #1
00461 template <typename T>
00462 T BVHNode<T>::TestOverlapSphereWithSphereTillLeafNodes ( BVHNode<T> const * const that ) const
00463 {
00464     return    ( GetCenter() - that->GetCenter() ).Length() 
00465             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00466 }
00467 //-----------------------------------------------------------------------------
00468 // TestOverlapSphereWithSphereTillLeafNodes #2
00469 template <typename T>
00470 T BVHNode<T>::TestOverlapSphereWithSphereTillLeafNodes ( 
00471                     BVHNode<T> const * const that, 
00472                     Matrix4x4<T> const & thatTransform ) const
00473 {
00474     return    (    GetCenter() 
00475                 - (thatTransform*that->GetCenter()).GetVector3() ).Length() 
00476             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00477 }
00478 //-----------------------------------------------------------------------------
00479 // TestOverlapSphereWithSphereTillLeafNodes #3
00480 template <typename T>
00481 T BVHNode<T>::TestOverlapSphereWithSphereTillLeafNodes ( 
00482                     Matrix4x4<T> const & thisTransform, 
00483                     BVHNode<T> const * const that ) const
00484 {
00485     return    (  (thisTransform*GetCenter()).GetVector3() 
00486                 - that->GetCenter() ).Length() 
00487             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00488 }
00489 //-----------------------------------------------------------------------------
00490 // TestOverlapSphereWithSphereTillLeafNodes #4
00491 template <typename T>
00492 T BVHNode<T>::TestOverlapSphereWithSphereTillLeafNodes ( 
00493                     Matrix4x4<T> const & thisTransform, 
00494                     BVHNode<T> const * const that, 
00495                     Matrix4x4<T> const & thatTransform ) const
00496 {
00497     return    (   (thisTransform*GetCenter()).GetVector3() 
00498                 - (thatTransform*that->GetCenter()).GetVector3() ).Length() 
00499             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00500 }
00501 //*/
00502 //-----------------------------------------------------------------------------
00503 #if defined(__gl_h_) || defined(__GL_H__)
00504 //=============================================================================
00505 // DrawByOpenGL
00506 //-----------------------------------------------------------------------------
00507 template <typename T> GLuint BoundingSphere<T>::g_uiDisplayList = 0;
00508 template <typename T> GLenum BoundingSphere<T>::g_eDrawStyle = GLU_LINE;
00509 //-----------------------------------------------------------------------------
00510 template <typename T>
00511 void BoundingSphere<T>::Draw ( GLenum drawStyle, Vector4<T> color )
00512 {
00513     //-----------------------------------------------------
00514     //std::cout << "Draw SPHERE Bounding Volume\n";
00515     if ( drawStyle != g_eDrawStyle ) {
00516         g_eDrawStyle = drawStyle;
00517         if ( g_uiDisplayList ) {
00518             glDeleteLists( g_uiDisplayList, 1 );
00519             g_uiDisplayList = 0;
00520         }
00521     }
00522     if ( !g_uiDisplayList ) {
00523         g_uiDisplayList = glGenLists( 1 );
00524         GLUquadricObj *qObj = gluNewQuadric();
00525         glNewList( g_uiDisplayList, GL_COMPILE );
00526             // GLenum drawStyle
00527             //  GLU_FILL
00528             //  GLU_LINE
00529             //  GLU_SILHOUETTE
00530             //  GLU_POINT
00531             gluQuadricDrawStyle( qObj, drawStyle ); // wireframe
00532             //gluSphere( qObj, 1, 9, 9 );
00533             //gluSphere( qObj, 1, 12, 12 );
00534             gluSphere( qObj, 1, 20, 20 );
00535         glEndList();
00536         gluDeleteQuadric( qObj );
00537     }
00538     //-----------------------------------------------------
00539     glPushMatrix();
00540 
00541         /*
00542         // DEBUG
00543         //---------------------------------------
00544         glPushMatrix();
00545         GLfloat mat[16];
00546 
00547         glLoadIdentity();
00548 
00549         std::cout << "Center and Radius: " << GetCenter() << "; " << GetRadius() << "\n";
00550 
00551         glGetFloatv( GL_MODELVIEW_MATRIX, mat );
00552         Matrix4x4<GLfloat> MAT1( mat );
00553         std::cout << "MAT 1: " << MAT1.Transposed();
00554 
00555         GetTransform().TransformByOpenGLForDrawing();
00556 
00557         glGetFloatv( GL_MODELVIEW_MATRIX, mat );
00558         Matrix4x4<GLfloat> MAT2( mat );
00559         std::cout << "MAT 2: " << MAT2.Transposed();
00560 
00561         std::cout << "TTT: " << GetTransform();
00562         //---------------------------------------
00563         glTranslatef( GetCenter()[0], GetCenter()[1], GetCenter()[2] );
00564 
00565         glGetFloatv( GL_MODELVIEW_MATRIX, mat );
00566         Matrix4x4<GLfloat> MAT3( mat );
00567         std::cout << "MAT 3: " << MAT3.Transposed();
00568 
00569         glScalef( GetRadius(), GetRadius(), GetRadius() );
00570 
00571         glGetFloatv( GL_MODELVIEW_MATRIX, mat );
00572         Matrix4x4<GLfloat> MAT4( mat );
00573         std::cout << "MAT 4: " << MAT4.Transposed();
00574         glPopMatrix();
00575         //*/
00576 
00577         //---------------------------------------
00578         GetTransform().TransformByOpenGLForDrawing();
00579         //---------------------------------------
00580         glColor4fv( color.GetDataFloat() );
00581         glTranslatef( GetCenter()[0], GetCenter()[1], GetCenter()[2] );
00582         glScalef( GetRadius(), GetRadius(), GetRadius() );
00583         //---------------------------------------
00584         glCallList( g_uiDisplayList );
00585 
00586     glPopMatrix();
00587 }
00588 //-----------------------------------------------------------------------------
00589 #endif
00590 //=============================================================================
00591 END_NAMESPACE_TAPs
00592 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00593 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines