#include <TAPsReadObj.hpp>
Static Public Member Functions | |
| static bool | ReadFile (const char *fileName, OpenGL::HalfEdgeModel< T > *const prModel) |
| static bool | ReadFile (const char *fileName, OpenGL::XPolygonalModel< T > *const prModel) |
| static bool | ReadFile (const char *fileName, OpenGL::PolygonalModel< T > *const prModel) |
Static Private Member Functions | |
| static void | ProcessLineFace_f (char *line, OpenGL::MeshModel< T > *const prModel) |
| static void | ProcessLineGroupName_g (char *line, OpenGL::MeshModel< T > *const prModel) |
| static void | ProcessLineMaterialLibrary_mtllib (char *line, OpenGL::MeshModel< T > *const prModel) |
| static void | ProcessLineObjectName_o (char *line, OpenGL::MeshModel< T > *const prModel) |
| static void | ProcessLineUseMaterialName_usemtl (char *line, OpenGL::MeshModel< T > *const prModel) |
| static void | ProcessLineVertexNormal_vn (char *line, OpenGL::MeshModel< T > *const prModel) |
| static void | ProcessLineVertexPosition_v (char *line, OpenGL::MeshModel< T > *const prModel) |
| static void | ProcessLineVertexTextureCoordinates_vt (char *line, OpenGL::MeshModel< T > *const prModel) |
| static bool | ReadDataFile (const char *fileName, OpenGL::MeshModel< T > *const prModel) |
| static void | SetModelProperties (OpenGL::MeshModel< T > *const prModel) |
| static void | SetupModel (OpenGL::HalfEdgeModel< T > *const prModel) |
| static void | SetupModel (OpenGL::XPolygonalModel< T > *const prModel) |
| static void | SetupModel (OpenGL::PolygonalModel< T > *const prModel) |
Static Private Attributes | |
| static int | faceNo = 0 |
| static FILE * | fileIn = NULL |
| static MeshData< T > | meshData |
| static int | vertexNormalNo = 0 |
| static int | vertexPositionNo = 0 |
| static int | vertexTextureCoordNo = 0 |
Friends | |
| class | ReadModels< T > |
Definition at line 52 of file TAPsReadObj.hpp.
| void ReadObj< T >::ProcessLineFace_f | ( | char * | line, | |
| OpenGL::MeshModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Face (f) assigns a face.
A group composed of an index of vertex position, coordinates, and normal represent one vertex of the face.
There is no space between indices and slashes
Support format:
( v v ... )
( v/vt v/vt ... )
( v v ... )
( v//vn v//vn ... )
( v/vt/vn v/vt/vn ... )
Example (a tri face): f v_1/vt_1/vn_1 v_2/vt_2/vn_2 v_3/vt_3/vn_3
Definition at line 438 of file TAPsReadObj.cpp.
00440 { 00441 /* 00442 // DEBUG 00443 char debugLine[256]; 00444 strcpy( debugLine, line ); 00445 //*/ 00446 00447 // Examples 00448 // f 111/49/111 110/129/110 109/102/109 108/30/108 (a quad) 00449 // f 15//15 16//16 8//8 (a triangle without vt) 00450 //--------------------------------------------------------------- 00451 std::vector< int > idxV, idxVT, idxVN; 00452 //--------------------------------------------------------------- 00453 char *delimSpaces = "\t \n"; // tab, space, new line 00454 char *token = NULL; 00455 char *vertexGroup = NULL; 00456 char *firstSlash = NULL; 00457 char *secondSlash = NULL; 00458 int tokenLen = 0; 00459 int len = 0; 00460 char *end; 00461 int numberOfVertices = 0; 00462 //--------------------------------------------------------------- 00463 token = strtok( line, delimSpaces ); // token is now 'f' 00464 token = strtok( '\0', delimSpaces ); // vertex properties (v/vt/vn) 00465 while ( token ) { 00466 tokenLen = static_cast<int>( strlen( token ) ); 00467 //if ( tokenLen <= 0 ) return; 00468 //------------------------------------------------- 00469 // Check format: 00470 // ( v v ... ) 00471 // ( v/vt v/vt ... ) 00472 // ( v//vn v//vn ... ) 00473 // ( v/vt/vn v/vt/vn ... ) 00474 firstSlash = strchr( token, '/' ); 00475 //--------------------------------------- 00476 // Format: v v ... 00477 if ( firstSlash == NULL ) { 00478 idxVT.push_back( -1 ); 00479 idxVN.push_back( -1 ); 00480 idxV.push_back( static_cast<int>( strtol( token, &end, 10 ) ) - 1 ); 00481 } 00482 //--------------------------------------- 00483 // Format: v/vt v/vt ... 00484 else { 00485 secondSlash = strrchr( token, '/' ); 00486 if ( secondSlash == firstSlash ) { 00487 idxVN.push_back( -1 ); 00488 int i = 0; 00489 int n = 0; 00490 char vStr[16]; 00491 //----------------- 00492 // v 00493 for ( ; n < firstSlash - token; ++i, ++n ) { 00494 vStr[n] = token[i]; 00495 } 00496 vStr[n] = '\0'; // null terminated 00497 idxV.push_back( static_cast<int>( strtol( vStr, &end, 10 ) ) - 1 ); 00498 //----------------- 00499 // vt 00500 for ( ++i, n = 0; n < token + tokenLen - firstSlash; ++i, ++n ) { 00501 vStr[n] = token[i]; 00502 } 00503 vStr[n] = '\0'; // null terminated 00504 idxVT.push_back( static_cast<int>( strtol( vStr, &end, 10 ) ) - 1 ); 00505 } 00506 //--------------------------------------- 00507 // Format: v//vn v//vn ... 00508 else { 00509 len = secondSlash - firstSlash; 00510 if ( len == 1 ) { 00511 idxVT.push_back( -1 ); 00512 int i = 0; 00513 int n = 0; 00514 char vStr[16]; 00515 //----------------- 00516 // v 00517 for ( ; n < firstSlash - token; ++i, ++n ) { 00518 vStr[n] = token[i]; 00519 } 00520 vStr[n] = '\0'; // null terminated 00521 idxV.push_back( static_cast<int>( strtol( vStr, &end, 10 ) ) - 1 ); 00522 //----------------- 00523 // vn 00524 for ( i+=2, n = 0; n < token + tokenLen - secondSlash; ++i, ++n ) { 00525 vStr[n] = token[i]; 00526 } 00527 vStr[n] = '\0'; // null terminated 00528 idxVN.push_back( static_cast<int>( strtol( vStr, &end, 10 ) ) - 1 ); 00529 } 00530 //--------------------------------------- 00531 // Format: v/vt/vn v/vt/vn ... 00532 else { 00533 int i = 0; 00534 int n = 0; 00535 char vStr[16]; 00536 //----------------- 00537 // v 00538 for ( ; n < firstSlash - token; ++i, ++n ) { 00539 vStr[n] = token[i]; 00540 } 00541 vStr[n] = '\0'; // null terminated 00542 idxV.push_back( static_cast<int>( strtol( vStr, &end, 10 ) ) - 1 ); 00543 //----------------- 00544 // vt 00545 for ( ++i, n = 0; n < secondSlash - firstSlash - 1; ++i, ++n ) { 00546 vStr[n] = token[i]; 00547 } 00548 vStr[n] = '\0'; // null terminated 00549 idxVT.push_back( static_cast<int>( strtol( vStr, &end, 10 ) ) - 1 ); 00550 //----------------- 00551 // vn 00552 for ( ++i, n = 0; n < token + tokenLen - secondSlash; ++i, ++n ) { 00553 vStr[n] = token[i]; 00554 } 00555 vStr[n] = '\0'; // null terminated 00556 idxVN.push_back( static_cast<int>( strtol( vStr, &end, 10 ) ) - 1 ); 00557 } 00558 } 00559 } 00560 //------------------------------------------------- 00561 ++numberOfVertices; 00562 token = strtok( '\0', delimSpaces ); // vertex properties (v/vt/vn) 00563 //token = strtok( line, delimSpaces ); // vertex properties (v/vt/vn) 00564 } 00565 //--------------------------------------------------------------- 00566 Face<T> * face = new Face<T>(); 00567 //----------------------------------------------------- 00568 // Vertices of Face 00569 /* 00570 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00571 std::cout << "Face: Number of vertices: " << numberOfVertices << "\n"; 00572 #endif 00573 //*/ 00574 00575 /* 00576 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00577 char buf[32]; 00578 std::string str = "f"; 00579 for ( int i = 0; i < numberOfVertices; ++i ) { 00580 itoa( idxV[i] + 1, buf, 10 ); 00581 str = str + " " + buf; 00582 if ( idxVT[0] != -1 ) { 00583 itoa( idxVT[i] + 1, buf, 10 ); 00584 str = str + "/" + buf; 00585 if ( idxVN[0] != -1 ) { 00586 itoa( idxVN[i] + 1, buf, 10 ); 00587 str = str + "/" + buf; 00588 } 00589 } 00590 else { 00591 if ( idxVN[0] != -1 ) { 00592 itoa( idxVN[i] + 1, buf, 10 ); 00593 str = str + "//" + buf; 00594 } 00595 } 00596 } 00597 if ( strncmp( debugLine, str.c_str(), strlen( str.c_str() ) ) != 0 ) { 00598 std::cout << "Different!\n"; 00599 std::cout << debugLine; 00600 std::cout << str << "\n"; 00601 std::cout << "Ori Len: " << static_cast<int>( strlen( debugLine ) ) << "\n"; 00602 std::cout << "Str Len: " << static_cast<int>( strlen( str.c_str() ) ) << "\n"; 00603 std::cout << "\n"; 00604 } 00605 #endif 00606 //*/ 00607 00608 face->SetNoVertices( numberOfVertices ); 00609 for ( int i = 0; i < numberOfVertices; ++i ) 00610 face->SetVertexNo( i, idxV[i] ); 00611 //----------------------------------------------------- 00612 // Normals of Vertices of Face 00613 if ( idxVN[ 0 ] != -1 ) { 00614 for ( int i = 0; i < numberOfVertices; ++i ) 00615 meshData.VertexList[ face->GetVertexNo( i ) ]->SetNormal( meshData.NormalList[ idxVN[i] ] ); 00616 } 00617 //----------------------------------------------------- 00618 // Texture Coordinates of Vertices of Face 00619 if ( idxVT[ 0 ] != -1 ) { 00620 face->SetNoTexCoords( numberOfVertices ); 00621 T s, t; 00622 for ( int i = 0; i < numberOfVertices; ++i ) { 00623 meshData.TextureCoor2DList[idxVT[i]].GetXY( s, t ); 00624 face->SetTexCoordNo( i, s, t ); 00625 } 00626 } 00627 //----------------------------------------------------- 00628 meshData.FaceList.push_back( face ); 00629 //--------------------------------------------------------------- 00630 /* 00631 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00632 std::cout << "Face# " << faceNo << ":\t" << *face << "\n"; 00633 #endif 00634 //*/ 00635 ++faceNo; 00636 }
| void ReadObj< T >::ProcessLineGroupName_g | ( | char * | line, | |
| OpenGL::MeshModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Group name (g) assigns a name to the elements that follow it.
Multiple group names are allowed.
If there are multiple groups, the elemetns that follows belong to all groups.
Example: g group_name1 group_name2 ...
Definition at line 346 of file TAPsReadObj.cpp.
| void ReadObj< T >::ProcessLineMaterialLibrary_mtllib | ( | char * | line, | |
| OpenGL::MeshModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Material library (mtllib) specifies the material library file to be searched for a material name.
Multiple filenames can be used with the material library statement.
Example: mtllib mat_lib_file1 mat_lib_file2 ...
Definition at line 354 of file TAPsReadObj.cpp.
| void ReadObj< T >::ProcessLineObjectName_o | ( | char * | line, | |
| OpenGL::MeshModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Object name (o) assigns a name to an entire object in a single file.
Example: o object_name
Definition at line 338 of file TAPsReadObj.cpp.
| void ReadObj< T >::ProcessLineUseMaterialName_usemtl | ( | char * | line, | |
| OpenGL::MeshModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Use material name (usemtl) specifies the material name for the elements that follow it.
If a material name is not specified, a default material or default model color is used.
Example: usemtl material_name
Definition at line 362 of file TAPsReadObj.cpp.
| void ReadObj< T >::ProcessLineVertexNormal_vn | ( | char * | line, | |
| OpenGL::MeshModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Vertex Normal (vn) assigns normal of a vertex.
Example: vn i j k
Definition at line 416 of file TAPsReadObj.cpp.
00418 { 00419 // Example 00420 // vn 0.855148 0.250195 -0.454009 00421 float i, j, k; 00422 char acNode[4]; 00423 sscanf( line, "%s %f %f %f", acNode, &i, &j, &k ); 00424 meshData.NormalList.push_back( Vector3<T>( i, j, k ) ); 00425 //--------------------------------------------------------------- 00426 /* 00427 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00428 std::cout << "Normal# " << vertexNormalNo << ":\t" << i << "\t" << j << "\t" << k << "\n"; 00429 #endif 00430 //*/ 00431 ++vertexNormalNo; 00432 }
| void ReadObj< T >::ProcessLineVertexPosition_v | ( | char * | line, | |
| OpenGL::MeshModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Vertex Position (v) assigns a position of the vertex.
Currently support only x, y, and z components and ignore w component.
Example: v x y z w
Definition at line 372 of file TAPsReadObj.cpp.
00374 { 00375 // Example 00376 // v 0.279370 157.247177 -5.951185 00377 float x, y, z; 00378 char acNode[4]; 00379 sscanf( line, "%s %f %f %f", acNode, &x, &y, &z ); 00380 meshData.VertexList.push_back( new Vertex<T>( x, y, z ) ); 00381 //--------------------------------------------------------------- 00382 /* 00383 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00384 std::cout << "Position# " << vertexPositionNo << ":\t" << x << "\t" << y << "\t" << z << "\n"; 00385 #endif 00386 //*/ 00387 ++vertexPositionNo; 00388 }
| void ReadObj< T >::ProcessLineVertexTextureCoordinates_vt | ( | char * | line, | |
| OpenGL::MeshModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Vertex Texture Coordinates (vt) assigns texture coordinates of a vertex.
Currently support only s and t and ignore p and q components.
Example: vt s t p q
Definition at line 394 of file TAPsReadObj.cpp.
00396 { 00397 // Example 00398 // vt 0.2 0.5 00399 float s, t; 00400 char acNode[4]; 00401 sscanf( line, "%vt %f %f", acNode, &s, &t ); 00402 meshData.TextureCoor2DList.push_back( Vector2<T>( s, t ) ); 00403 //--------------------------------------------------------------- 00404 /* 00405 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00406 std::cout << "TextureCoord# " << vertexTextureCoordNo << ":\t" << s << "\t" << t << "\n"; 00407 #endif 00408 //*/ 00409 ++vertexTextureCoordNo; 00410 }
| bool ReadObj< T >::ReadDataFile | ( | const char * | fileName, | |
| OpenGL::MeshModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Set Model Properties
E.g. its numbers of vertices and faces.
Definition at line 77 of file TAPsReadObj.cpp.
00079 { 00080 //--------------------------------------------------------------- 00081 // Open the input file 00082 00083 std::cout << "Open the input file: " << fileName << std::endl; 00084 00085 fileIn = fopen( fileName, "r" ); 00086 if ( !fileIn ) { 00087 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00088 std::perror( fileName ); 00089 #endif 00090 return false; 00091 } 00092 //--------------------------------------------------------------- 00093 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00094 std::cout << "START READING " << fileName << "\n"; 00095 #endif 00096 //--------------------------------------------------------------- 00097 // Initialization 00098 faceNo = 0; 00099 vertexPositionNo = 0; 00100 vertexTextureCoordNo = 0; 00101 vertexNormalNo = 0; 00102 meshData.ClearAll(); 00103 //--------------------------------------------------------------- 00104 // Read in each line, check what its contents are, 00105 // and pass it out to the relevant decoder function 00106 char line[256]; 00107 fgets( line, 256, fileIn ); 00108 do { 00109 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00110 //std::cout << "I/P Line: " << line; 00111 #endif 00112 //------------------------------------------------- 00113 // Vertex Normal 00114 if ( !strncmp( line, "vn", strlen( "vn" ) ) ) 00115 ProcessLineVertexNormal_vn( line, prModel ); 00116 //------------------------------------------------- 00117 // Vertex Texture Coordinates 00118 else if ( !strncmp( line, "vt", strlen( "vt" ) ) ) 00119 ProcessLineVertexTextureCoordinates_vt( line, prModel ); 00120 //------------------------------------------------- 00121 // Vertex Position 00122 else if ( !strncmp( line, "v", strlen( "v" ) ) ) 00123 ProcessLineVertexPosition_v( line, prModel ); 00124 //------------------------------------------------- 00125 // Face 00126 else if ( !strncmp( line, "f", strlen( "f" ) ) ) 00127 ProcessLineFace_f( line, prModel ); 00128 //------------------------------------------------- 00129 // Group Name 00130 else if ( !strncmp( line, "g", strlen( "g" ) ) ) 00131 ProcessLineGroupName_g( line, prModel ); 00132 //------------------------------------------------- 00133 // Use Material Name 00134 else if ( !strncmp( line, "usemtl", strlen( "usemtl" ) ) ) 00135 ProcessLineUseMaterialName_usemtl( line, prModel ); 00136 //------------------------------------------------- 00137 // Use Material Name 00138 else if ( !strncmp( line, "mtllib", strlen( "mtllib" ) ) ) 00139 ProcessLineMaterialLibrary_mtllib( line, prModel ); 00140 //------------------------------------------------- 00141 // Object Name 00142 else if ( !strncmp( line, "o", strlen( "o" ) ) ) 00143 ProcessLineObjectName_o( line, prModel ); 00144 //------------------------------------------------- 00145 fgets( line, 256, fileIn ); 00146 } while ( !feof( fileIn ) ); 00147 //--------------------------------------------------------------- 00148 fclose( fileIn ); // close the input file 00149 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00150 std::cout << "END READING " << fileName << "\n"; 00151 #endif 00152 return true; 00153 }
| bool ReadObj< T >::ReadFile | ( | const char * | fileName, | |
| OpenGL::HalfEdgeModel< T > *const | prModel | |||
| ) | [inline, static] |
Definition at line 61 of file TAPsReadObj.cpp.
00063 { 00064 if ( !ReadDataFile( fileName, prModel ) ) return false; 00065 //--------------------------------------------------------------- 00066 SetupModel( prModel ); 00067 prModel->GetMaterial()->ApplyMaterial(); 00068 //--------------------------------------------------------------- 00069 meshData.ClearAll(); 00070 return true; 00071 }
| bool ReadObj< T >::ReadFile | ( | const char * | fileName, | |
| OpenGL::XPolygonalModel< T > *const | prModel | |||
| ) | [inline, static] |
Definition at line 47 of file TAPsReadObj.cpp.
00049 { 00050 if ( !ReadDataFile( fileName, prModel ) ) return false; 00051 //--------------------------------------------------------------- 00052 SetupModel( prModel ); 00053 prModel->GetMaterial()->ApplyMaterial(); 00054 //--------------------------------------------------------------- 00055 meshData.ClearAll(); 00056 return true; 00057 }
| bool ReadObj< T >::ReadFile | ( | const char * | fileName, | |
| OpenGL::PolygonalModel< T > *const | prModel | |||
| ) | [inline, static] |
Definition at line 33 of file TAPsReadObj.cpp.
00035 { 00036 if ( !ReadDataFile( fileName, prModel ) ) return false; 00037 //--------------------------------------------------------------- 00038 SetupModel( prModel ); 00039 prModel->GetMaterial()->ApplyMaterial(); 00040 //--------------------------------------------------------------- 00041 meshData.ClearAll(); 00042 return true; 00043 }
| void ReadObj< T >::SetModelProperties | ( | OpenGL::MeshModel< T > *const | prModel | ) | [inline, static, private] |
Definition at line 157 of file TAPsReadObj.cpp.
00158 { 00159 prModel->SetNumVertices( static_cast<int>( meshData.VertexList.size() ) ); 00160 prModel->SetNumFaces( static_cast<int>( meshData.FaceList.size() ) ); 00161 00162 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00163 std::cout << "Number of Vertices: " << prModel->GetNumVertices() << "\n"; 00164 std::cout << "Number of Faces: " << prModel->GetNumFaces() << "\n"; 00165 #endif 00166 }
| void ReadObj< T >::SetupModel | ( | OpenGL::HalfEdgeModel< T > *const | prModel | ) | [inline, static, private] |
Definition at line 228 of file TAPsReadObj.cpp.
00229 { 00230 SetModelProperties( prModel ); 00231 //--------------------------------------------------------------- 00232 int iNumVertices = prModel->GetNumVertices(); 00233 // Allocate memory for vertices 00234 HelpCreateHalfEdgeModel<T>::vertexList = 00235 new HEVertex<T>*[ iNumVertices ]; 00236 HelpCreateHalfEdgeModel<T>::vertexRingList = 00237 new DS::HashTableBySTLVector<int>( iNumVertices ); 00238 HelpCreateHalfEdgeModel<T>::halfEdgeRingList = 00239 new DS::HashTableBySTLVector< HEHalfEdge<T> * >( iNumVertices ); 00240 //--------------------------------------------------------------- 00241 // For Each Vertex 00242 for ( int i = 0; i < iNumVertices; ++i ) { 00243 // Put created vertex in vertexList for look up later 00244 HelpCreateHalfEdgeModel<T>::vertexList[ i ] = 00245 new HEVertex<T>( 00246 meshData.VertexList[ i ]->GetPosition(), 00247 meshData.VertexList[ i ]->GetNormal() 00248 #ifdef TAPs_USE_DATA_POOL 00249 , prModel->GetArrayOfVertexPositions().GetAddressOfDataNumber( i ) 00250 , prModel->GetArrayOfVertexNormals().GetAddressOfDataNumber( i ) 00251 #endif//TAPs_USE_DATA_POOL 00252 ); 00253 // Put created vertex in vertexList of the model 00254 prModel->GetVertexList()->Append( 00255 HelpCreateHalfEdgeModel<T>::vertexList[ i ] ); 00256 } 00257 //--------------------------------------------------------------- 00258 // For Each Face 00259 for ( int i = 0; i < prModel->GetNumFaces(); ++i ) { 00260 //------------------------------------------------- 00261 HEFace<T> * heFace = new HEFace<T>(); 00262 prModel->GetFaceList()->Append( heFace ); 00263 std::vector< HEHalfEdge<T> * > heHalfEdge; 00264 int v = 0; 00265 //----------------------------------- 00266 // (CCW) Record v0 to v1, v1 to v2, ... in vertexRingList 00267 // put v1 in bucket v0 00268 HelpCreateHalfEdgeModel<T>::vertexRingList->Insert( 00269 meshData.FaceList[i]->GetVertexNo( 1 ), 00270 meshData.FaceList[i]->GetVertexNo( 0 ) ); 00271 //----------------------------------- 00272 // Create and Set half-edge 00273 heHalfEdge.push_back( HelpCreateHalfEdgeModel<T>::CreateHalfEdgeFrom( 00274 HelpCreateHalfEdgeModel<T>::vertexList[ meshData.FaceList[i]->GetVertexNo( 0 ) ], 00275 HelpCreateHalfEdgeModel<T>::vertexList[ meshData.FaceList[i]->GetVertexNo( 1 ) ], 00276 heFace ) ); 00277 //----------------------------------- 00278 // Record half-edges in halfEdgeRingList 00279 HelpCreateHalfEdgeModel<T>::halfEdgeRingList->Insert( 00280 heHalfEdge[0], meshData.FaceList[i]->GetVertexNo( 0 ) ); // put in bucket v0 00281 //----------------------------------- 00282 // Set incident half-edge of this face 00283 heFace->IncidentHalfEdge( heHalfEdge[ 0 ] ); 00284 //----------------------------------- 00285 for ( v = 1; v < meshData.FaceList[i]->GetNumVertices() - 1; ++v ) { 00286 //----------------------------------- 00287 // put v+1 in bucket v 00288 HelpCreateHalfEdgeModel<T>::vertexRingList->Insert( 00289 meshData.FaceList[i]->GetVertexNo( v+1 ), 00290 meshData.FaceList[i]->GetVertexNo( v ) ); 00291 //----------------------------------- 00292 // Create and Set half-edge 00293 heHalfEdge.push_back( HelpCreateHalfEdgeModel<T>::CreateHalfEdgeFrom( 00294 HelpCreateHalfEdgeModel<T>::vertexList[ meshData.FaceList[i]->GetVertexNo( v ) ], 00295 HelpCreateHalfEdgeModel<T>::vertexList[ meshData.FaceList[i]->GetVertexNo( v+1 ) ], 00296 heFace, heHalfEdge[ v-1 ] ) ); // w/ prev ptr 00297 //----------------------------------- 00298 // Record half-edges in halfEdgeRingList 00299 HelpCreateHalfEdgeModel<T>::halfEdgeRingList->Insert( 00300 heHalfEdge[v], meshData.FaceList[i]->GetVertexNo( v ) ); // put in bucket v 00301 } 00302 //----------------------------------- 00303 // put v0 in bucket v 00304 HelpCreateHalfEdgeModel<T>::vertexRingList->Insert( 00305 meshData.FaceList[i]->GetVertexNo( 0 ), 00306 meshData.FaceList[i]->GetVertexNo( v ) ); 00307 //----------------------------------- 00308 // Create and Set half-edge 00309 heHalfEdge.push_back( HelpCreateHalfEdgeModel<T>::CreateHalfEdgeFrom( 00310 HelpCreateHalfEdgeModel<T>::vertexList[ meshData.FaceList[i]->GetVertexNo( v ) ], 00311 HelpCreateHalfEdgeModel<T>::vertexList[ meshData.FaceList[i]->GetVertexNo( 0 ) ], 00312 heFace, heHalfEdge[ v-1 ], heHalfEdge[ 0 ] ) ); // w/ prev and next ptrs 00313 //----------------------------------- 00314 // Record half-edges in halfEdgeRingList 00315 HelpCreateHalfEdgeModel<T>::halfEdgeRingList->Insert( 00316 heHalfEdge[v], meshData.FaceList[i]->GetVertexNo( v ) ); // put in bucket v0 00317 //----------------------------------- 00318 // (CCW) Record v0 to v1, v1 to v2, and v2 to v0 in vertexRingList 00319 // HelpCreateHalfEdgeModel<T>::vertexRingList->Insert( v1, v0 ); // put v1 in bucket v0 00320 // HelpCreateHalfEdgeModel<T>::vertexRingList->Insert( v2, v1 ); // put v2 in bucket v1 00321 // HelpCreateHalfEdgeModel<T>::vertexRingList->Insert( v0, v2 ); // put v0 in bucket v2 00322 //----------------------------------- 00323 // Record half-edges in halfEdgeRingList 00324 // HelpCreateHalfEdgeModel<T>::halfEdgeRingList->Insert( heHalfEdge0, v0 ); // put in bucket v0 00325 // HelpCreateHalfEdgeModel<T>::halfEdgeRingList->Insert( heHalfEdge1, v1 ); // put in bucket v1 00326 // HelpCreateHalfEdgeModel<T>::halfEdgeRingList->Insert( heHalfEdge2, v2 ); // put in bucket v2 00327 } 00328 //--------------------------------------------------------------- 00329 //--------------------------------------------------------------- 00330 HelpCreateHalfEdgeModel<T>::CreateHalfEdgeModel( prModel ); 00331 //*/ 00332 }
| void ReadObj< T >::SetupModel | ( | OpenGL::XPolygonalModel< T > *const | prModel | ) | [inline, static, private] |
Definition at line 200 of file TAPsReadObj.cpp.
00201 { 00202 SetModelProperties( prModel ); 00203 prModel->NewVertexListByNoVertices(); 00204 prModel->NewFaceListByNoFaces(); 00205 for ( int i = 0; i < prModel->GetNumVertices(); ++i ) { 00206 prModel->GetVertexList()[i].SetPosition( meshData.VertexList[i]->GetPosition() ); 00207 prModel->GetVertexList()[i].SetNormal( meshData.VertexList[i]->GetNormal() ); 00208 } 00209 for ( int i = 0; i < prModel->GetNumFaces(); ++i ) { 00210 prModel->GetFaceList()[i] = *meshData.FaceList[i]; 00211 } 00212 /* 00213 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00214 std::cout << "Number of Vertices: " << prModel->GetNumVertices() << "\n"; 00215 for ( int i = 0; i < prModel->GetNumVertices(); ++i ) { 00216 std::cout << "Vertex# " << prModel->GetVertexList()[i] << "\n"; 00217 } 00218 std::cout << "Number of Faces: " << prModel->GetNumFaces() << "\n"; 00219 for ( int i = 0; i < prModel->GetNumFaces(); ++i ) { 00220 std::cout << "Vertex# " << prModel->GetFaceList()[i] << "\n"; 00221 } 00222 #endif 00223 //*/ 00224 }
| void ReadObj< T >::SetupModel | ( | OpenGL::PolygonalModel< T > *const | prModel | ) | [inline, static, private] |
Definition at line 172 of file TAPsReadObj.cpp.
00173 { 00174 SetModelProperties( prModel ); 00175 prModel->NewVertexListByNoVertices(); 00176 prModel->NewFaceListByNoFaces(); 00177 for ( int i = 0; i < prModel->GetNumVertices(); ++i ) { 00178 prModel->GetVertexList()[i].SetPosition( meshData.VertexList[i]->GetPosition() ); 00179 prModel->GetVertexList()[i].SetNormal( meshData.VertexList[i]->GetNormal() ); 00180 } 00181 for ( int i = 0; i < prModel->GetNumFaces(); ++i ) { 00182 prModel->GetFaceList()[i] = *meshData.FaceList[i]; 00183 } 00184 /* 00185 #ifdef DEBUG_MESSAGE_TAPS_READ_OBJ_HPP 00186 std::cout << "Number of Vertices: " << prModel->GetNumVertices() << "\n"; 00187 for ( int i = 0; i < prModel->GetNumVertices(); ++i ) { 00188 std::cout << "Vertex# " << prModel->GetVertexList()[i] << "\n"; 00189 } 00190 std::cout << "Number of Faces: " << prModel->GetNumFaces() << "\n"; 00191 for ( int i = 0; i < prModel->GetNumFaces(); ++i ) { 00192 std::cout << "Vertex# " << prModel->GetFaceList()[i] << "\n"; 00193 } 00194 #endif 00195 //*/ 00196 }
friend class ReadModels< T > [friend] |
Definition at line 53 of file TAPsReadObj.hpp.
Definition at line 193 of file TAPsReadObj.hpp.
BEGIN_NAMESPACE_TAPs FILE * ReadObj< T >::fileIn = NULL [inline, static, private] |
Definition at line 192 of file TAPsReadObj.hpp.
Definition at line 197 of file TAPsReadObj.hpp.
int ReadObj< T >::vertexNormalNo = 0 [inline, static, private] |
Definition at line 196 of file TAPsReadObj.hpp.
int ReadObj< T >::vertexPositionNo = 0 [inline, static, private] |
Definition at line 194 of file TAPsReadObj.hpp.
int ReadObj< T >::vertexTextureCoordNo = 0 [inline, static, private] |
Definition at line 195 of file TAPsReadObj.hpp.
1.5.6