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