![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsOpenGLHETriMeshOneModelMultiParts.cpp 00003 00004 Class OpenGLHETriMeshOneModelMultiParts is for creating an OpenGL Polygonal Model using 00005 half-edge data structure. 00006 00007 SUKITTI PUNAK (02/27/2006) 00008 UPDATE (04/10/2006) 00009 ******************************************************************************/ 00010 #include "TAPsOpenGLHETriMeshOneModelMultiParts.hpp" 00011 // Using Inclusion Model (i.e. definitions are included in declarations) 00012 // (this name.cpp is included in name.hpp) 00013 // Each friend is defined directly inside its declaration. 00014 00015 BEGIN_NAMESPACE_TAPs__OpenGL 00016 //============================================================================= 00017 //----------------------------------------------------------------------------- 00018 // default constructor 00019 template <typename T> 00020 OpenGLHETriMeshOneModelMultiParts<T>::OpenGLHETriMeshOneModelMultiParts() 00021 : HETriMeshOneModelMultiParts<T>(), bIsDisplayVertexNormals( false ) 00022 { 00023 #ifdef TAPs_DEBUG_MODE 00024 std::cout << "OpenGLHETriMeshOneModelMultiParts<" << typeid(T).name() << "> constructor\n"; 00025 #endif//TAPs_DEBUG_MODE 00026 } 00027 //----------------------------------------------------------------------------- 00028 // destructor 00029 template <typename T> 00030 OpenGLHETriMeshOneModelMultiParts<T>::~OpenGLHETriMeshOneModelMultiParts() 00031 { 00032 #ifdef TAPs_DEBUG_MODE 00033 std::cout << "OpenGLHETriMeshOneModelMultiParts<" << typeid(T).name() << "> destructor\n"; 00034 #endif//TAPs_DEBUG_MODE 00035 } 00036 /* 00037 //----------------------------------------------------------------------------- 00038 //void DisplayGL() 00039 template <typename T> 00040 void OpenGLHETriMeshOneModelMultiParts<T>::DisplayGL( OpenGL::Enum::DrawMode DM ) 00041 { 00042 switch (DM) { 00043 case OpenGL::Enum::POLYGON: 00044 DrawGL( GL_POLYGON ); 00045 break; 00046 case OpenGL::Enum::WIRE_FRAME: 00047 DrawGL( GL_LINE_LOOP ); 00048 break; 00049 case OpenGL::Enum::POINT: 00050 DrawGL( GL_POINTS ); 00051 break; 00052 case OpenGL::Enum:: POLYGON_WITH_WIRE_FRAME: 00053 // Draw the object with GL_POLYGON_OFFSET enabled 00054 glEnable( GL_POLYGON_OFFSET_FILL ); 00055 glPolygonOffset( 1.0, 1.0 ); 00056 DrawGL( GL_POLYGON ); 00057 glDisable( GL_POLYGON_OFFSET_FILL ); 00058 // Draw the wire frame of the object 00059 glDisable( GL_LIGHTING ); 00060 //glDisable( GL_DEPTH_TEST ); 00061 glColor3ub( 255, 200, 0 ); 00062 DrawGL( GL_LINE_LOOP ); 00063 glEnable( GL_LIGHTING ); 00064 //glEnable( GL_DEPTH_TEST ); 00065 break; 00066 } 00067 } 00068 //*/ 00069 //----------------------------------------------------------------------------- 00070 // Helper Fn 00071 // void DrawGL() 00072 template <typename T> 00073 void OpenGLHETriMeshOneModelMultiParts<T>::DrawGL ( GLenum drawMode ) 00074 { 00075 //std::cout << "File: " << __FILE__ << " (" << __LINE__ << ") " << "OpenGLHETriMeshOneModelMultiParts::DrawGL(...)\n"; 00076 00077 #ifdef TAPs_USE_DATA_POOL 00078 glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); 00079 #endif//TAPs_USE_DATA_POOL 00080 //--------------------------------------------------------------- 00081 if ( drawMode == OpenGL::Enum::POINT ) { 00082 00083 #ifdef TAPs_USE_DATA_POOL 00084 glEnableClientState( GL_VERTEX_ARRAY ); 00085 if ( typeid(T) == typeid(float) ) 00086 { 00087 glVertexPointer( 3, GL_FLOAT, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 00088 } 00089 else //if ( typeid(T) == typeid(double) ) 00090 { 00091 glVertexPointer( 3, GL_DOUBLE, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 00092 } 00093 glPointSize( 2 ); 00094 glDrawArrays( GL_POINTS, 0, GetArrayOfVertexPositions().GetSize() ); 00095 00096 #else //TAPs_USE_DATA_POOL 00097 HEVertex<T> *ptr = m_listVertex->Head(); 00098 glBegin( drawMode ); 00099 while ( ptr != NULL ) { 00100 // Draw the vertex 00101 glVertex3f ( 00102 static_cast<float>( (*ptr)[0] ), 00103 static_cast<float>( (*ptr)[1] ), 00104 static_cast<float>( (*ptr)[2] ) ); 00105 ptr = ptr->Next(); 00106 } 00107 glEnd(); 00108 00109 #endif//TAPs_USE_DATA_POOL 00110 00111 } 00112 else if ( isFacetShading ) { 00113 // Draw the object 00114 //glEnable( GL_TEXTURE_2D ); 00115 HEFace<T> *facePtr = m_listFace->Head(); 00116 HEHalfEdge<T> *halfEdgePtr; 00117 //for ( int f = 0; f < GetNoFaces(); ++f ) { 00118 while ( facePtr != NULL ) { 00119 00120 // Submaterial supported by .ASE 00121 #ifdef TAPs_SUPPORT_ASE_FORMAT 00122 int matID = facePtr->GetMaterialID(); 00123 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 00124 this->submaterials[ matID ]->ApplyMaterial(); 00125 } 00126 #endif//TAPs_SUPPORT_ASE_FORMAT 00127 00128 halfEdgePtr = facePtr->IncidentHalfEdge(); 00129 glBegin( drawMode ); 00130 //for ( int i = 0; i < 3; ++i ) { 00131 do { 00133 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00134 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00135 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00136 //} 00137 // Normal of the face 00138 glNormal3f ( 00139 static_cast<float>( facePtr->GetNormal()[0] ), 00140 static_cast<float>( facePtr->GetNormal()[1] ), 00141 static_cast<float>( facePtr->GetNormal()[2] ) 00142 ); 00143 // Draw the vertex 00144 glVertex3f ( 00145 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00146 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00147 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00148 ); 00149 // DEBUG: 00150 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 00151 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 00152 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 00153 //std::cout << "\n"; 00154 halfEdgePtr = halfEdgePtr->Next(); 00155 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00156 //std::cout << "\n"; 00157 //} 00158 glEnd(); 00159 facePtr = facePtr->Next(); 00160 } 00161 00162 // Draw the object 00163 //for ( int i = 0; i < m_iNoFaces; i++ ) 00164 //{ 00165 // glBegin( drawMode ); 00166 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 00167 // { 00168 // // Draw texture 00169 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00170 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00171 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00172 // } 00173 // // Normal of the face 00174 // //glNormal3f ( static_cast<float>( m_prFace[i].GetNormal()[0] ), 00175 // // static_cast<float>( m_prFace[i].GetNormal()[1] ), 00176 // // static_cast<float>( m_prFace[i].GetNormal()[2] ) ); 00177 // // Draw the vertex 00178 // glVertex3f ( 00179 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 00180 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 00181 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 00182 // } 00183 // glEnd(); 00184 //} 00186 } 00187 else { 00188 // Draw the object 00189 00190 #ifdef TAPs_USE_DATA_POOL 00191 glEnableClientState( GL_VERTEX_ARRAY ); 00192 glEnableClientState( GL_NORMAL_ARRAY ); 00193 if ( typeid(T) == typeid(float) ) 00194 { 00195 glVertexPointer( 3, GL_FLOAT, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 00196 glNormalPointer( GL_FLOAT, 0, GetArrayOfVertexNormals().GetAddressOfDataNumber(0) ); 00197 } 00198 else //if ( typeid(T) == typeid(double) ) 00199 { 00200 glVertexPointer( 3, GL_DOUBLE, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 00201 glNormalPointer( GL_DOUBLE, 0, GetArrayOfVertexNormals().GetAddressOfDataNumber(0) ); 00202 } 00203 00204 #ifdef TAPs_SUPPORT_ASE_FORMAT 00205 int i = 0; 00206 HEFace<T> *facePtr = m_listFace->Head(); 00207 while ( facePtr != NULL ) { 00208 00209 // Submaterial supported by .ASE 00210 int matID = facePtr->GetMaterialID(); 00211 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 00212 this->submaterials[ matID ]->ApplyMaterial(); 00213 } 00214 glDrawElements( 00215 GL_TRIANGLES, 00216 3, 00217 GL_UNSIGNED_INT, 00218 GetArrayOfIndexFaces().GetAddressOfDataNumber(i++) 00219 ); 00220 facePtr = facePtr->Next(); 00221 } 00222 #else //TAPs_SUPPORT_ASE_FORMAT 00223 glDrawElements( 00224 GL_TRIANGLES, 00225 GetArrayOfIndexFaces().GetSize()*GetArrayOfIndexFaces().GetStride(), 00226 GL_UNSIGNED_INT, 00227 GetArrayOfIndexFaces().GetAddressOfDataNumber(0) 00228 ); 00229 #endif//TAPs_SUPPORT_ASE_FORMAT 00230 00231 #else //TAPs_USE_DATA_POOL 00232 //glEnable( GL_TEXTURE_2D ); 00233 HEFace<T> *facePtr = m_listFace->Head(); 00234 HEHalfEdge<T> *halfEdgePtr; 00235 //for ( int f = 0; f < GetNoFaces(); ++f ) { 00236 while ( facePtr != NULL ) { 00237 00238 // Submaterial supported by .ASE 00239 #ifdef TAPs_SUPPORT_ASE_FORMAT 00240 int matID = facePtr->GetMaterialID(); 00241 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 00242 this->submaterials[ matID ]->ApplyMaterial(); 00243 } 00244 #endif//TAPs_SUPPORT_ASE_FORMAT 00245 00246 halfEdgePtr = facePtr->IncidentHalfEdge(); 00247 glBegin( drawMode ); 00248 //for ( int i = 0; i < 3; ++i ) { 00249 do { 00251 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00252 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00253 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00254 //} 00256 glNormal3f ( 00257 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[0] ), 00258 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[1] ), 00259 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[2] ) 00260 ); 00261 // Draw the vertex 00262 glVertex3f ( 00263 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00264 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00265 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00266 ); 00267 // DEBUG: 00268 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 00269 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 00270 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 00271 //std::cout << "\n"; 00272 halfEdgePtr = halfEdgePtr->Next(); 00273 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00274 //std::cout << "\n"; 00275 //} 00276 glEnd(); 00277 facePtr = facePtr->Next(); 00278 } 00279 00280 #endif//TAPs_USE_DATA_POOL 00281 00284 //for ( int i = 0; i < m_iNoFaces; i++ ) 00285 //{ 00286 // glBegin( drawMode ); 00287 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 00288 // { 00289 // // Draw texture 00290 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00291 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00292 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00293 // } 00294 // // Normal of the vertex 00295 // glNormal3f ( static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 00296 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 00297 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 00298 // // Draw the vertex 00299 // glVertex3f ( 00300 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 00301 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 00302 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 00303 // } 00304 // glEnd(); 00305 //} 00307 } 00308 00309 // Draw Boundary 00310 //if ( drawMode == OpenGL::Enum::POLYGON_WITH_WIRE_FRAME ) { 00311 //if ( true ) { 00312 // glColor3f( 1.0f, 0.0f, 0.0f ); 00313 // glDisable( GL_LIGHTING ); 00314 // glBegin( GL_LINES ); 00315 // HEFace<T> *facePtr = m_listFace->Head(); 00316 // HEHalfEdge<T> *halfEdgePtr; 00317 // while ( facePtr != NULL ) { 00318 // halfEdgePtr = facePtr->IncidentHalfEdge(); 00319 // do { 00320 // if ( !halfEdgePtr->Pair() ) { 00321 // // Draw the vertex 00322 // glVertex3f ( 00323 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00324 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00325 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00326 // ); 00327 // glVertex3f ( 00328 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 00329 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 00330 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 00331 // ); 00332 // } 00333 // halfEdgePtr = halfEdgePtr->Next(); 00334 // } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00335 // facePtr = facePtr->Next(); 00336 // } 00337 // glEnd(); 00338 // glEnable( GL_LIGHTING ); 00339 //} 00340 00341 // Draw Boundary 00342 if ( true ) { 00343 glColor3f( 1.0f, 0.0f, 0.0f ); 00344 glPushAttrib( GL_LIGHTING_BIT ); 00345 glDisable( GL_LIGHTING ); 00346 glBegin( GL_LINES ); 00347 if ( m_listHoleFace != NULL ) { 00348 HEFace<T> *facePtr = m_listHoleFace->Head(); 00349 HEHalfEdge<T> *halfEdgePtr; 00350 while ( facePtr != NULL ) { 00351 halfEdgePtr = facePtr->IncidentHalfEdge(); 00352 do { 00353 //if ( halfEdgePtr && halfEdgePtr->Next() ) { 00354 // Draw the vertex 00355 glVertex3f ( 00356 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00357 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00358 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00359 ); 00360 glVertex3f ( 00361 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 00362 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 00363 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 00364 ); 00365 //} 00366 halfEdgePtr = halfEdgePtr->Next(); 00367 } while ( halfEdgePtr && halfEdgePtr != facePtr->IncidentHalfEdge() ); 00368 facePtr = facePtr->Next(); 00369 } 00370 } 00371 glEnd(); 00372 //glEnable( GL_LIGHTING ); 00373 glPopAttrib(); 00374 } 00375 00376 if ( bIsDisplayVertexNormals ) { 00377 glColor3ub( 75, 200, 100 ); 00378 glPushAttrib( GL_LIGHTING_BIT ); 00379 glDisable( GL_LIGHTING ); 00380 //HEVertex<T> * pVertex = GetVertexList(); 00381 HEVertex<T> * pVertex = m_listVertex->Head(); 00382 while ( pVertex ) { 00383 Fn::Draw3DLine( pVertex->GetPosition(), pVertex->GetPosition() + pVertex->GetNormal() ); 00384 pVertex = pVertex->Next(); 00385 } 00386 //glEnable( GL_LIGHTING ); 00387 glPopAttrib(); 00388 } 00389 00390 #ifdef TAPs_DEBUG_CD_WITH_HETRI 00391 for ( int i = 0; i < static_cast<int>( m_Parts.size() ); ++i ) { 00392 DrawGLParticleRef( i ); 00393 if ( m_Parts[i].GetModelType() == TAPs::Enum::MODEL_DEFORM ) { 00394 DrawGLSprings( i ); 00395 } 00396 } 00397 #endif//TAPs_DEBUG_CD_WITH_HETRI 00398 00399 00400 DrawVertexSimulationStatus(); 00401 00402 00403 //DrawGLParticleRef(); 00404 //DrawGLVertexRing1(); 00405 //DrawGLSpringConnections(); 00406 //DrawGLSprings(); 00407 00408 //DrawGLHalfEdges(); 00409 00410 // Draw AABB Bounding Box 00411 //DrawBoundingAABB(); 00412 //DrawBoundingEllipsoid(); 00413 //DrawBoundingSphere(); 00414 //--------------------------------------------------------------- 00415 #ifdef TAPs_USE_DATA_POOL 00416 glPopClientAttrib(); 00417 #endif//TAPs_USE_DATA_POOL 00418 } 00419 //----------------------------------------------------------------------------- 00420 00421 00422 00423 00424 00425 00426 00427 00428 00429 00430 00431 00432 00433 00434 00435 00436 //============================================================================= 00437 #ifdef TAPs_ENABLE_FACE_VERTEX_COLOR 00438 //----------------------------------------------------------------------------- 00439 template <typename T> 00440 void OpenGLHETriMeshOneModelMultiParts<T>::DrawGLWithFaceVertexColor_RGB ( GLenum drawMode ) 00441 { 00442 //std::cout << "File: " << __FILE__ << " (" << __LINE__ << ") " << "OpenGLHETriMeshOneModelMultiParts::DrawGLWithFaceVertexColor_RGB(...)\n"; 00443 00444 #ifdef TAPs_USE_DATA_POOL 00445 glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); 00446 #endif//TAPs_USE_DATA_POOL 00447 00448 glPushAttrib( GL_ENABLE_BIT | GL_ENABLE_BIT ); 00449 glEnable( GL_COLOR_MATERIAL ); 00450 00451 //--------------------------------------------------------------- 00452 if ( drawMode == OpenGL::Enum::POINT ) { 00453 00454 #ifdef TAPs_USE_DATA_POOL 00455 glEnableClientState( GL_VERTEX_ARRAY ); 00456 if ( typeid(T) == typeid(float) ) 00457 { 00458 glVertexPointer( 3, GL_FLOAT, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 00459 } 00460 else //if ( typeid(T) == typeid(double) ) 00461 { 00462 glVertexPointer( 3, GL_DOUBLE, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 00463 } 00464 glPointSize( 2 ); 00465 glDrawArrays( GL_POINTS, 0, GetArrayOfVertexPositions().GetSize() ); 00466 00467 #else //TAPs_USE_DATA_POOL 00468 HEVertex<T> *ptr = m_listVertex->Head(); 00469 glBegin( drawMode ); 00470 while ( ptr != NULL ) { 00471 // Draw the vertex 00472 glVertex3f ( 00473 static_cast<float>( (*ptr)[0] ), 00474 static_cast<float>( (*ptr)[1] ), 00475 static_cast<float>( (*ptr)[2] ) ); 00476 ptr = ptr->Next(); 00477 } 00478 glEnd(); 00479 00480 #endif//TAPs_USE_DATA_POOL 00481 } 00482 else if ( isFacetShading ) { 00483 // Draw the object 00484 //glEnable( GL_TEXTURE_2D ); 00485 HEFace<T> *facePtr = m_listFace->Head(); 00486 HEHalfEdge<T> *halfEdgePtr; 00487 //for ( int f = 0; f < GetNoFaces(); ++f ) { 00488 while ( facePtr != NULL ) { 00489 00490 /* 00491 // Submaterial supported by .ASE 00492 #ifdef TAPs_SUPPORT_ASE_FORMAT 00493 int matID = facePtr->GetMaterialID(); 00494 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 00495 this->submaterials[ matID ]->ApplyMaterial(); 00496 } 00497 #endif//TAPs_SUPPORT_ASE_FORMAT 00498 //*/ 00499 00500 halfEdgePtr = facePtr->IncidentHalfEdge(); 00501 int j = 0; 00502 glBegin( drawMode ); 00503 //for ( int i = 0; i < 3; ++i ) { 00504 do { 00506 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00507 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00508 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00509 //} 00510 // Normal of the face 00511 glNormal3f ( 00512 static_cast<float>( facePtr->GetNormal()[0] ), 00513 static_cast<float>( facePtr->GetNormal()[1] ), 00514 static_cast<float>( facePtr->GetNormal()[2] ) 00515 ); 00516 00517 // Vertex color of the face 00518 float VC[3]; 00519 GetVertexColor( facePtr->GetVertexColorNo( j++ ), &VC[0], &VC[1], &VC[2] ); 00520 glColor3f ( VC[0], VC[1], VC[2] ); 00521 00522 // Draw the vertex 00523 glVertex3f ( 00524 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00525 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00526 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00527 ); 00528 // DEBUG: 00529 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 00530 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 00531 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 00532 //std::cout << "\n"; 00533 halfEdgePtr = halfEdgePtr->Next(); 00534 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00535 //std::cout << "\n"; 00536 //} 00537 glEnd(); 00538 facePtr = facePtr->Next(); 00539 } 00540 00541 // Draw the object 00542 //for ( int i = 0; i < m_iNoFaces; i++ ) 00543 //{ 00544 // glBegin( drawMode ); 00545 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 00546 // { 00547 // // Draw texture 00548 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00549 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00550 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00551 // } 00552 // // Normal of the face 00553 // //glNormal3f ( static_cast<float>( m_prFace[i].GetNormal()[0] ), 00554 // // static_cast<float>( m_prFace[i].GetNormal()[1] ), 00555 // // static_cast<float>( m_prFace[i].GetNormal()[2] ) ); 00556 // // Draw the vertex 00557 // glVertex3f ( 00558 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 00559 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 00560 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 00561 // } 00562 // glEnd(); 00563 //} 00565 } 00566 else { 00567 // Draw the object 00568 00569 #ifdef TAPs_USE_DATA_POOL__ 00570 #else //TAPs_USE_DATA_POOL__ 00571 00572 //glEnable( GL_TEXTURE_2D ); 00573 HEFace<T> *facePtr = m_listFace->Head(); 00574 HEHalfEdge<T> *halfEdgePtr; 00575 while ( facePtr != NULL ) { 00576 00577 /* 00578 // Submaterial supported by .ASE 00579 #ifdef TAPs_SUPPORT_ASE_FORMAT 00580 int matID = facePtr->GetMaterialID(); 00581 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 00582 this->submaterials[ matID ]->ApplyMaterial(); 00583 } 00584 #endif//TAPs_SUPPORT_ASE_FORMAT 00585 //*/ 00586 00587 halfEdgePtr = facePtr->IncidentHalfEdge(); 00588 int j = 0; 00589 glBegin( drawMode ); 00590 //for ( int i = 0; i < 3; ++i ) { 00591 do { 00593 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00594 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00595 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00596 //} 00598 glNormal3f ( 00599 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[0] ), 00600 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[1] ), 00601 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[2] ) 00602 ); 00603 00604 // Vertex color of the face 00605 float VC[3]; 00606 GetVertexColor( facePtr->GetVertexColorNo( j++ ), &VC[0], &VC[1], &VC[2] ); 00607 glColor3f ( VC[0], VC[1], VC[2] ); 00608 00609 // Draw the vertex 00610 glVertex3f ( 00611 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00612 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00613 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00614 ); 00615 // DEBUG: 00616 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 00617 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 00618 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 00619 //std::cout << "\n"; 00620 halfEdgePtr = halfEdgePtr->Next(); 00621 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00622 //std::cout << "\n"; 00623 //} 00624 glEnd(); 00625 facePtr = facePtr->Next(); 00626 } 00627 00628 #endif//TAPs_USE_DATA_POOL__ 00629 00632 //for ( int i = 0; i < m_iNoFaces; i++ ) 00633 //{ 00634 // glBegin( drawMode ); 00635 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 00636 // { 00637 // // Draw texture 00638 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00639 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00640 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00641 // } 00642 // // Normal of the vertex 00643 // glNormal3f ( static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 00644 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 00645 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 00646 // // Draw the vertex 00647 // glVertex3f ( 00648 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 00649 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 00650 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 00651 // } 00652 // glEnd(); 00653 //} 00655 } 00656 00657 glPopAttrib(); 00658 00659 // Draw Boundary 00660 //if ( drawMode == OpenGL::Enum::POLYGON_WITH_WIRE_FRAME ) { 00661 //if ( true ) { 00662 // glColor3f( 1.0f, 0.0f, 0.0f ); 00663 // glDisable( GL_LIGHTING ); 00664 // glBegin( GL_LINES ); 00665 // HEFace<T> *facePtr = m_listFace->Head(); 00666 // HEHalfEdge<T> *halfEdgePtr; 00667 // while ( facePtr != NULL ) { 00668 // halfEdgePtr = facePtr->IncidentHalfEdge(); 00669 // do { 00670 // if ( !halfEdgePtr->Pair() ) { 00671 // // Draw the vertex 00672 // glVertex3f ( 00673 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00674 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00675 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00676 // ); 00677 // glVertex3f ( 00678 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 00679 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 00680 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 00681 // ); 00682 // } 00683 // halfEdgePtr = halfEdgePtr->Next(); 00684 // } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00685 // facePtr = facePtr->Next(); 00686 // } 00687 // glEnd(); 00688 // glEnable( GL_LIGHTING ); 00689 //} 00690 00691 // Draw Boundary 00692 if ( true ) { 00693 glColor3f( 1.0f, 0.0f, 0.0f ); 00694 glPushAttrib( GL_LIGHTING_BIT ); 00695 glDisable( GL_LIGHTING ); 00696 glBegin( GL_LINES ); 00697 if ( m_listHoleFace != NULL ) { 00698 HEFace<T> *facePtr = m_listHoleFace->Head(); 00699 HEHalfEdge<T> *halfEdgePtr; 00700 while ( facePtr != NULL ) { 00701 halfEdgePtr = facePtr->IncidentHalfEdge(); 00702 do { 00703 //if ( halfEdgePtr && halfEdgePtr->Next() ) { 00704 // Draw the vertex 00705 glVertex3f ( 00706 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00707 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00708 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00709 ); 00710 glVertex3f ( 00711 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 00712 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 00713 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 00714 ); 00715 //} 00716 halfEdgePtr = halfEdgePtr->Next(); 00717 } while ( halfEdgePtr && halfEdgePtr != facePtr->IncidentHalfEdge() ); 00718 facePtr = facePtr->Next(); 00719 } 00720 } 00721 glEnd(); 00722 //glEnable( GL_LIGHTING ); 00723 glPopAttrib(); 00724 } 00725 00726 if ( bIsDisplayVertexNormals ) { 00727 glColor3ub( 75, 200, 100 ); 00728 glPushAttrib( GL_LIGHTING_BIT ); 00729 glDisable( GL_LIGHTING ); 00730 //HEVertex<T> * pVertex = GetVertexList(); 00731 HEVertex<T> * pVertex = m_listVertex->Head(); 00732 while ( pVertex ) { 00733 Fn::Draw3DLine( pVertex->GetPosition(), pVertex->GetPosition() + pVertex->GetNormal() ); 00734 pVertex = pVertex->Next(); 00735 } 00736 //glEnable( GL_LIGHTING ); 00737 glPopAttrib(); 00738 } 00739 00740 #ifdef TAPs_DEBUG_CD_WITH_HETRI 00741 for ( int i = 0; i < static_cast<int>( m_Parts.size() ); ++i ) { 00742 DrawGLParticleRef( i ); 00743 if ( m_Parts[i].GetModelType() == TAPs::Enum::MODEL_DEFORM ) { 00744 DrawGLSprings( i ); 00745 } 00746 } 00747 #endif//TAPs_DEBUG_CD_WITH_HETRI 00748 00749 00750 DrawVertexSimulationStatus(); 00751 00752 00753 //DrawGLParticleRef(); 00754 //DrawGLVertexRing1(); 00755 //DrawGLSpringConnections(); 00756 //DrawGLSprings(); 00757 00758 //DrawGLHalfEdges(); 00759 00760 // Draw AABB Bounding Box 00761 //DrawBoundingAABB(); 00762 //DrawBoundingEllipsoid(); 00763 //DrawBoundingSphere(); 00764 //--------------------------------------------------------------- 00765 #ifdef TAPs_USE_DATA_POOL 00766 glPopClientAttrib(); 00767 #endif//TAPs_USE_DATA_POOL 00768 } 00769 //----------------------------------------------------------------------------- 00770 template <typename T> 00771 void OpenGLHETriMeshOneModelMultiParts<T>::DrawGLWithFaceVertexColor_RGBA ( GLenum drawMode ) 00772 { 00773 //std::cout << "File: " << __FILE__ << " (" << __LINE__ << ") " << "OpenGLHETriMeshOneModelMultiParts::DrawGLWithFaceVertexColor_RGBA(...)\n"; 00774 00775 #ifdef TAPs_USE_DATA_POOL 00776 glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); 00777 #endif//TAPs_USE_DATA_POOL 00778 00779 glPushAttrib( GL_ENABLE_BIT | GL_ENABLE_BIT ); 00780 glEnable( GL_COLOR_MATERIAL ); 00781 00782 //--------------------------------------------------------------- 00783 if ( drawMode == OpenGL::Enum::POINT ) { 00784 00785 #ifdef TAPs_USE_DATA_POOL 00786 glEnableClientState( GL_VERTEX_ARRAY ); 00787 if ( typeid(T) == typeid(float) ) 00788 { 00789 glVertexPointer( 3, GL_FLOAT, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 00790 } 00791 else //if ( typeid(T) == typeid(double) ) 00792 { 00793 glVertexPointer( 3, GL_DOUBLE, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 00794 } 00795 glPointSize( 2 ); 00796 glDrawArrays( GL_POINTS, 0, GetArrayOfVertexPositions().GetSize() ); 00797 00798 #else //TAPs_USE_DATA_POOL 00799 HEVertex<T> *ptr = m_listVertex->Head(); 00800 glBegin( drawMode ); 00801 while ( ptr != NULL ) { 00802 // Draw the vertex 00803 glVertex3f ( 00804 static_cast<float>( (*ptr)[0] ), 00805 static_cast<float>( (*ptr)[1] ), 00806 static_cast<float>( (*ptr)[2] ) ); 00807 ptr = ptr->Next(); 00808 } 00809 glEnd(); 00810 00811 #endif//TAPs_USE_DATA_POOL 00812 } 00813 else if ( isFacetShading ) { 00814 // Draw the object 00815 //glEnable( GL_TEXTURE_2D ); 00816 HEFace<T> *facePtr = m_listFace->Head(); 00817 HEHalfEdge<T> *halfEdgePtr; 00818 //for ( int f = 0; f < GetNoFaces(); ++f ) { 00819 while ( facePtr != NULL ) { 00820 00821 /* 00822 // Submaterial supported by .ASE 00823 #ifdef TAPs_SUPPORT_ASE_FORMAT 00824 int matID = facePtr->GetMaterialID(); 00825 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 00826 this->submaterials[ matID ]->ApplyMaterial(); 00827 } 00828 #endif//TAPs_SUPPORT_ASE_FORMAT 00829 //*/ 00830 00831 halfEdgePtr = facePtr->IncidentHalfEdge(); 00832 int j = 0; 00833 glBegin( drawMode ); 00834 //for ( int i = 0; i < 3; ++i ) { 00835 do { 00837 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00838 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00839 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00840 //} 00841 // Normal of the face 00842 glNormal3f ( 00843 static_cast<float>( facePtr->GetNormal()[0] ), 00844 static_cast<float>( facePtr->GetNormal()[1] ), 00845 static_cast<float>( facePtr->GetNormal()[2] ) 00846 ); 00847 00848 // Vertex color of the face 00849 float VC[4]; 00850 GetVertexColor( facePtr->GetVertexColorNo( j++ ), &VC[0], &VC[1], &VC[2], &VC[3] ); 00851 glColor4f ( VC[0], VC[1], VC[2], VC[3] ); 00852 00853 // Draw the vertex 00854 glVertex3f ( 00855 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00856 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00857 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00858 ); 00859 // DEBUG: 00860 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 00861 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 00862 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 00863 //std::cout << "\n"; 00864 halfEdgePtr = halfEdgePtr->Next(); 00865 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00866 //std::cout << "\n"; 00867 //} 00868 glEnd(); 00869 facePtr = facePtr->Next(); 00870 } 00871 00872 // Draw the object 00873 //for ( int i = 0; i < m_iNoFaces; i++ ) 00874 //{ 00875 // glBegin( drawMode ); 00876 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 00877 // { 00878 // // Draw texture 00879 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00880 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00881 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00882 // } 00883 // // Normal of the face 00884 // //glNormal3f ( static_cast<float>( m_prFace[i].GetNormal()[0] ), 00885 // // static_cast<float>( m_prFace[i].GetNormal()[1] ), 00886 // // static_cast<float>( m_prFace[i].GetNormal()[2] ) ); 00887 // // Draw the vertex 00888 // glVertex3f ( 00889 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 00890 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 00891 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 00892 // } 00893 // glEnd(); 00894 //} 00896 } 00897 else { 00898 // Draw the object 00899 00900 #ifdef TAPs_USE_DATA_POOL__ 00901 #else //TAPs_USE_DATA_POOL__ 00902 00903 //glEnable( GL_TEXTURE_2D ); 00904 HEFace<T> *facePtr = m_listFace->Head(); 00905 HEHalfEdge<T> *halfEdgePtr; 00906 //for ( int f = 0; f < GetNoFaces(); ++f ) { 00907 while ( facePtr != NULL ) { 00908 00909 /* 00910 // Submaterial supported by .ASE 00911 #ifdef TAPs_SUPPORT_ASE_FORMAT 00912 int matID = facePtr->GetMaterialID(); 00913 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 00914 this->submaterials[ matID ]->ApplyMaterial(); 00915 } 00916 #endif//TAPs_SUPPORT_ASE_FORMAT 00917 //*/ 00918 00919 halfEdgePtr = facePtr->IncidentHalfEdge(); 00920 int j = 0; 00921 glBegin( drawMode ); 00922 //for ( int i = 0; i < 3; ++i ) { 00923 do { 00925 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00926 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00927 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00928 //} 00930 glNormal3f ( 00931 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[0] ), 00932 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[1] ), 00933 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[2] ) 00934 ); 00935 00936 // Vertex color of the face 00937 float VC[4]; 00938 GetVertexColor( facePtr->GetVertexColorNo( j++ ), &VC[0], &VC[1], &VC[2], &VC[3] ); 00939 glColor4f ( VC[0], VC[1], VC[2], VC[3] ); 00940 00941 // Draw the vertex 00942 glVertex3f ( 00943 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 00944 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 00945 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 00946 ); 00947 // DEBUG: 00948 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 00949 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 00950 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 00951 //std::cout << "\n"; 00952 halfEdgePtr = halfEdgePtr->Next(); 00953 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 00954 //std::cout << "\n"; 00955 //} 00956 glEnd(); 00957 facePtr = facePtr->Next(); 00958 } 00959 00960 #endif//TAPs_USE_DATA_POOL__ 00961 00964 //for ( int i = 0; i < m_iNoFaces; i++ ) 00965 //{ 00966 // glBegin( drawMode ); 00967 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 00968 // { 00969 // // Draw texture 00970 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 00971 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 00972 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 00973 // } 00974 // // Normal of the vertex 00975 // glNormal3f ( static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 00976 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 00977 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 00978 // // Draw the vertex 00979 // glVertex3f ( 00980 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 00981 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 00982 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 00983 // } 00984 // glEnd(); 00985 //} 00987 } 00988 00989 glPopAttrib(); 00990 00991 // Draw Boundary 00992 //if ( drawMode == OpenGL::Enum::POLYGON_WITH_WIRE_FRAME ) { 00993 //if ( true ) { 00994 // glColor3f( 1.0f, 0.0f, 0.0f ); 00995 // glDisable( GL_LIGHTING ); 00996 // glBegin( GL_LINES ); 00997 // HEFace<T> *facePtr = m_listFace->Head(); 00998 // HEHalfEdge<T> *halfEdgePtr; 00999 // while ( facePtr != NULL ) { 01000 // halfEdgePtr = facePtr->IncidentHalfEdge(); 01001 // do { 01002 // if ( !halfEdgePtr->Pair() ) { 01003 // // Draw the vertex 01004 // glVertex3f ( 01005 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01006 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01007 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01008 // ); 01009 // glVertex3f ( 01010 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 01011 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 01012 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 01013 // ); 01014 // } 01015 // halfEdgePtr = halfEdgePtr->Next(); 01016 // } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 01017 // facePtr = facePtr->Next(); 01018 // } 01019 // glEnd(); 01020 // glEnable( GL_LIGHTING ); 01021 //} 01022 01023 // Draw Boundary 01024 if ( true ) { 01025 glColor3f( 1.0f, 0.0f, 0.0f ); 01026 glPushAttrib( GL_LIGHTING_BIT ); 01027 glDisable( GL_LIGHTING ); 01028 glBegin( GL_LINES ); 01029 if ( m_listHoleFace != NULL ) { 01030 HEFace<T> *facePtr = m_listHoleFace->Head(); 01031 HEHalfEdge<T> *halfEdgePtr; 01032 while ( facePtr != NULL ) { 01033 halfEdgePtr = facePtr->IncidentHalfEdge(); 01034 do { 01035 //if ( halfEdgePtr && halfEdgePtr->Next() ) { 01036 // Draw the vertex 01037 glVertex3f ( 01038 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01039 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01040 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01041 ); 01042 glVertex3f ( 01043 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 01044 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 01045 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 01046 ); 01047 //} 01048 halfEdgePtr = halfEdgePtr->Next(); 01049 } while ( halfEdgePtr && halfEdgePtr != facePtr->IncidentHalfEdge() ); 01050 facePtr = facePtr->Next(); 01051 } 01052 } 01053 glEnd(); 01054 //glEnable( GL_LIGHTING ); 01055 glPopAttrib(); 01056 } 01057 01058 if ( bIsDisplayVertexNormals ) { 01059 glColor3ub( 75, 200, 100 ); 01060 glPushAttrib( GL_LIGHTING_BIT ); 01061 glDisable( GL_LIGHTING ); 01062 //HEVertex<T> * pVertex = GetVertexList(); 01063 HEVertex<T> * pVertex = m_listVertex->Head(); 01064 while ( pVertex ) { 01065 Fn::Draw3DLine( pVertex->GetPosition(), pVertex->GetPosition() + pVertex->GetNormal() ); 01066 pVertex = pVertex->Next(); 01067 } 01068 //glEnable( GL_LIGHTING ); 01069 glPopAttrib(); 01070 } 01071 01072 #ifdef TAPs_DEBUG_CD_WITH_HETRI 01073 for ( int i = 0; i < static_cast<int>( m_Parts.size() ); ++i ) { 01074 DrawGLParticleRef( i ); 01075 if ( m_Parts[i].GetModelType() == TAPs::Enum::MODEL_DEFORM ) { 01076 DrawGLSprings( i ); 01077 } 01078 } 01079 #endif//TAPs_DEBUG_CD_WITH_HETRI 01080 01081 01082 DrawVertexSimulationStatus(); 01083 01084 01085 //DrawGLParticleRef(); 01086 //DrawGLVertexRing1(); 01087 //DrawGLSpringConnections(); 01088 //DrawGLSprings(); 01089 01090 //DrawGLHalfEdges(); 01091 01092 // Draw AABB Bounding Box 01093 //DrawBoundingAABB(); 01094 //DrawBoundingEllipsoid(); 01095 //DrawBoundingSphere(); 01096 //--------------------------------------------------------------- 01097 #ifdef TAPs_USE_DATA_POOL 01098 glPopClientAttrib(); 01099 #endif//TAPs_USE_DATA_POOL 01100 } 01101 //----------------------------------------------------------------------------- 01102 template <typename T> 01103 bool OpenGLHETriMeshOneModelMultiParts<T>::EnableVertexColors ( bool b ) 01104 { 01105 if ( m_svVertexColors.size() == 0 ) m_bEnableVertexColor = false; 01106 else m_bEnableVertexColor = b; 01107 return m_bEnableVertexColor; 01108 } 01109 //----------------------------------------------------------------------------- 01110 #endif//TAPs_ENABLE_FACE_VERTEX_COLOR 01111 //============================================================================= 01112 01113 01114 01115 01116 01117 01118 01119 01120 01121 01122 01123 //============================================================================= 01124 #ifdef TAPs_RENDER_BY_GLSL_DS_FACE_VERTEX 01125 //----------------------------------------------------------------------------- 01126 template <typename T> 01127 void OpenGLHETriMeshOneModelMultiParts<T>::DrawGLSLWithDSFaceVertex_RGB ( GLenum drawMode ) 01128 { 01129 //std::cout << "File: " << __FILE__ << " (" << __LINE__ << ") " << "OpenGLHETriMeshOneModelMultiParts::DrawGLWithFaceVertexColor_RGB(...)\n"; 01130 01131 //assert( ShaderProgram ); 01132 GlobalGLSLShaderPool::GetShaderProgram( ShaderName )->BeginGLSL(); 01133 GlobalGLSLShaderPool::SetShaderParameters( ShaderName ); 01134 01135 #ifdef TAPs_USE_DATA_POOL 01136 glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); 01137 #endif//TAPs_USE_DATA_POOL 01138 01139 glPushAttrib( GL_ENABLE_BIT | GL_ENABLE_BIT ); 01140 glEnable( GL_COLOR_MATERIAL ); 01141 01142 01143 /* 01144 // HACKING FOR RENDERING 01145 // Set Material Value 01146 static float mat_ambient[] = { 1, 1, 1, 1 }; 01147 static float mat_diffuse[] = { 1, 1, 1, 1 }; 01148 static float mat_specular[] = { 1, 1, 1, 1 }; 01149 static float mat_shininess[] = { 512 }; 01150 static float mat_emission[] = { 1, 1, 0, 1 }; 01151 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient ); 01152 glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse ); 01153 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular ); 01154 glMaterialfv( GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess ); 01155 glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, mat_emission ); 01156 //*/ 01157 01158 01159 //--------------------------------------------------------------- 01160 if ( drawMode == OpenGL::Enum::POINT ) { 01161 01162 #ifdef TAPs_USE_DATA_POOL 01163 glEnableClientState( GL_VERTEX_ARRAY ); 01164 if ( typeid(T) == typeid(float) ) 01165 { 01166 glVertexPointer( 3, GL_FLOAT, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 01167 } 01168 else //if ( typeid(T) == typeid(double) ) 01169 { 01170 glVertexPointer( 3, GL_DOUBLE, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 01171 } 01172 glPointSize( 2 ); 01173 glDrawArrays( GL_POINTS, 0, GetArrayOfVertexPositions().GetSize() ); 01174 01175 #else //TAPs_USE_DATA_POOL 01176 HEVertex<T> *ptr = m_listVertex->Head(); 01177 glBegin( drawMode ); 01178 while ( ptr != NULL ) { 01179 // Draw the vertex 01180 glVertex3f ( 01181 static_cast<float>( (*ptr)[0] ), 01182 static_cast<float>( (*ptr)[1] ), 01183 static_cast<float>( (*ptr)[2] ) ); 01184 ptr = ptr->Next(); 01185 } 01186 glEnd(); 01187 01188 #endif//TAPs_USE_DATA_POOL 01189 } 01190 else if ( isFacetShading ) { 01191 // Draw the object 01192 //glEnable( GL_TEXTURE_2D ); 01193 HEFace<T> *facePtr = m_listFace->Head(); 01194 HEHalfEdge<T> *halfEdgePtr; 01195 //for ( int f = 0; f < GetNoFaces(); ++f ) { 01196 while ( facePtr != NULL ) { 01197 01198 /* 01199 // Submaterial supported by .ASE 01200 #ifdef TAPs_SUPPORT_ASE_FORMAT 01201 int matID = facePtr->GetMaterialID(); 01202 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 01203 this->submaterials[ matID ]->ApplyMaterial(); 01204 } 01205 #endif//TAPs_SUPPORT_ASE_FORMAT 01206 //*/ 01207 01208 halfEdgePtr = facePtr->IncidentHalfEdge(); 01209 int j = 0; 01210 glBegin( drawMode ); 01211 //for ( int i = 0; i < 3; ++i ) { 01212 do { 01214 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 01215 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 01216 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 01217 //} 01218 // Normal of the face 01219 glNormal3f ( 01220 static_cast<float>( facePtr->GetNormal()[0] ), 01221 static_cast<float>( facePtr->GetNormal()[1] ), 01222 static_cast<float>( facePtr->GetNormal()[2] ) 01223 ); 01224 01225 /* 01226 // Vertex color of the face 01227 float VC[3]; 01228 GetVertexColor( facePtr->GetVertexColorNo( j++ ), &VC[0], &VC[1], &VC[2] ); 01229 glColor3f ( VC[0], VC[1], VC[2] ); 01230 //*/ 01231 01232 // Draw the vertex 01233 glVertex3f ( 01234 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01235 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01236 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01237 ); 01238 // DEBUG: 01239 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 01240 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 01241 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 01242 //std::cout << "\n"; 01243 halfEdgePtr = halfEdgePtr->Next(); 01244 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 01245 //std::cout << "\n"; 01246 //} 01247 glEnd(); 01248 facePtr = facePtr->Next(); 01249 } 01250 01251 // Draw the object 01252 //for ( int i = 0; i < m_iNoFaces; i++ ) 01253 //{ 01254 // glBegin( drawMode ); 01255 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 01256 // { 01257 // // Draw texture 01258 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 01259 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 01260 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 01261 // } 01262 // // Normal of the face 01263 // //glNormal3f ( static_cast<float>( m_prFace[i].GetNormal()[0] ), 01264 // // static_cast<float>( m_prFace[i].GetNormal()[1] ), 01265 // // static_cast<float>( m_prFace[i].GetNormal()[2] ) ); 01266 // // Draw the vertex 01267 // glVertex3f ( 01268 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 01269 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 01270 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 01271 // } 01272 // glEnd(); 01273 //} 01275 } 01276 else { 01277 // Draw the object 01278 01279 #ifdef TAPs_USE_DATA_POOL__ 01280 #else //TAPs_USE_DATA_POOL__ 01281 01282 //glEnable( GL_TEXTURE_2D ); 01283 HEFace<T> *facePtr = m_listFace->Head(); 01284 HEHalfEdge<T> *halfEdgePtr; 01285 while ( facePtr != NULL ) { 01286 01287 /* 01288 // Submaterial supported by .ASE 01289 #ifdef TAPs_SUPPORT_ASE_FORMAT 01290 int matID = facePtr->GetMaterialID(); 01291 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 01292 this->submaterials[ matID ]->ApplyMaterial(); 01293 } 01294 #endif//TAPs_SUPPORT_ASE_FORMAT 01295 //*/ 01296 01297 halfEdgePtr = facePtr->IncidentHalfEdge(); 01298 int j = 0; 01299 glBegin( drawMode ); 01300 //for ( int i = 0; i < 3; ++i ) { 01301 do { 01303 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 01304 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 01305 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 01306 //} 01308 glNormal3f ( 01309 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[0] ), 01310 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[1] ), 01311 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[2] ) 01312 ); 01313 01314 /* 01315 // Vertex color of the face 01316 float VC[3]; 01317 GetVertexColor( facePtr->GetVertexColorNo( j++ ), &VC[0], &VC[1], &VC[2] ); 01318 glColor3f ( VC[0], VC[1], VC[2] ); 01319 //*/ 01320 01321 // Draw the vertex 01322 glVertex3f ( 01323 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01324 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01325 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01326 ); 01327 // DEBUG: 01328 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 01329 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 01330 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 01331 //std::cout << "\n"; 01332 halfEdgePtr = halfEdgePtr->Next(); 01333 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 01334 //std::cout << "\n"; 01335 //} 01336 glEnd(); 01337 facePtr = facePtr->Next(); 01338 } 01339 01340 #endif//TAPs_USE_DATA_POOL__ 01341 01344 //for ( int i = 0; i < m_iNoFaces; i++ ) 01345 //{ 01346 // glBegin( drawMode ); 01347 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 01348 // { 01349 // // Draw texture 01350 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 01351 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 01352 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 01353 // } 01354 // // Normal of the vertex 01355 // glNormal3f ( static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 01356 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 01357 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 01358 // // Draw the vertex 01359 // glVertex3f ( 01360 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 01361 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 01362 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 01363 // } 01364 // glEnd(); 01365 //} 01367 } 01368 01369 glPopAttrib(); 01370 01371 // Draw Boundary 01372 //if ( drawMode == OpenGL::Enum::POLYGON_WITH_WIRE_FRAME ) { 01373 //if ( true ) { 01374 // glColor3f( 1.0f, 0.0f, 0.0f ); 01375 // glDisable( GL_LIGHTING ); 01376 // glBegin( GL_LINES ); 01377 // HEFace<T> *facePtr = m_listFace->Head(); 01378 // HEHalfEdge<T> *halfEdgePtr; 01379 // while ( facePtr != NULL ) { 01380 // halfEdgePtr = facePtr->IncidentHalfEdge(); 01381 // do { 01382 // if ( !halfEdgePtr->Pair() ) { 01383 // // Draw the vertex 01384 // glVertex3f ( 01385 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01386 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01387 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01388 // ); 01389 // glVertex3f ( 01390 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 01391 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 01392 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 01393 // ); 01394 // } 01395 // halfEdgePtr = halfEdgePtr->Next(); 01396 // } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 01397 // facePtr = facePtr->Next(); 01398 // } 01399 // glEnd(); 01400 // glEnable( GL_LIGHTING ); 01401 //} 01402 01403 // Draw Boundary 01404 if ( true ) { 01405 glColor3f( 1.0f, 0.0f, 0.0f ); 01406 glPushAttrib( GL_LIGHTING_BIT ); 01407 glDisable( GL_LIGHTING ); 01408 glBegin( GL_LINES ); 01409 if ( m_listHoleFace != NULL ) { 01410 HEFace<T> *facePtr = m_listHoleFace->Head(); 01411 HEHalfEdge<T> *halfEdgePtr; 01412 while ( facePtr != NULL ) { 01413 halfEdgePtr = facePtr->IncidentHalfEdge(); 01414 do { 01415 //if ( halfEdgePtr && halfEdgePtr->Next() ) { 01416 // Draw the vertex 01417 glVertex3f ( 01418 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01419 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01420 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01421 ); 01422 glVertex3f ( 01423 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 01424 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 01425 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 01426 ); 01427 //} 01428 halfEdgePtr = halfEdgePtr->Next(); 01429 } while ( halfEdgePtr && halfEdgePtr != facePtr->IncidentHalfEdge() ); 01430 facePtr = facePtr->Next(); 01431 } 01432 } 01433 glEnd(); 01434 //glEnable( GL_LIGHTING ); 01435 glPopAttrib(); 01436 } 01437 01438 if ( bIsDisplayVertexNormals ) { 01439 glColor3ub( 75, 200, 100 ); 01440 glPushAttrib( GL_LIGHTING_BIT ); 01441 glDisable( GL_LIGHTING ); 01442 //HEVertex<T> * pVertex = GetVertexList(); 01443 HEVertex<T> * pVertex = m_listVertex->Head(); 01444 while ( pVertex ) { 01445 Fn::Draw3DLine( pVertex->GetPosition(), pVertex->GetPosition() + pVertex->GetNormal() ); 01446 pVertex = pVertex->Next(); 01447 } 01448 //glEnable( GL_LIGHTING ); 01449 glPopAttrib(); 01450 } 01451 01452 #ifdef TAPs_DEBUG_CD_WITH_HETRI 01453 for ( int i = 0; i < static_cast<int>( m_Parts.size() ); ++i ) { 01454 DrawGLParticleRef( i ); 01455 if ( m_Parts[i].GetModelType() == TAPs::Enum::MODEL_DEFORM ) { 01456 DrawGLSprings( i ); 01457 } 01458 } 01459 #endif//TAPs_DEBUG_CD_WITH_HETRI 01460 01461 01462 DrawVertexSimulationStatus(); 01463 01464 01465 //DrawGLParticleRef(); 01466 //DrawGLVertexRing1(); 01467 //DrawGLSpringConnections(); 01468 //DrawGLSprings(); 01469 01470 //DrawGLHalfEdges(); 01471 01472 // Draw AABB Bounding Box 01473 //DrawBoundingAABB(); 01474 //DrawBoundingEllipsoid(); 01475 //DrawBoundingSphere(); 01476 //--------------------------------------------------------------- 01477 #ifdef TAPs_USE_DATA_POOL 01478 glPopClientAttrib(); 01479 #endif//TAPs_USE_DATA_POOL 01480 01481 GlobalGLSLShaderPool::GetShaderProgram( ShaderName )->EndGLSL(); 01482 01483 /* 01484 glPushAttrib( GL_ALL_ATTRIB_BITS ); 01485 glEnable( GL_COLOR_MATERIAL ); 01486 glEnable( GL_TEXTURE_2D ); 01487 static unsigned int count = 0; 01488 if ( count++ < 1000 ) glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); 01489 else if ( count++ < 2000 ) glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); 01490 else if ( count++ < 3000 ) glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE ); 01491 else if ( count++ < 4000 ) glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND ); 01492 else if ( count++ < 5000 ) glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD ); 01493 else if ( count++ < 6000 ) glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE ); 01494 else if ( count++ < 7000 ) count = 0; 01495 glBindTexture( GL_TEXTURE_2D, GlobalGLSLShaderPool::Get2DTextureID( 0 ) ); 01496 glColor3f( 0, 1, 0 ); 01497 glBegin( GL_QUADS ); 01498 glTexCoord2f( 0, 0 ); 01499 glNormal3f( 0, 0, 1 ); 01500 glVertex3f( 0, 0, 0 ); 01501 glTexCoord2f( 0, 1 ); 01502 glNormal3f( 0, 0, 1 ); 01503 glVertex3f( 0, 1, 0 ); 01504 glTexCoord2f( 1, 1 ); 01505 glNormal3f( 0, 0, 1 ); 01506 glVertex3f( 1, 1, 0 ); 01507 glTexCoord2f( 1, 0 ); 01508 glNormal3f( 0, 0, 1 ); 01509 glVertex3f( 1, 0, 0 ); 01510 glEnd(); 01511 glPopAttrib(); 01512 //*/ 01513 01514 } 01515 //----------------------------------------------------------------------------- 01516 template <typename T> 01517 void OpenGLHETriMeshOneModelMultiParts<T>::DrawGLSLWithDSFaceVertex_RGBA ( GLenum drawMode ) 01518 { 01519 //std::cout << "File: " << __FILE__ << " (" << __LINE__ << ") " << "OpenGLHETriMeshOneModelMultiParts::DrawGLWithFaceVertexColor_RGBA(...)\n"; 01520 01521 //assert( ShaderProgram ); 01522 GlobalGLSLShaderPool::GetShaderProgram( ShaderName )->BeginGLSL(); 01523 GlobalGLSLShaderPool::SetShaderParameters( ShaderName ); 01524 01525 #ifdef TAPs_USE_DATA_POOL 01526 glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); 01527 #endif//TAPs_USE_DATA_POOL 01528 01529 glPushAttrib( GL_ENABLE_BIT | GL_ENABLE_BIT ); 01530 glEnable( GL_COLOR_MATERIAL ); 01531 01532 01533 /* 01534 // HACKING FOR RENDERING 01535 // Set Material Value 01536 static float mat_ambient[] = { 1, 1, 1, 1 }; 01537 static float mat_diffuse[] = { 1, 1, 1, 1 }; 01538 static float mat_specular[] = { 1, 1, 1, 1 }; 01539 static float mat_shininess[] = { 512 }; 01540 static float mat_emission[] = { 1, 1, 0, 1 }; 01541 glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient ); 01542 glMaterialfv( GL_FRONT_AND_BACK, GL_DIFFUSE, mat_diffuse ); 01543 glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular ); 01544 glMaterialfv( GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess ); 01545 glMaterialfv( GL_FRONT_AND_BACK, GL_EMISSION, mat_emission ); 01546 //*/ 01547 01548 01549 //--------------------------------------------------------------- 01550 if ( drawMode == OpenGL::Enum::POINT ) { 01551 01552 #ifdef TAPs_USE_DATA_POOL 01553 glEnableClientState( GL_VERTEX_ARRAY ); 01554 if ( typeid(T) == typeid(float) ) 01555 { 01556 glVertexPointer( 3, GL_FLOAT, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 01557 } 01558 else //if ( typeid(T) == typeid(double) ) 01559 { 01560 glVertexPointer( 3, GL_DOUBLE, 0, GetArrayOfVertexPositions().GetAddressOfDataNumber(0) ); 01561 } 01562 glPointSize( 2 ); 01563 glDrawArrays( GL_POINTS, 0, GetArrayOfVertexPositions().GetSize() ); 01564 01565 #else //TAPs_USE_DATA_POOL 01566 HEVertex<T> *ptr = m_listVertex->Head(); 01567 glBegin( drawMode ); 01568 while ( ptr != NULL ) { 01569 // Draw the vertex 01570 glVertex3f ( 01571 static_cast<float>( (*ptr)[0] ), 01572 static_cast<float>( (*ptr)[1] ), 01573 static_cast<float>( (*ptr)[2] ) ); 01574 ptr = ptr->Next(); 01575 } 01576 glEnd(); 01577 01578 #endif//TAPs_USE_DATA_POOL 01579 } 01580 else if ( isFacetShading ) { 01581 // Draw the object 01582 //glEnable( GL_TEXTURE_2D ); 01583 HEFace<T> *facePtr = m_listFace->Head(); 01584 HEHalfEdge<T> *halfEdgePtr; 01585 //for ( int f = 0; f < GetNoFaces(); ++f ) { 01586 while ( facePtr != NULL ) { 01587 01588 /* 01589 // Submaterial supported by .ASE 01590 #ifdef TAPs_SUPPORT_ASE_FORMAT 01591 int matID = facePtr->GetMaterialID(); 01592 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 01593 this->submaterials[ matID ]->ApplyMaterial(); 01594 } 01595 #endif//TAPs_SUPPORT_ASE_FORMAT 01596 //*/ 01597 01598 halfEdgePtr = facePtr->IncidentHalfEdge(); 01599 int j = 0; 01600 glBegin( drawMode ); 01601 //for ( int i = 0; i < 3; ++i ) { 01602 do { 01604 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 01605 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 01606 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 01607 //} 01608 // Normal of the face 01609 glNormal3f ( 01610 static_cast<float>( facePtr->GetNormal()[0] ), 01611 static_cast<float>( facePtr->GetNormal()[1] ), 01612 static_cast<float>( facePtr->GetNormal()[2] ) 01613 ); 01614 01615 /* 01616 // Vertex color of the face 01617 float VC[4]; 01618 GetVertexColor( facePtr->GetVertexColorNo( j++ ), &VC[0], &VC[1], &VC[2], &VC[3] ); 01619 glColor4f ( VC[0], VC[1], VC[2], VC[3] ); 01620 //*/ 01621 01622 // Draw the vertex 01623 glVertex3f ( 01624 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01625 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01626 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01627 ); 01628 // DEBUG: 01629 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 01630 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 01631 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 01632 //std::cout << "\n"; 01633 halfEdgePtr = halfEdgePtr->Next(); 01634 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 01635 //std::cout << "\n"; 01636 //} 01637 glEnd(); 01638 facePtr = facePtr->Next(); 01639 } 01640 01641 // Draw the object 01642 //for ( int i = 0; i < m_iNoFaces; i++ ) 01643 //{ 01644 // glBegin( drawMode ); 01645 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 01646 // { 01647 // // Draw texture 01648 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 01649 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 01650 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 01651 // } 01652 // // Normal of the face 01653 // //glNormal3f ( static_cast<float>( m_prFace[i].GetNormal()[0] ), 01654 // // static_cast<float>( m_prFace[i].GetNormal()[1] ), 01655 // // static_cast<float>( m_prFace[i].GetNormal()[2] ) ); 01656 // // Draw the vertex 01657 // glVertex3f ( 01658 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 01659 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 01660 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 01661 // } 01662 // glEnd(); 01663 //} 01665 } 01666 else { 01667 // Draw the object 01668 01669 #ifdef TAPs_USE_DATA_POOL__ 01670 #else //TAPs_USE_DATA_POOL__ 01671 01672 //glEnable( GL_TEXTURE_2D ); 01673 HEFace<T> *facePtr = m_listFace->Head(); 01674 HEHalfEdge<T> *halfEdgePtr; 01675 //for ( int f = 0; f < GetNoFaces(); ++f ) { 01676 while ( facePtr != NULL ) { 01677 01678 /* 01679 // Submaterial supported by .ASE 01680 #ifdef TAPs_SUPPORT_ASE_FORMAT 01681 int matID = facePtr->GetMaterialID(); 01682 if ( matID < static_cast<int>( this->submaterials.size() ) ) { 01683 this->submaterials[ matID ]->ApplyMaterial(); 01684 } 01685 #endif//TAPs_SUPPORT_ASE_FORMAT 01686 //*/ 01687 01688 halfEdgePtr = facePtr->IncidentHalfEdge(); 01689 int j = 0; 01690 glBegin( drawMode ); 01691 //for ( int i = 0; i < 3; ++i ) { 01692 do { 01694 //if ( m_prFace[i].GetNoTexCoords() != 0 ) { 01695 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 01696 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 01697 //} 01699 glNormal3f ( 01700 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[0] ), 01701 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[1] ), 01702 static_cast<float>( halfEdgePtr->Vertex()->GetNormal()[2] ) 01703 ); 01704 01705 /* 01706 // Vertex color of the face 01707 float VC[4]; 01708 GetVertexColor( facePtr->GetVertexColorNo( j++ ), &VC[0], &VC[1], &VC[2], &VC[3] ); 01709 glColor4f ( VC[0], VC[1], VC[2], VC[3] ); 01710 //*/ 01711 01712 // Draw the vertex 01713 glVertex3f ( 01714 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01715 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01716 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01717 ); 01718 // DEBUG: 01719 //std::cout << halfEdgePtr->Vertex()->GetPosition()[0]; 01720 //std::cout << halfEdgePtr->Vertex()->GetPosition()[1]; 01721 //std::cout << halfEdgePtr->Vertex()->GetPosition()[2]; 01722 //std::cout << "\n"; 01723 halfEdgePtr = halfEdgePtr->Next(); 01724 } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 01725 //std::cout << "\n"; 01726 //} 01727 glEnd(); 01728 facePtr = facePtr->Next(); 01729 } 01730 01731 #endif//TAPs_USE_DATA_POOL__ 01732 01735 //for ( int i = 0; i < m_iNoFaces; i++ ) 01736 //{ 01737 // glBegin( drawMode ); 01738 // for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j ) 01739 // { 01740 // // Draw texture 01741 // if ( m_prFace[i].GetNoTexCoords() != 0 ) { 01742 // glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 01743 // static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) ); 01744 // } 01745 // // Normal of the vertex 01746 // glNormal3f ( static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 01747 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 01748 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 01749 // // Draw the vertex 01750 // glVertex3f ( 01751 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 01752 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 01753 // static_cast<float>( m_prXVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) ); 01754 // } 01755 // glEnd(); 01756 //} 01758 } 01759 01760 glPopAttrib(); 01761 01762 // Draw Boundary 01763 //if ( drawMode == OpenGL::Enum::POLYGON_WITH_WIRE_FRAME ) { 01764 //if ( true ) { 01765 // glColor3f( 1.0f, 0.0f, 0.0f ); 01766 // glDisable( GL_LIGHTING ); 01767 // glBegin( GL_LINES ); 01768 // HEFace<T> *facePtr = m_listFace->Head(); 01769 // HEHalfEdge<T> *halfEdgePtr; 01770 // while ( facePtr != NULL ) { 01771 // halfEdgePtr = facePtr->IncidentHalfEdge(); 01772 // do { 01773 // if ( !halfEdgePtr->Pair() ) { 01774 // // Draw the vertex 01775 // glVertex3f ( 01776 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01777 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01778 // static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01779 // ); 01780 // glVertex3f ( 01781 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 01782 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 01783 // static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 01784 // ); 01785 // } 01786 // halfEdgePtr = halfEdgePtr->Next(); 01787 // } while ( halfEdgePtr != facePtr->IncidentHalfEdge() ); 01788 // facePtr = facePtr->Next(); 01789 // } 01790 // glEnd(); 01791 // glEnable( GL_LIGHTING ); 01792 //} 01793 01794 // Draw Boundary 01795 if ( true ) { 01796 glColor3f( 1.0f, 0.0f, 0.0f ); 01797 glPushAttrib( GL_LIGHTING_BIT ); 01798 glDisable( GL_LIGHTING ); 01799 glBegin( GL_LINES ); 01800 if ( m_listHoleFace != NULL ) { 01801 HEFace<T> *facePtr = m_listHoleFace->Head(); 01802 HEHalfEdge<T> *halfEdgePtr; 01803 while ( facePtr != NULL ) { 01804 halfEdgePtr = facePtr->IncidentHalfEdge(); 01805 do { 01806 //if ( halfEdgePtr && halfEdgePtr->Next() ) { 01807 // Draw the vertex 01808 glVertex3f ( 01809 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[0] ), 01810 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[1] ), 01811 static_cast<float>( halfEdgePtr->Vertex()->GetPosition()[2] ) 01812 ); 01813 glVertex3f ( 01814 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[0] ), 01815 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[1] ), 01816 static_cast<float>( halfEdgePtr->Next()->Vertex()->GetPosition()[2] ) 01817 ); 01818 //} 01819 halfEdgePtr = halfEdgePtr->Next(); 01820 } while ( halfEdgePtr && halfEdgePtr != facePtr->IncidentHalfEdge() ); 01821 facePtr = facePtr->Next(); 01822 } 01823 } 01824 glEnd(); 01825 //glEnable( GL_LIGHTING ); 01826 glPopAttrib(); 01827 } 01828 01829 if ( bIsDisplayVertexNormals ) { 01830 glColor3ub( 75, 200, 100 ); 01831 glPushAttrib( GL_LIGHTING_BIT ); 01832 glDisable( GL_LIGHTING ); 01833 //HEVertex<T> * pVertex = GetVertexList(); 01834 HEVertex<T> * pVertex = m_listVertex->Head(); 01835 while ( pVertex ) { 01836 Fn::Draw3DLine( pVertex->GetPosition(), pVertex->GetPosition() + pVertex->GetNormal() ); 01837 pVertex = pVertex->Next(); 01838 } 01839 //glEnable( GL_LIGHTING ); 01840 glPopAttrib(); 01841 } 01842 01843 #ifdef TAPs_DEBUG_CD_WITH_HETRI 01844 for ( int i = 0; i < static_cast<int>( m_Parts.size() ); ++i ) { 01845 DrawGLParticleRef( i ); 01846 if ( m_Parts[i].GetModelType() == TAPs::Enum::MODEL_DEFORM ) { 01847 DrawGLSprings( i ); 01848 } 01849 } 01850 #endif//TAPs_DEBUG_CD_WITH_HETRI 01851 01852 DrawVertexSimulationStatus(); 01853 01854 //DrawGLParticleRef(); 01855 //DrawGLVertexRing1(); 01856 //DrawGLSpringConnections(); 01857 //DrawGLSprings(); 01858 01859 //DrawGLHalfEdges(); 01860 01861 // Draw AABB Bounding Box 01862 //DrawBoundingAABB(); 01863 //DrawBoundingEllipsoid(); 01864 //DrawBoundingSphere(); 01865 //--------------------------------------------------------------- 01866 #ifdef TAPs_USE_DATA_POOL 01867 glPopClientAttrib(); 01868 #endif//TAPs_USE_DATA_POOL 01869 01870 GlobalGLSLShaderPool::GetShaderProgram( ShaderName )->EndGLSL(); 01871 } 01872 //----------------------------------------------------------------------------- 01873 #endif//TAPs_RENDER_BY_GLSL_DS_FACE_VERTEX 01874 //============================================================================= 01875 01876 01877 01878 01879 01880 01881 01882 01883 01884 01885 01886 01887 //----------------------------------------------------------------------------- 01888 // DEBUG 01889 template <typename T> 01890 void OpenGLHETriMeshOneModelMultiParts<T>::DrawGLParticleRef ( int partNo ) 01891 { 01892 // Draw whole model 01893 if ( partNo < 0 ) { 01894 if ( !m_pHEVertexList->empty() ) { 01895 glPushAttrib( GL_CURRENT_BIT | GL_LIGHTING_BIT ); 01896 glDisable( GL_LIGHTING ); 01897 glColor3f( 0, 1, 0 ); 01898 glPointSize( 2 ); 01899 glPushMatrix(); 01900 glBegin( GL_POINTS ); 01901 for ( int i = 0; i < static_cast<int>( m_pHEVertexList->size() ); ++i ) { 01902 glVertex3fv( (*m_pHEVertexList)[i]->GetParticleRef()->GetPosition().GetDataFloat() ); 01903 } 01904 glEnd(); 01905 glPopMatrix(); 01906 glPopAttrib(); 01907 } 01908 } 01909 // Draw a part 01910 else if ( partNo < static_cast<int>( m_Parts.size() ) ) { 01911 float color = 1.0f / static_cast<float>( m_Parts.size() ); 01912 Vector3<float> vColor( 1.0f-(color*(partNo+1)), 0.0f, color*(partNo+1) ); 01913 glPushAttrib( GL_CURRENT_BIT | GL_LIGHTING_BIT ); 01914 glDisable( GL_LIGHTING ); 01915 glColor3f( vColor[0], vColor[1], vColor[2] ); 01916 glPointSize( 2 ); 01917 glPushMatrix(); 01918 glBegin( GL_POINTS ); 01919 for ( int i = 0; i < static_cast<int>( m_Parts[partNo].GetVertexList().size() ); ++i ) { 01920 glVertex3fv( m_Parts[partNo].GetVertexList()[i]->GetParticleRef()->GetPosition().GetDataFloat() ); 01921 } 01922 glEnd(); 01923 glPopMatrix(); 01924 glPopAttrib(); 01925 01926 01927 /* 01928 // DEBUG 01929 glPushAttrib( GL_CURRENT_BIT | GL_LIGHTING_BIT ); 01930 glDisable( GL_LIGHTING ); 01931 glColor3f( 1, 0, 0 ); 01932 glPointSize( 7 ); 01933 glPushMatrix(); 01934 glBegin( GL_POINTS ); 01935 for ( int i = 0; i < static_cast<int>( m_Parts[partNo].GetVertexList().size() ); ++i ) { 01936 glVertex3fv( m_Parts[partNo].GetVertexList()[i]->GetHomePosition().GetDataFloat() ); 01937 } 01938 glEnd(); 01939 glPopMatrix(); 01940 glPopAttrib(); 01941 //*/ 01942 } 01943 } 01944 //----------------------------------------------------------------------------- 01945 // DEBUG 01946 template <typename T> 01947 void OpenGLHETriMeshOneModelMultiParts<T>::DrawGLVertexRing1 ( int partNo ) 01948 { 01949 glPushAttrib( GL_CURRENT_BIT | GL_LIGHTING_BIT ); 01950 glDisable( GL_LIGHTING ); 01951 glColor3f( 0, 0.5, 1 ); 01952 glLineWidth( 1 ); 01953 glPushMatrix(); 01954 glBegin( GL_LINES ); 01955 for ( int i = 0; i < static_cast<int>( m_vpHEVertex.size() ); ++i ) { 01956 int k; 01957 for ( int j = 0; j < static_cast<int>( m_pviListVertexRing1[i].size() ); ++j ) { 01958 glVertex3f( m_vpHEVertex[i]->GetPosition()[0], 01959 m_vpHEVertex[i]->GetPosition()[1], 01960 m_vpHEVertex[i]->GetPosition()[2] ); 01961 k = m_pviListVertexRing1[i][j]; 01962 glVertex3f( m_vpHEVertex[k]->GetPosition()[0], 01963 m_vpHEVertex[k]->GetPosition()[1], 01964 m_vpHEVertex[k]->GetPosition()[2] ); 01965 } 01966 } 01967 glEnd(); 01968 glPopMatrix(); 01969 glPopAttrib(); 01970 } 01971 //----------------------------------------------------------------------------- 01972 // DEBUG 01973 template <typename T> 01974 void OpenGLHETriMeshOneModelMultiParts<T>::DrawGLSpringConnections ( int partNo ) 01975 { 01976 for ( int i = 0; i < static_cast<int>( m_vpSpringRef.size() ); ++i ) { 01977 glPushAttrib( GL_CURRENT_BIT | GL_LIGHTING_BIT ); 01978 glDisable( GL_LIGHTING ); 01979 glColor3f( 0, 0.5, 1 ); 01980 glLineWidth( 1 ); 01981 glPushMatrix(); 01982 glBegin( GL_LINES ); 01983 glVertex3f( m_vpSpringRef[i]->GetParticleOne().GetPosition()[0], 01984 m_vpSpringRef[i]->GetParticleOne().GetPosition()[1], 01985 m_vpSpringRef[i]->GetParticleOne().GetPosition()[2] ); 01986 glVertex3f( m_vpSpringRef[i]->GetParticleTwo().GetPosition()[0], 01987 m_vpSpringRef[i]->GetParticleTwo().GetPosition()[1], 01988 m_vpSpringRef[i]->GetParticleTwo().GetPosition()[2] ); 01989 glEnd(); 01990 glPopMatrix(); 01991 glPopAttrib(); 01992 } 01993 } 01994 //----------------------------------------------------------------------------- 01995 // DEBUG 01996 template <typename T> 01997 void OpenGLHETriMeshOneModelMultiParts<T>::DrawGLSprings ( int partNo ) 01998 { 01999 // Draw whole model 02000 if ( partNo < 0 ) { 02001 for ( int i = 0; i < static_cast<int>( m_vpSpringRef.size() ); ++i ) { 02002 m_vpSpringRef[i]->DrawByOpenGL(); 02003 } 02004 } 02005 // Draw a part 02006 else if ( partNo < static_cast<int>( m_Parts.size() ) ) { 02007 for ( int i = 0; i < static_cast<int>( m_Parts[partNo].GetSpringList().size() ); ++i ) { 02008 m_Parts[partNo].GetSpringList()[i]->DrawByOpenGL(); 02009 } 02010 } 02011 } 02012 //------------------------------------------------------------------------------ 02013 #ifdef TAPs_ADVANCED_SIMULATION 02014 template <typename T> 02015 void OpenGLHETriMeshOneModelMultiParts<T>::DrawVertexSimulationStatus () 02016 { 02017 /* 02018 // Draw as points 02019 glPushAttrib( GL_ENABLE_BIT ); 02020 glDisable( GL_LIGHTING ); 02021 glPointSize( 3 ); 02022 glBegin( GL_POINTS ); 02023 HEVertex<T> * pVertex = m_listVertex->Head(); 02024 while ( pVertex ) { 02025 if ( pVertex->SimFlags.CheckSimulationConstraints( TAPs::Enum::AddOn::FIXED ) ) { 02026 glColor4f( 0.0f, 0.0f, 1.0f, 0.5f ); 02027 } 02028 else if ( pVertex->SimFlags.CheckSimulationConstraints( TAPs::Enum::AddOn::ATTACHED ) ) { 02029 glColor4f( 0.0f, 1.0f, 0.0f, 0.5f ); 02030 } 02031 else if ( pVertex->SimFlags.CheckSimulationConstraints( TAPs::Enum::AddOn::PUNCTURED ) ) { 02032 glColor4f( 1.0f, 0.0f, 0.0f, 0.5f ); 02033 } 02034 else { 02035 glColor4f( 0.5f, 0.5f, 0.5f, 0.5f ); 02036 } 02037 glVertex3fv( pVertex->GetPosition().GetDataFloat() ); 02038 pVertex = pVertex->Next(); 02039 } 02040 glEnd(); 02041 glPopAttrib(); 02042 //*/ 02043 02044 //* 02045 // Draw as spheres 02046 static OpenGLUsefulObj<T> drawer; 02047 T radius = 0.01; 02048 HEVertex<T> * pVertex = m_listVertex->Head(); 02049 while ( pVertex ) { 02050 if ( pVertex->SimFlags.CheckSimulationConstraints( TAPs::Enum::AddOn::FIXED ) ) { 02051 glTranslatef( pVertex->GetPosition()[0], pVertex->GetPosition()[1], pVertex->GetPosition()[2] ); 02052 drawer.SetColor( 0, 0, 1, 0.5 ); 02053 drawer.DrawSphere( radius ); 02054 glTranslatef( -pVertex->GetPosition()[0], -pVertex->GetPosition()[1], -pVertex->GetPosition()[2] ); 02055 } 02056 else if ( pVertex->SimFlags.CheckSimulationConstraints( TAPs::Enum::AddOn::ATTACHED ) ) { 02057 glTranslatef( pVertex->GetPosition()[0], pVertex->GetPosition()[1], pVertex->GetPosition()[2] ); 02058 drawer.SetColor( 0, 1, 0, 0.5 ); 02059 drawer.DrawSphere( radius ); 02060 glTranslatef( -pVertex->GetPosition()[0], -pVertex->GetPosition()[1], -pVertex->GetPosition()[2] ); 02061 } 02062 else if ( pVertex->SimFlags.CheckSimulationConstraints( TAPs::Enum::AddOn::PUNCTURED ) ) { 02063 glTranslatef( pVertex->GetPosition()[0], pVertex->GetPosition()[1], pVertex->GetPosition()[2] ); 02064 drawer.SetColor( 1, 0, 0, 0.5 ); 02065 drawer.DrawSphere( radius ); 02066 glTranslatef( -pVertex->GetPosition()[0], -pVertex->GetPosition()[1], -pVertex->GetPosition()[2] ); 02067 } 02068 pVertex = pVertex->Next(); 02069 } 02070 //*/ 02071 02072 } 02073 #endif//TAPs_ADVANCED_SIMULATION 02074 //----------------------------------------------------------------------------- 02075 02076 //----------------------------------------------------------------------------- 02077 //============================================================================= 02078 END_NAMESPACE_TAPs__OpenGL 02079 //----------------------------------------------------------------------------- 02080 //34567890123456789012345678901234567890123456789012345678901234567890123456789 02081 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----