#include <TAPsReadTAPs.hpp>
Static Public Member Functions | |
| 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 | ProcessNodeFaces (char *line, OpenGL::XPolygonalModel< T > *const prModel) |
| static void | ProcessNodeFaces (char *line, OpenGL::PolygonalModel< T > *const prModel) |
| static void | ProcessNodeFormat (char *line, OpenGL::XPolygonalModel< T > *const prModel) |
| static void | ProcessNodeFormat (char *line, OpenGL::PolygonalModel< T > *const prModel) |
| static void | ProcessNodeImageTexture (char *line, OpenGL::XPolygonalModel< T > *const prModel) |
| static void | ProcessNodeMaterial (char *line, OpenGL::XPolygonalModel< T > *const prModel) |
| static void | ProcessNodeMaterial (char *line, OpenGL::PolygonalModel< T > *const prModel) |
| static void | ProcessNodeTextureCoordinates (char *line, OpenGL::XPolygonalModel< T > *const prModel) |
| static void | ProcessNodeTextureCoordinates (char *line, OpenGL::PolygonalModel< T > *const prModel) |
| static void | ProcessNodeVertices (char *line, OpenGL::XPolygonalModel< T > *const prModel) |
| static void | ProcessNodeVertices (char *line, OpenGL::PolygonalModel< T > *const prModel) |
Static Private Attributes | |
| static FILE * | fileIn = NULL |
Friends | |
| class | ReadModels< T > |
Definition at line 30 of file TAPsReadTAPs.hpp.
| void ReadTAPs< T >::ProcessNodeFaces | ( | char * | line, | |
| OpenGL::XPolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 450 of file TAPsReadTAPs.cpp.
00451 { 00452 //Example: 00453 // Faces 2 00454 // { 00455 // #nb_nodes node_0 node_1 ... node_(nb_nodes-1) 00456 // 4 0 1 2 3 00457 // 3 2 3 4 00458 // } 00459 00460 // Set number of faces 00461 int n = 0; 00462 char str[128]; 00463 sscanf( line, "%s%d", str, &n ); 00464 prModel->SetNoFaces( n ); 00465 prModel->NewFaceListByNoFaces(); 00466 00467 // Temp Variables 00468 char *delimiters = "\t "; 00469 char *token = NULL; 00470 char *end; 00471 int numberOfVertices; 00472 int vertexNo; 00473 00474 // For vertex info 00475 //vertexAt = new std::vector<int>[n]; 00476 00477 // Set each Xface 00478 n = 0; 00479 while ( str[0] != '{' ) { 00480 fgets( line, 128, fileIn ); 00481 sscanf( line, "%s", str ); 00482 } 00483 while ( str[0] != '}' && n < prModel->GetNoFaces() ) { 00484 fgets( line, 128, fileIn ); 00485 sscanf( line, "%s", str ); 00486 if ( str[0] == '#' ) continue; 00487 00488 // Get and set number of vertices 00489 token = strtok( line, delimiters ); 00490 numberOfVertices = static_cast<int>( strtol( token, &end, 10 ) ); 00491 prModel->GetFaceList()[n].SetNoVertices( numberOfVertices ); 00492 00493 // Set the Xface 00494 for ( int i = 0; i < numberOfVertices; ++i ) 00495 { 00496 token = strtok( '\0', delimiters ); 00497 vertexNo = static_cast<int>( strtol( token, &end, 10 ) ); 00498 prModel->GetFaceList()[n].SetVertexNo( i, vertexNo ); 00499 //vertexAt[vertexNo].push_back( i ); 00500 } 00501 ++n; 00502 } 00503 prModel->SetNoFaces( n ); 00504 }
| void ReadTAPs< T >::ProcessNodeFaces | ( | char * | line, | |
| OpenGL::PolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 392 of file TAPsReadTAPs.cpp.
00393 { 00394 //Example: 00395 // Faces 2 00396 // { 00397 // #nb_nodes node_0 node_1 ... node_(nb_nodes-1) 00398 // 4 0 1 2 3 00399 // 3 2 3 4 00400 // } 00401 00402 // Set number of faces 00403 int n = 0; 00404 char str[128]; 00405 sscanf( line, "%s%d", str, &n ); 00406 prModel->SetNoFaces( n ); 00407 prModel->NewFaceListByNoFaces(); 00408 00409 // Temp Variables 00410 char *delimiters = "\t "; 00411 char *token = NULL; 00412 char *end; 00413 int numberOfVertices; 00414 int vertexNo; 00415 00416 // For vertex info 00417 //vertexAt = new std::vector<int>[n]; 00418 00419 // Set each Xface 00420 n = 0; 00421 while ( str[0] != '{' ) { 00422 fgets( line, 128, fileIn ); 00423 sscanf( line, "%s", str ); 00424 } 00425 while ( str[0] != '}' && n < prModel->GetNoFaces() ) { 00426 fgets( line, 128, fileIn ); 00427 sscanf( line, "%s", str ); 00428 if ( str[0] == '#' ) continue; 00429 00430 // Get and set number of vertices 00431 token = strtok( line, delimiters ); 00432 numberOfVertices = static_cast<int>( strtol( token, &end, 10 ) ); 00433 prModel->GetFaceList()[n].SetNoVertices( numberOfVertices ); 00434 00435 // Set the Xface 00436 for ( int i = 0; i < numberOfVertices; ++i ) 00437 { 00438 token = strtok( '\0', delimiters ); 00439 vertexNo = static_cast<int>( strtol( token, &end, 10 ) ); 00440 prModel->GetFaceList()[n].SetVertexNo( i, vertexNo ); 00441 //vertexAt[vertexNo].push_back( i ); 00442 } 00443 ++n; 00444 } 00445 prModel->SetNoFaces( n ); 00446 }
| void ReadTAPs< T >::ProcessNodeFormat | ( | char * | line, | |
| OpenGL::XPolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 134 of file TAPsReadTAPs.cpp.
00135 { 00136 // Example: 00137 // Format TAPs_OpenGL_Model 00138 char s1[64], s2[64]; 00139 sscanf( line, "%s %s", s1, s2 ); 00140 if ( strncmp( s2, "TAPs_OpenGL_Model", strlen("TAPs_OpenGL_Model") ) ) { 00141 // Not "TAPs_OpenGL_Model" Format 00142 std::cerr << "The Input File is Not \"TAPs_OpenGL_Model\" Format!" << std::endl; 00143 exit ( EXIT_FAILURE ); 00144 } 00145 }
| void ReadTAPs< T >::ProcessNodeFormat | ( | char * | line, | |
| OpenGL::PolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 119 of file TAPsReadTAPs.cpp.
00120 { 00121 // Example: 00122 // Format TAPs_OpenGL_Model 00123 char s1[64], s2[64]; 00124 sscanf( line, "%s %s", s1, s2 ); 00125 if ( strncmp( s2, "TAPs_OpenGL_Model", strlen("TAPs_OpenGL_Model") ) ) { 00126 // Not "TAPs_OpenGL_Model" Format 00127 std::cerr << "The Input File is Not \"TAPs_OpenGL_Model\" Format!" << std::endl; 00128 exit ( EXIT_FAILURE ); 00129 } 00130 }
| void ReadTAPs< T >::ProcessNodeImageTexture | ( | char * | line, | |
| OpenGL::XPolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 645 of file TAPsReadTAPs.cpp.
00646 { 00647 // ImageTexture 00648 // { 00649 // fileName "../Textures/dg_gallbladder.bmp" 00650 // repeatS false 00651 // repeatT false 00652 // } 00653 char type[128]; 00654 char argument[128]; 00655 //char *end; 00656 double r = 0, g = 0, b = 0, a = 0; 00657 sscanf( line, "%s", type ); 00658 while ( type[0] != '{' ) { 00659 fgets( line, 128, fileIn ); 00660 sscanf( line, "%s", type ); 00661 } 00662 while ( type[0] != '}' ) { 00663 fgets( line, 128, fileIn ); 00664 sscanf( line, "%s %s", type, argument ); 00665 //std::cout << argument << std::endl; 00666 if ( type[0] == '#' ) continue; 00667 if ( !strncmp( type, "fileName", strlen("fileName") ) ) { 00668 prModel->SetImageFileName( argument ); 00669 prModel->m_pcImg = new BitmapImage(); 00670 if ( prModel->m_pcImg->LoadBitmapFile( argument ) ) { 00671 //prModel->EnableTexture(); 00672 } 00673 else { 00674 //prModel->m_pcImg.~BitmapImage(); 00675 std::cout << "ReadTAPs: Could not open the bitmap file!" << std::endl; 00676 } 00677 } 00678 else if ( !strncmp( type, "repeatS", strlen("repeatS") ) ) { 00679 //prModel->GetMaterial()->SetDiffuse( r, g, b, a ); 00680 } 00681 else if ( !strncmp( type, "repeatT", strlen("repeatT") ) ) { 00682 //prModel->GetMaterial()->SetSpecular( r, g, b, a ); 00683 } 00684 } 00685 }
| void ReadTAPs< T >::ProcessNodeMaterial | ( | char * | line, | |
| OpenGL::XPolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 214 of file TAPsReadTAPs.cpp.
00215 { 00216 //Example: 00217 // Material 00218 // { 00219 // ambient 0.1 0.2 0.3 1.0 00220 // diffuse 0.2 0.4 0.6 0.5 # alpha is the transparency 00221 // specular 0.81 0.82 0.83 1.0 00222 // shininess 1 00223 // emission 0 0 0 0 00224 // } 00225 char type[128]; 00226 char cr[32]; 00227 char cg[32]; 00228 char cb[32]; 00229 char ca[32]; 00230 char *end; 00231 double r = 0, g = 0, b = 0, a = 0; 00232 sscanf( line, "%s", type ); 00233 while ( type[0] != '{' ) { 00234 fgets( line, 128, fileIn ); 00235 sscanf( line, "%s", type ); 00236 } 00237 while ( type[0] != '}' ) { 00238 fgets( line, 128, fileIn ); 00239 sscanf( line, "%s %s %s %s %s", type, cr, cg, cb, ca ); 00240 if ( type[0] == '#' ) continue; 00241 if ( !strncmp( type, "ambient", strlen("ambient") ) ) { 00242 r = strtod( cr, &end ); 00243 g = strtod( cg, &end ); 00244 b = strtod( cb, &end ); 00245 a = strtod( ca, &end ); 00246 prModel->GetMaterial()->SetAmbient( r, g, b, a ); 00247 } 00248 else if ( !strncmp( type, "diffuse", strlen("diffuse") ) ) { 00249 r = strtod( cr, &end ); 00250 g = strtod( cg, &end ); 00251 b = strtod( cb, &end ); 00252 a = strtod( ca, &end ); 00253 prModel->GetMaterial()->SetDiffuse( r, g, b, a ); 00254 } 00255 else if ( !strncmp( type, "specular", strlen("specular") ) ) { 00256 r = strtod( cr, &end ); 00257 g = strtod( cg, &end ); 00258 b = strtod( cb, &end ); 00259 a = strtod( ca, &end ); 00260 prModel->GetMaterial()->SetSpecular( r, g, b, a ); 00261 } 00262 else if ( !strncmp( type, "shininess", strlen("shininess") ) ) { 00263 r = strtod( cr, &end ); 00264 prModel->GetMaterial()->SetShininess( r ); 00265 } 00266 else if ( !strncmp( type, "emission", strlen("emission") ) ) { 00267 r = strtod( cr, &end ); 00268 g = strtod( cg, &end ); 00269 b = strtod( cb, &end ); 00270 a = strtod( ca, &end ); 00271 prModel->GetMaterial()->SetEmission( r, g, b, a ); 00272 } 00273 } 00274 }
| void ReadTAPs< T >::ProcessNodeMaterial | ( | char * | line, | |
| OpenGL::PolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 150 of file TAPsReadTAPs.cpp.
00151 { 00152 //Example: 00153 // Material 00154 // { 00155 // ambient 0.1 0.2 0.3 1.0 00156 // diffuse 0.2 0.4 0.6 0.5 # alpha is the transparency 00157 // specular 0.81 0.82 0.83 1.0 00158 // shininess 1 00159 // emission 0 0 0 0 00160 // } 00161 char type[128]; 00162 char cr[32]; 00163 char cg[32]; 00164 char cb[32]; 00165 char ca[32]; 00166 char *end; 00167 double r = 0, g = 0, b = 0, a = 0; 00168 sscanf( line, "%s", type ); 00169 while ( type[0] != '{' ) { 00170 fgets( line, 128, fileIn ); 00171 sscanf( line, "%s", type ); 00172 } 00173 while ( type[0] != '}' ) { 00174 fgets( line, 128, fileIn ); 00175 sscanf( line, "%s %s %s %s %s", type, cr, cg, cb, ca ); 00176 if ( type[0] == '#' ) continue; 00177 if ( !strncmp( type, "ambient", strlen("ambient") ) ) { 00178 r = strtod( cr, &end ); 00179 g = strtod( cg, &end ); 00180 b = strtod( cb, &end ); 00181 a = strtod( ca, &end ); 00182 prModel->GetMaterial()->SetAmbient( r, g, b, a ); 00183 } 00184 else if ( !strncmp( type, "diffuse", strlen("diffuse") ) ) { 00185 r = strtod( cr, &end ); 00186 g = strtod( cg, &end ); 00187 b = strtod( cb, &end ); 00188 a = strtod( ca, &end ); 00189 prModel->GetMaterial()->SetDiffuse( r, g, b, a ); 00190 } 00191 else if ( !strncmp( type, "specular", strlen("specular") ) ) { 00192 r = strtod( cr, &end ); 00193 g = strtod( cg, &end ); 00194 b = strtod( cb, &end ); 00195 a = strtod( ca, &end ); 00196 prModel->GetMaterial()->SetSpecular( r, g, b, a ); 00197 } 00198 else if ( !strncmp( type, "shininess", strlen("shininess") ) ) { 00199 r = strtod( cr, &end ); 00200 prModel->GetMaterial()->SetShininess( r ); 00201 } 00202 else if ( !strncmp( type, "emission", strlen("emission") ) ) { 00203 r = strtod( cr, &end ); 00204 g = strtod( cg, &end ); 00205 b = strtod( cb, &end ); 00206 a = strtod( ca, &end ); 00207 prModel->GetMaterial()->SetEmission( r, g, b, a ); 00208 } 00209 } 00210 }
| void ReadTAPs< T >::ProcessNodeTextureCoordinates | ( | char * | line, | |
| OpenGL::XPolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 576 of file TAPsReadTAPs.cpp.
00577 { 00578 //Example: 00579 // Texture 2 00580 // { 00581 // # Texture Coordinates assigned at face vertices 00582 // # virtices s_0 t_0 s_1 t_1 s_2 t_2 s_3 t_3 00583 // 0 4 0.3166 0.6316 0.3441 0.6337 0.3537 0.6127 0.3225 0.6008 00584 // 1 4 0.3015 0.8142 0.3624 0.8094 0.3548 0.7738 0.3012 0.7804 00585 // } 00586 //Another Example: 00587 // Texture 1 00588 // { 00589 // # Texture Coordinates assigned at face vertices 00590 // # vertices s_0 t_0 s_1 t_1 s_2 t_2 s_3 t_3 00591 // 0 4 1 0 1 1 0 1 0 0 00592 // } 00593 00594 00595 // Set number of (2-D) texture coordinates 00596 int n = 0; 00597 char str[128]; 00598 sscanf( line, "%s%d", str, &n ); 00599 prModel->SetNoTexCoords( n ); 00600 00601 // Temp Variables 00602 char *delimiters = "\t "; 00603 char *token = NULL; 00604 char *end; 00605 int numberOfTexCoords; 00606 Real s, t; // texture coordinates 00607 int faceNo; 00608 00609 // Set texture coordinates of each Xface 00610 n = 0; 00611 while ( str[0] != '{' ) { 00612 fgets( line, 128, fileIn ); 00613 sscanf( line, "%s", str ); 00614 } 00615 while ( str[0] != '}' && n < prModel->GetNoTexCoords() ) { 00616 fgets( line, 128, fileIn ); 00617 sscanf( line, "%s", str ); 00618 if ( str[0] == '#' ) continue; 00619 00620 // Get number of face 00621 token = strtok( line, delimiters ); 00622 faceNo = static_cast<int>( strtol( token, &end, 10 ) ); 00623 // Get number of texture coordinates 00624 token = strtok( '\0', delimiters ); 00625 numberOfTexCoords = static_cast<int>( strtol( token, &end, 10 ) ); 00626 prModel->GetFaceList()[faceNo].SetNoTexCoords( numberOfTexCoords ); 00627 00628 // Set the texture coordinates 00629 for ( int i = 0; i < numberOfTexCoords; ++i ) 00630 { 00631 token = strtok( '\0', delimiters ); 00632 s = static_cast<Real>( strtod( token, &end ) ); 00633 token = strtok( '\0', delimiters ); 00634 t = static_cast<Real>( strtod( token, &end ) ); 00635 prModel->GetFaceList()[faceNo].SetTexCoordNo( i, s, t ); 00636 } 00637 ++n; 00638 } 00639 prModel->SetNoTexCoords( n ); 00640 }
| void ReadTAPs< T >::ProcessNodeTextureCoordinates | ( | char * | line, | |
| OpenGL::PolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 509 of file TAPsReadTAPs.cpp.
00510 { 00511 //Example: 00512 // TextureCoordinates 2 00513 // { 00514 // # Texture Coordinates assigned at face vertices 00515 // # vertices s_0 t_0 s_1 t_1 s_2 t_2 s_3 t_3 00516 // 0 4 0.3166 0.6316 0.3441 0.6337 0.3537 0.6127 0.3225 0.6008 00517 // 1 4 0.3015 0.8142 0.3624 0.8094 0.3548 0.7738 0.3012 0.7804 00518 // } 00519 //Another Example: 00520 // TextureCoordinates 1 00521 // { 00522 // # Texture Coordinates assigned at face vertices 00523 // # vertices s_0 t_0 s_1 t_1 s_2 t_2 s_3 t_3 00524 // 0 4 1 0 1 1 0 1 0 0 00525 // } 00526 00527 // Set number of (2-D) texture coordinates 00528 int n = 0; 00529 char str[128]; 00530 sscanf( line, "%s%d", str, &n ); 00531 prModel->SetNoTexCoords( n ); 00532 00533 // Temp Variables 00534 char *delimiters = "\t "; 00535 char *token = NULL; 00536 char *end; 00537 int numberOfTexCoords; 00538 Real s, t; // texture coordinates 00539 int faceNo; 00540 00541 // Set texture coordinates of each Xface 00542 n = 0; 00543 while ( str[0] != '{' ) { 00544 fgets( line, 128, fileIn ); 00545 sscanf( line, "%s", str ); 00546 } 00547 while ( str[0] != '}' && n < prModel->GetNoTexCoords() ) { 00548 fgets( line, 128, fileIn ); 00549 sscanf( line, "%s", str ); 00550 if ( str[0] == '#' ) continue; 00551 00552 // Get number of face 00553 token = strtok( line, delimiters ); 00554 faceNo = static_cast<int>( strtol( token, &end, 10 ) ); 00555 // Get number of texture coordinates 00556 token = strtok( '\0', delimiters ); 00557 numberOfTexCoords = static_cast<int>( strtol( token, &end, 10 ) ); 00558 prModel->GetFaceList()[faceNo].SetNoTexCoords( numberOfTexCoords ); 00559 00560 // Set the texture coordinates 00561 for ( int i = 0; i < numberOfTexCoords; ++i ) 00562 { 00563 token = strtok( '\0', delimiters ); 00564 s = static_cast<Real>( strtod( token, &end ) ); 00565 token = strtok( '\0', delimiters ); 00566 t = static_cast<Real>( strtod( token, &end ) ); 00567 prModel->GetFaceList()[faceNo].SetTexCoordNo( i, s, t ); 00568 } 00569 ++n; 00570 } 00571 prModel->SetNoTexCoords( n ); 00572 }
| void ReadTAPs< T >::ProcessNodeVertices | ( | char * | line, | |
| OpenGL::XPolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 335 of file TAPsReadTAPs.cpp.
00336 { 00337 /* 00338 //Example 00339 // 12 556.629028 2647.669922 436.273010 00340 char *end; 00341 char *delimiters = "\t "; 00342 char *token = strtok( line, delimiters ); // token is "12" 00343 token = strtok( '\0', delimiters ); // token is "556.629028" 00344 pObject1_c->m_pdVertex[n][0] = strtod( token, &end ); 00345 token = strtok( '\0', delimiters ); // token is "2647.669922" 00346 pObject1_c->m_pdVertex[n][1] = strtod( token, &end ); 00347 token = strtok( '\0', delimiters ); // token is "436.273010" 00348 pObject1_c->m_pdVertex[n][2] = strtod( token, &end ); 00349 */ 00350 00351 //Example: 00352 // Vertices 6 00353 // { 00354 // # x y z 00355 // 1 -1 0 00356 // 1 1 0 00357 // -1 1 0 00358 // -1 -1 0 00359 // -2 -1 0 00360 // } 00361 char cx[128]; 00362 char cy[32]; 00363 char cz[32]; 00364 char *end; 00365 00366 // Set number of vertices 00367 sscanf( line, "%s %s", cx, cy ); 00368 int n = strtod( cy, &end ); 00369 prModel->SetNoVertices( n ); 00370 prModel->NewVertexListByNoVertices(); 00371 00372 // Set each vertex 00373 n = 0; 00374 while ( cx[0] != '{' ) { 00375 fgets( line, 128, fileIn ); 00376 sscanf( line, "%s", cx ); 00377 } 00378 while ( cx[0] != '}' && n < prModel->GetNoVertices() ) { 00379 fgets( line, 128, fileIn ); 00380 sscanf( line, "%s %s %s", cx, cy, cz ); 00381 if ( cx[0] == '#' ) continue; 00382 prModel->GetVertexList()[n ][0] = strtod( cx, &end ); 00383 prModel->GetVertexList()[n ][1] = strtod( cy, &end ); 00384 prModel->GetVertexList()[n++][2] = strtod( cz, &end ); 00385 } 00386 prModel->SetNoVertices( n ); 00387 }
| void ReadTAPs< T >::ProcessNodeVertices | ( | char * | line, | |
| OpenGL::PolygonalModel< T > *const | prModel | |||
| ) | [inline, static, private] |
Definition at line 279 of file TAPsReadTAPs.cpp.
00280 { 00281 /* 00282 //Example 00283 // 12 556.629028 2647.669922 436.273010 00284 char *end; 00285 char *delimiters = "\t "; 00286 char *token = strtok( line, delimiters ); // token is "12" 00287 token = strtok( '\0', delimiters ); // token is "556.629028" 00288 pObject1_c->m_pdVertex[n][0] = strtod( token, &end ); 00289 token = strtok( '\0', delimiters ); // token is "2647.669922" 00290 pObject1_c->m_pdVertex[n][1] = strtod( token, &end ); 00291 token = strtok( '\0', delimiters ); // token is "436.273010" 00292 pObject1_c->m_pdVertex[n][2] = strtod( token, &end ); 00293 */ 00294 00295 //Example: 00296 // Vertices 6 00297 // { 00298 // # x y z 00299 // 1 -1 0 00300 // 1 1 0 00301 // -1 1 0 00302 // -1 -1 0 00303 // -2 -1 0 00304 // } 00305 char cx[128]; 00306 char cy[32]; 00307 char cz[32]; 00308 char *end; 00309 00310 // Set number of vertices 00311 sscanf( line, "%s %s", cx, cy ); 00312 int n = strtod( cy, &end ); 00313 prModel->SetNoVertices( n ); 00314 prModel->NewVertexListByNoVertices(); 00315 00316 // Set each vertex 00317 n = 0; 00318 while ( cx[0] != '{' ) { 00319 fgets( line, 128, fileIn ); 00320 sscanf( line, "%s", cx ); 00321 } 00322 while ( cx[0] != '}' && n < prModel->GetNoVertices() ) { 00323 fgets( line, 128, fileIn ); 00324 sscanf( line, "%s %s %s", cx, cy, cz ); 00325 if ( cx[0] == '#' ) continue; 00326 prModel->GetVertexList()[n ][0] = strtod( cx, &end ); 00327 prModel->GetVertexList()[n ][1] = strtod( cy, &end ); 00328 prModel->GetVertexList()[n++][2] = strtod( cz, &end ); 00329 } 00330 prModel->SetNoVertices( n ); 00331 }
| bool ReadTAPs< T >::readFile | ( | const char * | fileName, | |
| OpenGL::XPolygonalModel< T > *const | prModel | |||
| ) | [inline, static] |
Definition at line 68 of file TAPsReadTAPs.cpp.
00069 { 00070 // Open the input file 00071 fileIn = fopen( fileName, "r" ); 00072 if ( !fileIn ) { 00073 std::perror( fileName ); 00074 return false; 00075 } 00076 00077 // Read in each line, check what its contents are, 00078 // and pass it out to the relevant decoder function 00079 const char * const NodeFormat = "Format"; 00080 const char * const NodeHeader = "Header"; 00081 const char * const NodeMaterial = "Material"; 00082 const char * const NodeVertices = "Vertices"; 00083 const char * const NodeFaces = "Faces"; 00084 const char * const NodeTexCoords = "TextureCoordinates"; 00085 const char * const NodeImageTexture = "ImageTexture"; 00086 const char * const NodeEnd = "End"; 00087 00088 char line[128]; 00089 while ( !feof(fileIn) ) { 00090 fgets( line, 128, fileIn ); // read a line 00091 if ( line[0] == '#' ) continue; 00092 if ( !strncmp( line, NodeFormat, strlen(NodeFormat) ) ) { 00093 ProcessNodeFormat( line, prModel ); 00094 } 00095 else if ( !strncmp( line, NodeMaterial, strlen(NodeVertices) ) ) { 00096 ProcessNodeMaterial( line, prModel ); 00097 } 00098 else if ( !strncmp( line, NodeVertices, strlen(NodeVertices) ) ) { 00099 ProcessNodeVertices( line, prModel ); 00100 } 00101 else if ( !strncmp( line, NodeFaces, strlen(NodeFaces) ) ) { 00102 ProcessNodeFaces( line, prModel ); 00103 } 00104 else if ( !strncmp( line, NodeTexCoords, strlen(NodeTexCoords) ) ) { 00105 ProcessNodeTextureCoordinates( line, prModel ); 00106 } 00107 else if ( !strncmp( line, NodeImageTexture, strlen(NodeImageTexture) ) ) { 00108 ProcessNodeImageTexture( line, prModel ); 00109 } 00110 } 00111 fclose(fileIn); 00112 prModel->GetMaterial()->ApplyMaterial(); 00113 return true; 00114 }
| bool ReadTAPs< T >::readFile | ( | const char * | fileName, | |
| OpenGL::PolygonalModel< T > *const | prModel | |||
| ) | [inline, static] |
Definition at line 22 of file TAPsReadTAPs.cpp.
00023 { 00024 // Open the input file 00025 fileIn = fopen( fileName, "r" ); 00026 if ( !fileIn ) { 00027 std::perror( fileName ); 00028 return false; 00029 } 00030 00031 // Read in each line, check what its contents are, 00032 // and pass it out to the relevant decoder function 00033 const char * const NodeFormat = "Format"; 00034 const char * const NodeHeader = "Header"; 00035 const char * const NodeMaterial = "Material"; 00036 const char * const NodeVertices = "Vertices"; 00037 const char * const NodeFaces = "Faces"; 00038 const char * const NodeTexCoords = "TextureCoordinates"; 00039 const char * const NodeEnd = "End"; 00040 00041 char line[128]; 00042 while ( !feof(fileIn) ) { 00043 fgets( line, 128, fileIn ); // read a line 00044 if ( line[0] == '#' ) continue; 00045 if ( !strncmp( line, NodeFormat, strlen(NodeFormat) ) ) { 00046 ProcessNodeFormat( line, prModel ); 00047 } 00048 else if ( !strncmp( line, NodeMaterial, strlen(NodeVertices) ) ) { 00049 ProcessNodeMaterial( line, prModel ); 00050 } 00051 else if ( !strncmp( line, NodeVertices, strlen(NodeVertices) ) ) { 00052 ProcessNodeVertices( line, prModel ); 00053 } 00054 else if ( !strncmp( line, NodeFaces, strlen(NodeFaces) ) ) { 00055 ProcessNodeFaces( line, prModel ); 00056 } 00057 else if ( !strncmp( line, NodeTexCoords, strlen(NodeTexCoords) ) ) { 00058 ProcessNodeTextureCoordinates( line, prModel ); 00059 } 00060 } 00061 fclose(fileIn); 00062 prModel->GetMaterial()->ApplyMaterial(); 00063 return true; 00064 }
friend class ReadModels< T > [friend] |
Definition at line 31 of file TAPsReadTAPs.hpp.
BEGIN_NAMESPACE_TAPs FILE * ReadTAPs< T >::fileIn = NULL [inline, static, private] |
Definition at line 73 of file TAPsReadTAPs.hpp.
1.5.6