TAPs 0.7.7.3
TAPsOpenGLPolygonalModel.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsOpenGLPolygonalModel.cpp
00003 
00004 Class OpenGLPolyModel is for creating an OpenGL Polygonal Model.
00005 
00006 SUKITTI PUNAK   (10/31/2004)
00007 UPDATE          (04/27/2005)
00008 ******************************************************************************/
00009 #include "TAPsOpenGLPolygonalModel.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__OpenGL
00015 //=============================================================================
00016 // CLASS: TAPsModel ************************************************************
00017 //-----------------------------------------------------------------------------
00018 // default constructor
00019 template <typename T>
00020 OpenGLPolygonalModel<T>::OpenGLPolygonalModel()
00021     : PolygonalModel<T>()
00022 {
00023     #ifdef  TAPs_DEBUG_MODE
00024     std::cout << "OpenGLPolygonalModel<" << typeid(T).name() << "> constructor\n";
00025     #endif//TAPs_DEBUG_MODE
00026 }
00027 //-----------------------------------------------------------------------------
00028 // destructor
00029 template <typename T>
00030 OpenGLPolygonalModel<T>::~OpenGLPolygonalModel()
00031 {
00032     #ifdef  TAPs_DEBUG_MODE
00033     std::cout << "OpenGLPolygonalModel<" << typeid(T).name() << "> destructor\n";
00034     #endif//TAPs_DEBUG_MODE
00035 }
00036 //-----------------------------------------------------------------------------
00037 // Helper Fn
00038 // void DrawGL()
00039 template <typename T>
00040 void OpenGLPolygonalModel<T>::DrawGL ( GLenum drawMode )
00041 {
00042     if ( isFacetShading ) {
00043         // Draw the object
00044         //glEnable( GL_TEXTURE_2D );
00045         for ( int i = 0; i < m_iNoFaces; i++ )
00046         {
00047             // Submaterial supported by .ASE
00048             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00049             int matID = m_prFace[i].GetMaterialID();
00050             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00051                 this->submaterials[ matID ]->ApplyMaterial();
00052             }
00053             #endif//TAPs_SUPPORT_ASE_FORMAT
00054 
00055             glBegin( drawMode );
00056             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00057             {
00058                 // Draw texture
00059                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00060                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00061                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00062                 }
00063                 // Normal of the face
00064                 glNormal3f ( static_cast<float>( m_prFace[i].GetNormal().GetX() ), 
00065                             static_cast<float>( m_prFace[i].GetNormal().GetY() ), 
00066                             static_cast<float>( m_prFace[i].GetNormal().GetZ() ) );
00067                 // Draw the vertex
00068                 glVertex3f ( 
00069                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00070                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00071                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00072             }
00073             glEnd();
00074         }
00075         //glDisable( GL_TEXTURE_2D );
00076     }
00077     else {
00078         // Draw the object
00079         //glEnable( GL_TEXTURE_2D );
00080         for ( int i = 0; i < m_iNoFaces; i++ )
00081         {
00082             // Submaterial supported by .ASE
00083             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00084             int matID = m_prFace[i].GetMaterialID();
00085             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00086                 this->submaterials[ matID ]->ApplyMaterial();
00087             }
00088             #endif//TAPs_SUPPORT_ASE_FORMAT
00089 
00090             glBegin( drawMode );
00091             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00092             {
00093                 // Draw texture
00094                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00095                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00096                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00097                 }
00098                 // Normal of the vertex
00099                 glNormal3f ( static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 
00100                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 
00101                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 
00102                 // Draw the vertex
00103                 glVertex3f ( 
00104                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00105                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00106                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00107             }
00108             glEnd();
00109         }
00110         //glDisable( GL_TEXTURE_2D );
00111     }
00112     
00113     // Draw AABB Bounding Box
00114     //DrawBoundingAABB();
00115     //DrawBoundingEllipsoid();
00116     //DrawBoundingSphere();
00117 }
00118 //-----------------------------------------------------------------------------
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 //=============================================================================
00133 #ifdef  TAPs_ENABLE_FACE_VERTEX_COLOR
00134 //-----------------------------------------------------------------------------
00135 template <typename T>
00136 void OpenGLPolygonalModel<T>::DrawGLWithFaceVertexColor_RGB ( GLenum drawMode )
00137 {
00138     //static bool isFirst = true;
00139 
00140     glPushAttrib( GL_ENABLE_BIT | GL_ENABLE_BIT );
00141     glEnable( GL_COLOR_MATERIAL );
00142 
00143     if ( isFacetShading ) {
00144         // Draw the object
00145         //glEnable( GL_TEXTURE_2D );
00146         for ( int i = 0; i < m_iNoFaces; i++ )
00147         {
00148             /*
00149             // Submaterial supported by .ASE
00150             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00151             int matID = m_prFace[i].GetMaterialID();
00152             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00153                 this->submaterials[ matID ]->ApplyMaterial();
00154             }
00155             #endif//TAPs_SUPPORT_ASE_FORMAT
00156             //*/
00157 
00158             glBegin( drawMode );
00159             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00160             {
00161                 // Draw texture
00162                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00163                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00164                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00165                 }
00166                 // Normal of the face
00167                 glNormal3f ( static_cast<float>( m_prFace[i].GetNormal().GetX() ), 
00168                              static_cast<float>( m_prFace[i].GetNormal().GetY() ), 
00169                              static_cast<float>( m_prFace[i].GetNormal().GetZ() ) );
00170 
00171                 // Vertex color of the face
00172                 float VC[3];
00173                 GetVertexColor( m_prFace[i].GetVertexColorNo( j ), &VC[0], &VC[1], &VC[2] );
00174                 glColor3f ( VC[0], VC[1], VC[2] );
00175 
00176                 // Draw the vertex
00177                 glVertex3f ( 
00178                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00179                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00180                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00181             }
00182             glEnd();
00183         }
00184         //glDisable( GL_TEXTURE_2D );
00185     }
00186     else {
00187         // Draw the object
00188         //glEnable( GL_TEXTURE_2D );
00189         for ( int i = 0; i < m_iNoFaces; i++ )
00190         {
00191             /*
00192             // Submaterial supported by .ASE
00193             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00194             int matID = m_prFace[i].GetMaterialID();
00195             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00196                 this->submaterials[ matID ]->ApplyMaterial();
00197             }
00198             #endif//TAPs_SUPPORT_ASE_FORMAT
00199             //*/
00200 
00201             glBegin( drawMode );
00202             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00203             {
00204                 // Draw texture
00205                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00206                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00207                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00208                 }
00209                 // Normal of the vertex
00210                 glNormal3f ( static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 
00211                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 
00212                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 
00213 
00214                 //if ( isFirst ) {
00215                 //  std::cout << "Face# " << i << " V# " << j << ":\t" << m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal() << "\n";
00216                 //}
00217 
00218                 // Vertex color of the face
00219                 float VC[3];
00220                 GetVertexColor( m_prFace[i].GetVertexColorNo( j ), &VC[0], &VC[1], &VC[2] );
00221                 glColor3f ( VC[0], VC[1], VC[2] );
00222 
00223                 // Draw the vertex
00224                 glVertex3f ( 
00225                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00226                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00227                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00228             }
00229             glEnd();
00230         }
00231         //glDisable( GL_TEXTURE_2D );
00232     }
00233 
00234     glPopAttrib();
00235 
00236     //isFirst = false;
00237     
00238     // Draw AABB Bounding Box
00239     //DrawBoundingAABB();
00240     //DrawBoundingEllipsoid();
00241     //DrawBoundingSphere();
00242 }
00243 //-----------------------------------------------------------------------------
00244 template <typename T>
00245 void OpenGLPolygonalModel<T>::DrawGLWithFaceVertexColor_RGBA ( GLenum drawMode )
00246 {
00247     //static bool isFirst = true;
00248 
00249     glPushAttrib( GL_ENABLE_BIT | GL_ENABLE_BIT );
00250     glEnable( GL_COLOR_MATERIAL );
00251 
00252     if ( isFacetShading ) {
00253         // Draw the object
00254         //glEnable( GL_TEXTURE_2D );
00255         for ( int i = 0; i < m_iNoFaces; i++ )
00256         {
00257             /*
00258             // Submaterial supported by .ASE
00259             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00260             int matID = m_prFace[i].GetMaterialID();
00261             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00262                 this->submaterials[ matID ]->ApplyMaterial();
00263             }
00264             #endif//TAPs_SUPPORT_ASE_FORMAT
00265             //*/
00266 
00267             glBegin( drawMode );
00268             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00269             {
00270                 // Draw texture
00271                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00272                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00273                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00274                 }
00275                 // Normal of the face
00276                 glNormal3f ( static_cast<float>( m_prFace[i].GetNormal().GetX() ), 
00277                              static_cast<float>( m_prFace[i].GetNormal().GetY() ), 
00278                              static_cast<float>( m_prFace[i].GetNormal().GetZ() ) );
00279 
00280                 // Vertex color of the face
00281                 float VC[4];
00282                 GetVertexColor( m_prFace[i].GetVertexColorNo( j ), &VC[0], &VC[1], &VC[2], &VC[3] );
00283                 glColor4f ( VC[0], VC[1], VC[2], VC[3] );
00284 
00285                 // Draw the vertex
00286                 glVertex3f ( 
00287                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00288                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00289                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00290             }
00291             glEnd();
00292         }
00293         //glDisable( GL_TEXTURE_2D );
00294     }
00295     else {
00296         // Draw the object
00297         //glEnable( GL_TEXTURE_2D );
00298         for ( int i = 0; i < m_iNoFaces; i++ )
00299         {
00300             /*
00301             // Submaterial supported by .ASE
00302             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00303             int matID = m_prFace[i].GetMaterialID();
00304             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00305                 this->submaterials[ matID ]->ApplyMaterial();
00306             }
00307             #endif//TAPs_SUPPORT_ASE_FORMAT
00308             //*/
00309 
00310             glBegin( drawMode );
00311             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00312             {
00313                 // Draw texture
00314                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00315                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00316                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00317                 }
00318                 // Normal of the vertex
00319                 glNormal3f ( static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 
00320                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 
00321                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 
00322 
00323                 //if ( isFirst ) {
00324                 //  std::cout << "Face# " << i << " V# " << j << ":\t" << m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal() << "\n";
00325                 //}
00326 
00327                 // Vertex color of the face
00328                 float VC[4];
00329                 GetVertexColor( m_prFace[i].GetVertexColorNo( j ), &VC[0], &VC[1], &VC[2], &VC[3] );
00330                 glColor4f ( VC[0], VC[1], VC[2], VC[3] );
00331 
00332                 // Draw the vertex
00333                 glVertex3f ( 
00334                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00335                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00336                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00337             }
00338             glEnd();
00339         }
00340         //glDisable( GL_TEXTURE_2D );
00341     }
00342 
00343     glPopAttrib();
00344 
00345     //isFirst = false;
00346     
00347     // Draw AABB Bounding Box
00348     //DrawBoundingAABB();
00349     //DrawBoundingEllipsoid();
00350     //DrawBoundingSphere();
00351 }
00352 //-----------------------------------------------------------------------------
00353 template <typename T>
00354 bool OpenGLPolygonalModel<T>::EnableVertexColors ( bool b )
00355 {
00356     if ( m_svVertexColors.size() == 0 ) m_bEnableVertexColor = false;
00357     else                                m_bEnableVertexColor = b;
00358     return m_bEnableVertexColor;
00359 }
00360 //-----------------------------------------------------------------------------
00361 #endif//TAPs_ENABLE_FACE_VERTEX_COLOR
00362 //=============================================================================
00363 
00364 
00365 
00366 
00367 
00368 
00369 
00370 
00371 
00372 
00373 
00374 //=============================================================================
00375 #ifdef  TAPs_RENDER_BY_GLSL_DS_FACE_VERTEX
00376 //-----------------------------------------------------------------------------
00377 template <typename T>
00378 void OpenGLPolygonalModel<T>::DrawGLSLWithDSFaceVertex_RGB ( GLenum drawMode )
00379 {
00380     //static bool isFirst = true;
00381 
00382     //assert( ShaderProgram );
00383     GlobalGLSLShaderPool::GetShaderProgram( ShaderName )->BeginGLSL();
00384     GlobalGLSLShaderPool::SetShaderParameters( ShaderName );
00385 
00386     glPushAttrib( GL_ENABLE_BIT | GL_ENABLE_BIT );
00387     glEnable( GL_COLOR_MATERIAL );
00388 
00389     if ( isFacetShading ) {
00390         // Draw the object
00391         //glEnable( GL_TEXTURE_2D );
00392         for ( int i = 0; i < m_iNoFaces; i++ )
00393         {
00394             /*
00395             // Submaterial supported by .ASE
00396             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00397             int matID = m_prFace[i].GetMaterialID();
00398             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00399                 this->submaterials[ matID ]->ApplyMaterial();
00400             }
00401             #endif//TAPs_SUPPORT_ASE_FORMAT
00402             //*/
00403 
00404             glBegin( drawMode );
00405             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00406             {
00407                 // Draw texture
00408                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00409                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00410                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00411                 }
00412                 // Normal of the face
00413                 glNormal3f ( static_cast<float>( m_prFace[i].GetNormal().GetX() ), 
00414                              static_cast<float>( m_prFace[i].GetNormal().GetY() ), 
00415                              static_cast<float>( m_prFace[i].GetNormal().GetZ() ) );
00416 
00417                 /*
00418                 // Vertex color of the face
00419                 float VC[3];
00420                 GetVertexColor( m_prFace[i].GetVertexColorNo( j ), &VC[0], &VC[1], &VC[2] );
00421                 glColor3f ( VC[0], VC[1], VC[2] );
00422                 //*/
00423 
00424                 // Draw the vertex
00425                 glVertex3f ( 
00426                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00427                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00428                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00429             }
00430             glEnd();
00431         }
00432         //glDisable( GL_TEXTURE_2D );
00433     }
00434     else {
00435         // Draw the object
00436         //glEnable( GL_TEXTURE_2D );
00437         for ( int i = 0; i < m_iNoFaces; i++ )
00438         {
00439             /*
00440             // Submaterial supported by .ASE
00441             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00442             int matID = m_prFace[i].GetMaterialID();
00443             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00444                 this->submaterials[ matID ]->ApplyMaterial();
00445             }
00446             #endif//TAPs_SUPPORT_ASE_FORMAT
00447             //*/
00448 
00449             glBegin( drawMode );
00450             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00451             {
00452                 // Draw texture
00453                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00454                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00455                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00456                 }
00457                 // Normal of the vertex
00458                 glNormal3f ( static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 
00459                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 
00460                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 
00461 
00462                 //if ( isFirst ) {
00463                 //  std::cout << "Face# " << i << " V# " << j << ":\t" << m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal() << "\n";
00464                 //}
00465 
00466                 /*
00467                 // Vertex color of the face
00468                 float VC[3];
00469                 GetVertexColor( m_prFace[i].GetVertexColorNo( j ), &VC[0], &VC[1], &VC[2] );
00470                 glColor3f ( VC[0], VC[1], VC[2] );
00471                 //*/
00472 
00473                 // Draw the vertex
00474                 glVertex3f ( 
00475                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00476                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00477                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00478             }
00479             glEnd();
00480         }
00481         //glDisable( GL_TEXTURE_2D );
00482     }
00483 
00484     glPopAttrib();
00485 
00486     //isFirst = false;
00487     
00488     // Draw AABB Bounding Box
00489     //DrawBoundingAABB();
00490     //DrawBoundingEllipsoid();
00491     //DrawBoundingSphere();
00492 
00493     GlobalGLSLShaderPool::GetShaderProgram( ShaderName )->EndGLSL();
00494 }
00495 //-----------------------------------------------------------------------------
00496 template <typename T>
00497 void OpenGLPolygonalModel<T>::DrawGLSLWithDSFaceVertex_RGBA ( GLenum drawMode )
00498 {
00499     //static bool isFirst = true;
00500 
00501     //assert( ShaderProgram );
00502     GlobalGLSLShaderPool::GetShaderProgram( ShaderName )->BeginGLSL();
00503     GlobalGLSLShaderPool::SetShaderParameters( ShaderName );
00504 
00505     glPushAttrib( GL_ENABLE_BIT | GL_ENABLE_BIT );
00506     glEnable( GL_COLOR_MATERIAL );
00507 
00508     if ( isFacetShading ) {
00509         // Draw the object
00510         //glEnable( GL_TEXTURE_2D );
00511         for ( int i = 0; i < m_iNoFaces; i++ )
00512         {
00513             /*
00514             // Submaterial supported by .ASE
00515             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00516             int matID = m_prFace[i].GetMaterialID();
00517             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00518                 this->submaterials[ matID ]->ApplyMaterial();
00519             }
00520             #endif//TAPs_SUPPORT_ASE_FORMAT
00521             //*/
00522 
00523             glBegin( drawMode );
00524             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00525             {
00526                 // Draw texture
00527                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00528                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00529                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00530                 }
00531                 // Normal of the face
00532                 glNormal3f ( static_cast<float>( m_prFace[i].GetNormal().GetX() ), 
00533                              static_cast<float>( m_prFace[i].GetNormal().GetY() ), 
00534                              static_cast<float>( m_prFace[i].GetNormal().GetZ() ) );
00535 
00536                 /*
00537                 // Vertex color of the face
00538                 float VC[4];
00539                 GetVertexColor( m_prFace[i].GetVertexColorNo( j ), &VC[0], &VC[1], &VC[2], &VC[3] );
00540                 glColor4f ( VC[0], VC[1], VC[2], VC[3] );
00541                 //*/
00542 
00543                 // Draw the vertex
00544                 glVertex3f ( 
00545                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00546                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00547                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00548             }
00549             glEnd();
00550         }
00551         //glDisable( GL_TEXTURE_2D );
00552     }
00553     else {
00554         // Draw the object
00555         //glEnable( GL_TEXTURE_2D );
00556         for ( int i = 0; i < m_iNoFaces; i++ )
00557         {
00558             /*
00559             // Submaterial supported by .ASE
00560             #ifdef  TAPs_SUPPORT_ASE_FORMAT
00561             int matID = m_prFace[i].GetMaterialID();
00562             if ( matID < static_cast<int>( this->submaterials.size() ) ) {
00563                 this->submaterials[ matID ]->ApplyMaterial();
00564             }
00565             #endif//TAPs_SUPPORT_ASE_FORMAT
00566             //*/
00567 
00568             glBegin( drawMode );
00569             for ( int j = 0; j < m_prFace[i].GetNoVertices(); ++j )
00570             {
00571                 // Draw texture
00572                 if ( m_prFace[i].GetNoTexCoords() != 0 ) {
00573                     glTexCoord2f( static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2 ) ), 
00574                                 static_cast<float>( m_prFace[i].GetTexCoordHalfNo( j*2+1 ) ) );
00575                 }
00576                 // Normal of the vertex
00577                 glNormal3f ( static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[0] ), 
00578                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[1] ), 
00579                              static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal()[2] ) ); 
00580 
00581                 //if ( isFirst ) {
00582                 //  std::cout << "Face# " << i << " V# " << j << ":\t" << m_prVertex[ m_prFace[i].GetVertexNo( j ) ].GetNormal() << "\n";
00583                 //}
00584 
00585                 /*
00586                 // Vertex color of the face
00587                 float VC[4];
00588                 GetVertexColor( m_prFace[i].GetVertexColorNo( j ), &VC[0], &VC[1], &VC[2], &VC[3] );
00589                 glColor4f ( VC[0], VC[1], VC[2], VC[3] );
00590                 //*/
00591 
00592                 // Draw the vertex
00593                 glVertex3f ( 
00594                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][0] ), 
00595                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][1] ), 
00596                     static_cast<float>( m_prVertex[ m_prFace[i].GetVertexNo( j ) ][2] ) );
00597             }
00598             glEnd();
00599         }
00600         //glDisable( GL_TEXTURE_2D );
00601     }
00602 
00603     glPopAttrib();
00604 
00605     //isFirst = false;
00606     
00607     // Draw AABB Bounding Box
00608     //DrawBoundingAABB();
00609     //DrawBoundingEllipsoid();
00610     //DrawBoundingSphere();
00611 
00612     GlobalGLSLShaderPool::GetShaderProgram( ShaderName )->EndGLSL();
00613 }
00614 //-----------------------------------------------------------------------------
00615 #endif//TAPs_RENDER_BY_GLSL_DS_FACE_VERTEX
00616 //=============================================================================
00617 
00618 
00619 
00620 
00621 
00622 
00623 
00624 
00625 
00626 //-----------------------------------------------------------------------------
00627 //=============================================================================
00628 END_NAMESPACE_TAPs__OpenGL
00629 //-----------------------------------------------------------------------------
00630 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00631 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines