TAPs 0.7.7.3
TAPsBVHNodeLeafElasticRodNode.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsBVHNodeLeafElasticRodNode.cpp
00003 
00004 BVHNodeLeafElasticRodNode class is for a Boundary Volume Hierarchy Leaf Node 
00005 containing a link to an elastic rod node.
00006 
00007 SUKITTI PUNAK   (08/21/2009)
00008 ******************************************************************************/
00009 #include "TAPsBVHNodeLeafElasticRodNode.hpp"
00010 // Using Inclusion Model (i.e. definitions are included in declarations)
00011 //                       (this name.cpp is included in name.hpp)
00012 // Each friend is defined directly inside its declaration.
00013 
00014 BEGIN_NAMESPACE_TAPs
00015 //=============================================================================
00016 // Constructor(s) and Destructor
00017 //-----------------------------------------------------------------------------
00018 template <typename T>
00019 BVHNodeLeafElasticRodNode<T>::BVHNodeLeafElasticRodNode (
00020     Enum::CD            type, 
00021     int                 id, 
00022     BVHNode<T> *        parent )
00023     : BVHNode<T>( id, type, parent ), 
00024       m_pERnode_1( NULL ), m_pERnode_2( NULL )
00025 {
00026     //m_bIsLeaf = true;
00027     m_iN = 0;
00028 }
00029 //-----------------------------------------------------------------------------
00030 template <typename T>
00031 BVHNodeLeafElasticRodNode<T>::~BVHNodeLeafElasticRodNode ()
00032 {}
00033 //-----------------------------------------------------------------------------
00034 // StrInfo
00035 template <typename T>
00036 std::string BVHNodeLeafElasticRodNode<T>::StrInfo () const
00037 {
00038     std::stringstream output;
00039     output  <<  "TAPs::BVHNodeLeafElasticRodNode<"
00040             <<  typeid(T).name() << "> Class:";
00041     //-------------------------------------------------
00042     output  << "contain the link from elastic rod's node i to node j\n"
00043             << "Node i: " << GetPtrToPrimitive_1() << "\n"
00044             << "Node j: " << GetPtrToPrimitive_2() << "\n"
00045             << "\n";
00046     
00047     return output.str();
00048 }
00049 //-----------------------------------------------------------------------------
00050 //=============================================================================
00051 // Node Operations
00052 //-----------------------------------------------------------------------------
00053 // Update
00054 // update only this node
00055 /*
00056 template <typename T>
00057 void BVHNodeLeafElasticRodNode<T>::Update ()
00058 {
00059     //---------------------------------------------------------------
00060     switch ( m_eType ) {
00061         case Enum::BVH_NODE_LEAF_SPHERE_TWO_ELASTIC_ROD_NODES:
00062             //UpdateSphere();
00063             break;
00064         case Enum::BVH_NODE_LEAF_AABB_TWO_ELASTIC_ROD_NODES:
00065             break;
00066         case Enum::BVH_NODE_LEAF_OBB_TWO_ELASTIC_ROD_NODES:
00067             break;
00068         default:
00069             assert( false );
00070             break;
00071     }
00072 }
00073 //*/
00074 //-----------------------------------------------------------------------------
00075 // UpdateSphere
00076 //template <typename T>
00077 //void BVHNodeLeafElasticRodNode<T>::UpdateSphere ()
00078 //{
00079     //std::cout << "UpdateSphere Node: " << this << "\n";
00080 
00081     /*
00082     //---------------------------------------------------------------
00083     Vector3<T> AABB[2];
00084     //HEVertex<T> * vertex = m_listVertex->Head();
00085     HEHalfEdge<T> * firstHalfEdge = m_primHEFace->IncidentHalfEdge();
00086     HEHalfEdge<T> * halfEdge = firstHalfEdge->Next();
00087     Vector3<T> vertex = firstHalfEdge->Vertex()->GetPosition();
00088     AABB[0] = AABB[1] = vertex;
00089     //---------------------------------------------------------------
00090     // For Each Vertex
00091      while ( halfEdge != firstHalfEdge ) {
00092         vertex = halfEdge->Vertex()->GetPosition();
00093         // Find the lowest an the highest of x, y, and z
00094         // AABB[0] is min and AABB[1] is max
00095         if      ( AABB[0][0] > vertex[0] )  AABB[0][0] = vertex[0];
00096         else if ( AABB[1][0] < vertex[0] )  AABB[1][0] = vertex[0];
00097         if      ( AABB[0][1] > vertex[1] )  AABB[0][1] = vertex[1];
00098         else if ( AABB[1][1] < vertex[1] )  AABB[1][1] = vertex[1];
00099         if      ( AABB[0][2] > vertex[2] )  AABB[0][2] = vertex[2];
00100         else if ( AABB[1][2] < vertex[2] )  AABB[1][2] = vertex[2];
00101         // Next vertex
00102         halfEdge = halfEdge->Next();
00103     }
00104     //---------------------------------------------------------------
00105     // Find the bounding volume center from the AABB
00106     Vector3<T> vCenter( ( AABB[0][0] + AABB[1][0] ) / 2.0,
00107                         ( AABB[0][1] + AABB[1][1] ) / 2.0,
00108                         ( AABB[0][2] + AABB[1][2] ) / 2.0 );
00109     //---------------------------------------------------------------
00110     // Find the Sphere Bounding Volume
00111     T radius = 0, squaredLength;
00112     halfEdge = firstHalfEdge = m_primHEFace->IncidentHalfEdge();
00113     //-----------------------------------------------------
00114     do {
00115         vertex = halfEdge->Vertex()->GetPosition();
00116         //squaredLength = (vertex - vCenter).SquaredLength();
00117         squaredLength = (vertex - vCenter).Length();
00118         if ( squaredLength > radius )   radius = squaredLength;
00119         halfEdge = halfEdge->Next();
00120     } while ( halfEdge != firstHalfEdge );
00121     //radius = sqrt( radius );
00122     //---------------------------------------------------------------
00123     SetCenter( vCenter );
00124     SetRadius( radius );
00125     //*/
00126 //}
00127 //-----------------------------------------------------------------------------
00128 // TestOverlapWith
00129 /*
00130 template <typename T>
00131 T BVHNodeLeafElasticRodNode<T>::TestOverlapWith ( BVHNode<T> const * const that ) const
00132 {
00133     switch ( m_eType ) {
00134         case Enum::BVH_NODE_BINARY_SPHERE:
00135         case Enum::BVH_NODE_QUAD_SPHERE:
00136         case Enum::BVH_NODE_OCTANT_SPHERE:
00137         case Enum::BVH_NODE_GENERIC_SPHERE:
00138         case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_APRIM:
00139         case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_PRIMS:
00140             switch ( that->GetType() ) {
00141                 case Enum::BVH_NODE_BINARY_SPHERE:
00142                 case Enum::BVH_NODE_QUAD_SPHERE:
00143                 case Enum::BVH_NODE_OCTANT_SPHERE:
00144                 case Enum::BVH_NODE_GENERIC_SPHERE:
00145                 case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_APRIM:
00146                     return    ( GetCenter() - that->GetCenter() ).Length() 
00147                             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00148                     break;
00149                 case Enum::BVH_NODE_LEAF_SPHERE_HALFEDGE_PRIMS:
00150                     return    ( GetCenter() - that->GetCenter() ).Length() 
00151                             - ( GetRadius() + that->GetRadius() );  // m_vW[0] is m_tRadius
00152                     break;
00153                 default:
00154                     std::cout << "Error: BVHNode<T>::TestOverlapWith Fn!" << std::endl;
00155                     assert( false );
00156                     break;
00157             }
00158             break;
00159         default:
00160             std::cout << "Error: BVHNode<T>::TestOverlapWith Fn!" << std::endl;
00161             assert( false );
00162             break;
00163     }
00164     return -777;    // -777 is an Error Code
00165 }
00166 //*/
00167 
00168 /*
00169 //-----------------------------------------------------------------------------
00170 // TestOverlapSphereWithSphere #1
00171 template <typename T>
00172 T BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithSphere ( 
00173             BVHNode<T> const * const that ) const
00174 {
00175     std::cout << "BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithSphere( #1 )\n";
00176 
00177     if ( that->IsLeaf() ) {
00178         T distance = BVHNode<T>::TestOverlapSphereWithSphere( that );
00179         if ( distance > Math<T>::ZERO ) return distance;
00180         else {
00181             //-----------------------------------
00182             // Triangle Case
00183             HEFace<T> * face1 = this->GetAPrimitiveHalfEdgeFace();
00184             HEFace<T> * face2 = that->GetAPrimitiveHalfEdgeFace();
00185             if ( face1 && face2 ) {
00186                 // Assume Triangles
00187                 std::vector< Vector3<T> > tri1, tri2;
00188                 tri1 = face1->GetCopyOfVertexPositions( 3 );
00189                 tri2 = face2->GetCopyOfVertexPositions( 3 );
00190                 bool isIntersect = CGMath<T>::FindIntersectionTriangleTriangle( 
00191                         tri1[0], tri1[1], tri1[2], tri2[0], tri2[1], tri2[2] );
00192                 if ( isIntersect )  return -1;
00193                 else                return  1;
00194             }
00195             //-----------------------------------
00196             return distance;
00197         }
00198     }
00199     else {
00200         return BVHNode<T>::TestOverlapSphereWithSphere( that );
00201     }
00202 }
00203 //-----------------------------------------------------------------------------
00204 // TestOverlapSphereWithSphere #2
00205 template <typename T>
00206 T BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithSphere ( 
00207             BVHNode<T> const * const that, 
00208             Matrix4x4<T> const & thatTransform ) const
00209 {
00210     std::cout << "BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithSphere( #2 )\n";
00211 
00212     if ( that->IsLeaf() ) {
00213         T distance = BVHNode<T>::TestOverlapSphereWithSphere( that, thatTransform );
00214         if ( distance > Math<T>::ZERO ) return distance;
00215         else {
00216             //-----------------------------------
00217             // Triangle Case
00218             HEFace<T> * face1 = this->GetAPrimitiveHalfEdgeFace();
00219             HEFace<T> * face2 = that->GetAPrimitiveHalfEdgeFace();
00220             if ( face1 && face2 ) {
00221                 // Assume Triangles
00222                 std::vector< Vector3<T> > tri1, tri2;
00223                 tri1 = face1->GetCopyOfVertexPositions( 3 );
00224                 tri2 = face2->GetCopyOfVertexPositions( 3 );
00225                 //---------------------
00226                 // Transforms
00227                 tri2[0] = (thatTransform * Vector4<T>(tri2[0])).GetVector3();
00228                 tri2[1] = (thatTransform * Vector4<T>(tri2[1])).GetVector3();
00229                 tri2[2] = (thatTransform * Vector4<T>(tri2[2])).GetVector3();
00230                 //--------------------------
00231                 bool isIntersect = CGMath<T>::FindIntersectionTriangleTriangle( 
00232                         tri1[0], tri1[1], tri1[2], tri2[0], tri2[1], tri2[2] );
00233                 if ( isIntersect )  return -1;
00234                 else                return  1;
00235             }
00236             //-----------------------------------
00237             return distance;
00238         }
00239     }
00240     else {
00241         return BVHNode<T>::TestOverlapSphereWithSphere( that, thatTransform );
00242     }
00243 }
00244 //-----------------------------------------------------------------------------
00245 // TestOverlapSphereWithSphere #3
00246 template <typename T>
00247 T BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithSphere ( 
00248             Matrix4x4<T> const & thisTransform, 
00249             BVHNode<T> const * const that ) const
00250 {
00251     std::cout << "BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithSphere( #3 )\n";
00252 
00253     if ( that->IsLeaf() ) {
00254         T distance = BVHNode<T>::TestOverlapSphereWithSphere( thisTransform, that );
00255         if ( distance > Math<T>::ZERO ) return distance;
00256         else {
00257             //-----------------------------------
00258             // Triangle Case
00259             HEFace<T> * face1 = this->GetAPrimitiveHalfEdgeFace();
00260             HEFace<T> * face2 = that->GetAPrimitiveHalfEdgeFace();
00261             if ( face1 && face2 ) {
00262                 // Assume Triangles
00263                 std::vector< Vector3<T> > tri1, tri2;
00264                 tri1 = face1->GetCopyOfVertexPositions( 3 );
00265                 tri2 = face2->GetCopyOfVertexPositions( 3 );
00266                 //---------------------
00267                 // Transforms
00268                 tri1[0] = (thisTransform * Vector4<T>(tri1[0])).GetVector3();
00269                 tri1[1] = (thisTransform * Vector4<T>(tri1[1])).GetVector3();
00270                 tri1[2] = (thisTransform * Vector4<T>(tri1[2])).GetVector3();
00271                 //---------------------
00272                 bool isIntersect = CGMath<T>::FindIntersectionTriangleTriangle( 
00273                         tri1[0], tri1[1], tri1[2], tri2[0], tri2[1], tri2[2] );
00274                 if ( isIntersect )  return -1;
00275                 else                return  1;
00276             }
00277             //-----------------------------------
00278             return distance;
00279         }
00280     }
00281     else {
00282         return BVHNode<T>::TestOverlapSphereWithSphere( thisTransform, that );
00283     }
00284 }
00285 //-----------------------------------------------------------------------------
00286 // TestOverlapSphereWithSphere #4
00287 template <typename T>
00288 T BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithSphere ( 
00289             Matrix4x4<T> const & thisTransform, 
00290             BVHNode<T> const * const that, 
00291             Matrix4x4<T> const & thatTransform ) const
00292 {
00293     std::cout << "BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithSphere( #4 )\n";
00294 
00295     if ( that->IsLeaf() ) {
00296         T distance = BVHNode<T>::TestOverlapSphereWithSphere( thisTransform, that, thatTransform );
00297         if ( distance > Math<T>::ZERO ) return distance;
00298         else {
00299             //-----------------------------------
00300             // Triangle Case
00301             HEFace<T> * face1 = this->GetAPrimitiveHalfEdgeFace();
00302             HEFace<T> * face2 = that->GetAPrimitiveHalfEdgeFace();
00303             if ( face1 && face2 ) {
00304                 // Assume Triangles
00305                 std::vector< Vector3<T> > tri1, tri2;
00306                 tri1 = face1->GetCopyOfVertexPositions( 3 );
00307                 tri2 = face2->GetCopyOfVertexPositions( 3 );
00308                 //---------------------
00309                 // Transforms
00310                 tri1[0] = (thisTransform * Vector4<T>(tri1[0])).GetVector3();
00311                 tri1[1] = (thisTransform * Vector4<T>(tri1[1])).GetVector3();
00312                 tri1[2] = (thisTransform * Vector4<T>(tri1[2])).GetVector3();
00313                 tri2[0] = (thatTransform * Vector4<T>(tri2[0])).GetVector3();
00314                 tri2[1] = (thatTransform * Vector4<T>(tri2[1])).GetVector3();
00315                 tri2[2] = (thatTransform * Vector4<T>(tri2[2])).GetVector3();
00316                 //---------------------
00317                 bool isIntersect = CGMath<T>::FindIntersectionTriangleTriangle( 
00318                         tri1[0], tri1[1], tri1[2], tri2[0], tri2[1], tri2[2] );
00319                 if ( isIntersect )  return -1;
00320                 else                return  1;
00321             }
00322             //-----------------------------------
00323             return distance;
00324         }
00325     }
00326     else {
00327         return BVHNode<T>::TestOverlapSphereWithSphere( thisTransform, that, thatTransform );
00328     }
00329 }
00330 //-----------------------------------------------------------------------------
00331 //*/
00332 
00333 
00334 /*
00335 //-----------------------------------------------------------------------------
00336 // TestOverlapSphereWithBVSphere #1
00337 template <typename T>
00338 T BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithBVSphere ( 
00339     Vector3<T> const & centerOfBVSphere,    //!< I/P: the center of the 2nd sphere
00340     T radiusOfBVSphere                      //!< I/P: the radius of the 2nd sphere
00341 ) const
00342 {
00343     std::cout << "BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithBVSphere( #1 )\n";
00344 
00345     T distance = BVHNode<T>::TestOverlapSphereWithBVSphere( centerOfBVSphere, radiusOfBVSphere );
00346     if ( distance > Math<T>::ZERO ) return distance;
00347     else {
00348         //---------------------------------------
00349         // Triangle Case
00350         HEFace<T> * face = this->GetAPrimitiveHalfEdgeFace();
00351         if ( face ) {
00352             // Assume Triangles
00353             std::vector< Vector3<T> > tri;
00354             tri = face->GetCopyOfVertexPositions( 3 );
00355             //-------------------------
00356             bool isIntersect = CGMath<T>::FindIntersectionSphereTriangle( 
00357                     centerOfBVSphere, radiusOfBVSphere, tri[0], tri[1], tri[2] );
00358             if ( isIntersect )  return -1;
00359             else                return  1;
00360         }
00361         //---------------------------------------
00362         return distance;
00363     }
00364 }
00365 //-----------------------------------------------------------------------------
00366 // TestOverlapSphereWithBVSphere #2
00367 template <typename T>
00368 T BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithBVSphere ( 
00369     Matrix4x4<T> const & transformA,        //!< I/P: the transformation for the 1st sphere
00370     Vector3<T> const & centerOfBVSphere,    //!< I/P: the center of the 2nd sphere
00371     T radiusOfBVSphere                      //!< I/P: the radius of the 2nd sphere
00372 ) const
00373 {
00374     std::cout << "BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithBVSphere( #2 )\n";
00375 
00376     T distance = BVHNode<T>::TestOverlapSphereWithBVSphere( transformA, centerOfBVSphere, radiusOfBVSphere );
00377     if ( distance > Math<T>::ZERO ) return distance;
00378     else {
00379         //---------------------------------------
00380         // Triangle Case
00381         HEFace<T> * face = this->GetAPrimitiveHalfEdgeFace();
00382         if ( face ) {
00383             // Assume Triangles
00384             std::vector< Vector3<T> > tri;
00385             tri = face->GetCopyOfVertexPositions( 3 );
00386             //-------------------------
00387             // Transforms
00388             tri[0] = (transformA * Vector4<T>(tri[0])).GetVector3();
00389             tri[1] = (transformA * Vector4<T>(tri[1])).GetVector3();
00390             tri[2] = (transformA * Vector4<T>(tri[2])).GetVector3();
00391             //-------------------------
00392             bool isIntersect = CGMath<T>::FindIntersectionSphereTriangle( 
00393                     centerOfBVSphere, radiusOfBVSphere, tri[0], tri[1], tri[2] );
00394             if ( isIntersect )  return -1;
00395             else                return  1;
00396         }
00397         //---------------------------------------
00398         return distance;
00399     }
00400 }
00401 //-----------------------------------------------------------------------------
00402 //*/
00403 
00404 
00405 /*
00406 //-----------------------------------------------------------------------------
00407 // TestOverlapSphereWithBVCylinder #1
00408 template <typename T>
00409 bool BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithBVCylinder_AtOrigin ( 
00410     Vector3<T> const & centerOfBVCylinder,  //!< I/P: the center of the cylinder bounding volume
00411     T radiusOfBVCylinder,                   //!< I/P: the radius of the cylinder bounding volume
00412     T heightOfBVCylinder                    //!< I/P: the height of the cylinder bounding volume
00413 ) const
00414 {
00415     std::cout << "BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithBVCylinder( #1 )\n";
00416 
00417     T distance = BVHNode<T>::TestOverlapSphereWithBVCylinder_AtOrigin( radiusOfBVCylinder, heightOfBVCylinder );
00418     if ( distance > Math<T>::ZERO ) return false;
00419     else {
00420         //---------------------------------------
00421         // Triangle Case
00422         HEFace<T> * face = this->GetAPrimitiveHalfEdgeFace();
00423         if ( face ) {
00424             // Assume Triangles
00425             std::vector< Vector3<T> > tri;
00426             tri = face->GetCopyOfVertexPositions( 3 );
00427             //-------------------------
00428             T halfHeight = heightOfBVCylinder / 2;
00429             bool isIntersect = CGMath<T>::FindIntersectionCylinderTriangle( 
00430                     Vector3<T>(0,0,halfHeight), Vector3<T>(0,0,-halfHeight), radiusOfBVCylinder, tri[0], tri[1], tri[2] );
00431             if ( isIntersect )  return true;
00432             else                return false;
00433         }
00434         //---------------------------------------
00435         return true;
00436     }
00437 }
00438 //-----------------------------------------------------------------------------
00439 // TestOverlapSphereWithBVCylinder #2
00440 template <typename T>
00441 bool BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithBVCylinder_AtOrigin ( 
00442     Matrix4x4<T> const & transformA,        //!< I/P: the transformation for the node's sphere
00443     Vector3<T> const & centerOfBVCylinder,  //!< I/P: the center of the cylinder bounding volume
00444     T radiusOfBVCylinder,                   //!< I/P: the radius of the cylinder bounding volume
00445     T heightOfBVCylinder                    //!< I/P: the height of the cylinder bounding volume
00446 ) const
00447 {
00448     std::cout << "BVHNodeLeafElasticRodNode<T>::TestOverlapSphereWithBVCylinder( #2 )\n";
00449 
00450     T distance = BVHNode<T>::TestOverlapSphereWithBVCylinder_AtOrigin( transformA, radiusOfBVCylinder, heightOfBVCylinder );
00451     if ( distance > Math<T>::ZERO ) return false;
00452     else {
00453         //---------------------------------------
00454         // Triangle Case
00455         HEFace<T> * face = this->GetAPrimitiveHalfEdgeFace();
00456         if ( face ) {
00457             // Assume Triangles
00458             std::vector< Vector3<T> > tri;
00459             tri = face->GetCopyOfVertexPositions( 3 );
00460             //-------------------------
00461             // Transforms
00462             tri[0] = (transformA * Vector4<T>(tri[0])).GetVector3();
00463             tri[1] = (transformA * Vector4<T>(tri[1])).GetVector3();
00464             tri[2] = (transformA * Vector4<T>(tri[2])).GetVector3();
00465             //-------------------------
00466             T halfHeight = heightOfBVCylinder / 2;
00467             bool isIntersect = CGMath<T>::FindIntersectionCylinderTriangle( 
00468                     Vector3<T>(0,0,halfHeight), Vector3<T>(0,0,-halfHeight), radiusOfBVCylinder, tri[0], tri[1], tri[2] );
00469             if ( isIntersect )  return true;
00470             else                return false;
00471         }
00472         //---------------------------------------
00473         return true;
00474     }
00475 }
00476 //-----------------------------------------------------------------------------
00477 //*/
00478 
00479 
00480 #if defined(__gl_h_) || defined(__GL_H__)
00481 //=============================================================================
00482 // DrawByOpenGL
00483 //-----------------------------------------------------------------------------
00484 template <typename T>
00485 void BVHNodeLeafElasticRodNode<T>::DrawByOpenGL () const
00486 {
00487     //static OpenGL::Material mat;
00488     //mat.SetMaterial( OpenGL::Enum::METAL_BRONZE );
00489     //mat.ApplyMaterial( OpenGL::Enum::FRONT );
00490 
00491     //glDisable( GL_LIGHTING );
00492     //glColor3f( 0.3, 0.4, 0.5 );
00493     //---------------------------------------------------------------
00494     //if ( bDraw ) {    // DEBUG
00495     //  DrawBV();
00496     //  DrawPrim();         // DEBUG
00497     //  return;
00498     //}
00499     DrawBV();
00500     DrawPrim();         // DEBUG
00501     //---------------------------------------------------------------
00502     //glEnable( GL_LIGHTING );
00503 }
00504 //-----------------------------------------------------------------------------
00505 template <typename T>
00506 void BVHNodeLeafElasticRodNode<T>::DrawByOpenGL ( 
00507         int currentLevel, int startLevel, int endLevel ) const
00508 {
00509     if ( startLevel <= currentLevel && currentLevel <= endLevel ) {
00510         //static OpenGL::Material mat;
00511         //mat.SetMaterial( OpenGL::Enum::METAL_BRONZE );
00512         //mat.ApplyMaterial( OpenGL::Enum::FRONT );
00513 
00514         //glDisable( GL_LIGHTING );
00515         //glColor3f( 0.3, 0.4, 0.5 );
00516         //-----------------------------------------------------------
00517         //if ( listHEFace.size() == 1 )
00518         DrawBV();
00519         DrawPrim();     // DEBUG
00520     }
00521     //---------------------------------------------------------------
00522     //glEnable( GL_LIGHTING );
00523 }
00524 //-----------------------------------------------------------------------------
00525 template <typename T>
00526 void BVHNodeLeafElasticRodNode<T>::DrawBV ( GLenum drawStyle ) const
00527 {
00528     switch ( m_eType ) {
00529         //-----------------------------------------------------------
00530         // DRAW SPHERE BVH
00531         case Enum::BVH_NODE_LEAF_SPHERE_TWO_ELASTIC_ROD_NODES:
00532         case Enum::BVH_NODE_LEAF_SPHERE_UNSPECIFIED_PRIMS:
00533             DrawSphereBV( drawStyle );
00534             break;
00535         //-----------------------------------------------------------
00536         // DRAW AABB BVH
00537         case Enum::BVH_NODE_LEAF_AABB_TWO_ELASTIC_ROD_NODES:
00538         case Enum::BVH_NODE_LEAF_AABB_UNSPECIFIED_PRIMS:
00539             DrawAABBBV( drawStyle );
00540             break;
00541         //-----------------------------------------------------------
00542         // DRAW OBB BVH
00543         case Enum::BVH_NODE_LEAF_OBB_TWO_ELASTIC_ROD_NODES:
00544         case Enum::BVH_NODE_LEAF_OBB_UNSPECIFIED_PRIMS:
00545             DrawOBBBV( drawStyle );
00546             break;
00547     }
00548 }
00549 //-----------------------------------------------------------------------------
00550 //DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG
00551 template <typename T>
00552 void BVHNodeLeafElasticRodNode<T>::DrawPrim ( GLenum drawStyle ) const
00553 {
00554     if ( m_pERnode_1 == NULL ) return;
00555 
00556     /*
00557     glDisable( GL_LIGHTING );
00558     //float div = RAND_MAX;
00559     //glColor3f( rand()/div, rand()/div, rand()/div );
00560     //glColor3f( 0.8, 0.8, 0.8 );
00561     glPushMatrix();
00562         HEHalfEdge<T> * firstHalfEdge, * halfEdge;
00563         Vector3<T> vertex;
00564         //-------------------------------------------
00565         // Draw The Half-Edge Face
00566         glBegin( GL_POLYGON );
00567         //glBegin( GL_LINE_LOOP );
00568             halfEdge = firstHalfEdge = m_primHEFace->IncidentHalfEdge();
00569             do {
00570                 vertex = halfEdge->Vertex()->GetPosition();
00571                 glVertex3f( vertex[0], vertex[1], vertex[2] );
00572                 halfEdge = halfEdge->Next();
00573             } while ( halfEdge != firstHalfEdge );
00574         glEnd();
00575         //-------------------------------------------
00576     glPopMatrix();
00577     glEnable( GL_LIGHTING );
00578     //*/
00579 }
00580 //DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG-DEBUG
00581 //-----------------------------------------------------------------------------
00582 #endif // #if defined(__gl_h_) || defined(__GL_H__)
00583 //=============================================================================
00584 END_NAMESPACE_TAPs
00585 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00586 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines