Ignore:
Timestamp:
04/30/07 08:16:31 (17 years ago)
Author:
gumbau
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshLoader.cpp

    r2127 r2341  
    1414#include        <cctype> 
    1515#include        <map> 
     16#include "GeoLodStripsLibrary.h" 
     17#include "GeoLodStripsConstructor.h" 
    1618 
    1719using namespace Geometry; 
     
    165167        unsigned        short   headerID; 
    166168        size_t                                  i; 
    167         //float                                         aux; 
    168169        size_t                                  k; 
    169170        bool                                            found; 
     
    462463        } 
    463464         
    464  
    465465        if (idx32bit) 
    466466        { 
     
    561561                } 
    562562        } 
    563  
    564563} 
    565564 
     
    597596                 
    598597                jumpChunk(f); 
    599  
    600598        } 
    601599} 
     
    606604void GeoMeshLoader::readSubMeshNameTable(FILE   *f, Mesh        *geoMesh) 
    607605{ 
    608                 unsigned        short   chunkID; 
    609                 unsigned        short   subMeshIndex; 
    610                 char                                            string[255]; 
    611  
     606        unsigned        short   chunkID; 
     607        unsigned        short   subMeshIndex; 
     608        char                                            string[255]; 
     609 
     610        if (!feof(f)) 
     611        { 
     612                chunkID =       readChunk(f); 
     613 
     614                while   (!feof(f) && (chunkID == M_SUBMESH_NAME_TABLE_ELEMENT)) 
     615                { 
     616                        //      Debug. 
     617                        cout    <<      "               M_SUBMESH_NAME_TABLE_ELEMENT" 
     618                                <<      endl; 
     619 
     620                        //      Read in the index of the submesh. 
     621                        fread(&subMeshIndex,sizeof(unsigned short),1,f); 
     622 
     623                        //      Read in the String and map it to its index. 
     624                        fgets(string,255,f); 
     625 
     626                        string[strlen(string) - 1]      =       '\0'; 
     627 
     628                        //      Gets the submesh name. 
     629                        strcpy(geoMesh->mSubMesh[subMeshIndex].mName,string); 
     630 
     631                        cout    <<      "--> SubMesh " 
     632                                <<      subMeshIndex 
     633                                <<      ": " 
     634                                <<      string 
     635                                <<      endl; 
     636 
     637                        // If we're not end of file get the next chunk ID. 
     638                        if (!feof(f)) 
     639                        { 
     640                                chunkID = readChunk(f); 
     641                        } 
     642                } 
    612643                if (!feof(f)) 
    613644                { 
    614                         chunkID =       readChunk(f); 
    615                          
    616                         while   (!feof(f) && (chunkID == M_SUBMESH_NAME_TABLE_ELEMENT )) 
    617                         { 
    618                                 //      Debug. 
    619                                 cout    <<      "               M_SUBMESH_NAME_TABLE_ELEMENT" 
    620                                                         <<      endl; 
    621                                  
    622                                 // Read in the index of the submesh. 
    623                                 fread(&subMeshIndex,sizeof(unsigned short),1,f); 
    624                                  
    625                                 // Read in the String and map it to its index. 
    626                                 fgets(string,255,f); 
    627  
    628                                 // If we're not end of file get the next chunk ID. 
    629                                 if (!feof(f)) 
    630                                 { 
    631                                         chunkID = readChunk(f); 
    632                                 } 
    633                         } 
    634                         if (!feof(f)) 
    635                         { 
    636                                 // Backpedal back to start of chunk. 
    637                                 fseek(f,-(long)CHUNK_OVERHEAD_SIZE,1); 
    638                         } 
    639                 } 
     645                        // Backpedal back to start of chunk. 
     646                        fseek(f,-(long)CHUNK_OVERHEAD_SIZE,1); 
     647                } 
     648        } 
    640649} 
    641650 
     
    643652//      Read a mesh file. 
    644653//------------------------------------------------------------------------- 
    645  
    646 #include "GeoLodStripsLibrary.h" 
    647 #include "GeoLodStripsConstructor.h" 
    648  
    649654void GeoMeshLoader::readMesh(FILE       *f, Mesh        *geoMesh, int option) 
    650655{ 
     
    667672                chunkID =       readChunk(f); 
    668673 
    669                 while(!feof(f) && 
    670                                 (chunkID == M_GEOMETRY || 
    671                                  chunkID == M_SUBMESH || 
    672                                  chunkID == M_MESH_SKELETON_LINK || 
    673                                  chunkID == M_MESH_BONE_ASSIGNMENT || 
    674                                  chunkID == M_MESH_LOD || 
    675                                  chunkID == M_MESH_BOUNDS || 
    676                                  chunkID == M_SUBMESH_NAME_TABLE || 
    677                                  chunkID == M_EDGE_LISTS || 
    678                                  chunkID == 0xabcd ||  
    679                                  chunkID == 0xdcba)) 
     674                while   (!feof(f) && 
     675                                (chunkID == M_GEOMETRY                                                  || 
     676                                 chunkID == M_SUBMESH                                                           || 
     677                                 chunkID == M_MESH_SKELETON_LINK                || 
     678                                 chunkID == M_MESH_BONE_ASSIGNMENT      || 
     679                                 chunkID == M_MESH_LOD                                                  || 
     680                                 chunkID == M_MESH_BOUNDS                                               || 
     681                                 chunkID == M_SUBMESH_NAME_TABLE                || 
     682                                 chunkID == M_EDGE_LISTS                                                || 
     683                                 chunkID == M_LODSTRIPS                                                 || 
     684                                 chunkID == M_LODTREES                                                  || 
     685                                 chunkID == M_POSES                                                                     || 
     686                                 chunkID == M_ANIMATIONS)) 
    680687                { 
    681688                        switch(chunkID) 
    682689                        { 
    683                                 case 0xabcd: 
     690                                case M_LODSTRIPS: 
    684691                                         
    685692                                        //      Debug. 
     
    741748                                        break; 
    742749 
    743                                 case 0xdcba: 
     750                                case M_LODTREES: 
     751 
    744752                                        cout << "LODTREES_Chunk" << endl; 
    745753                                        treesimpseq = new Geometry::TreeSimplificationSequence; 
     
    761769                                        break; 
    762770 
    763  
    764771                                case M_GEOMETRY: 
    765772 
     
    792799                                        cout    <<      "               M_MESH_SKELETON_LINK  " 
    793800                                                                <<      endl; 
    794                                                                  
    795801 
    796802                                        readSkeletonLink(f, geoMesh, option); 
     
    799805 
    800806                                case M_MESH_BONE_ASSIGNMENT: 
    801  
    802                                         //      Debug. 
    803                                         //cout  <<      "               M_MESH_BONE_ASSIGNMENT  " 
    804                                         //                      <<      endl; 
    805807 
    806808                                        readMeshBoneAssignment(f, geoMesh, option); 
     
    823825                                                                <<      endl; 
    824826 
    825                                         //jumpChunk(f); 
    826827                                        readMeshBounds(f, geoMesh, option); 
    827828                                        break; 
     
    844845                                        jumpChunk(f); 
    845846                                        break; 
     847 
     848                                case M_POSES: 
     849 
     850                                        //      Debug. 
     851                                        cout    <<      "               M_POSES " 
     852                                                                <<      endl; 
     853 
     854                                        jumpChunk(f); 
     855                                        break; 
     856 
     857                                case M_ANIMATIONS: 
     858 
     859                                        //      Debug. 
     860                                        cout    <<      "               M_ANIMATIONS " 
     861                                                                <<      endl; 
     862 
     863                                        jumpChunk(f); 
     864                                        break; 
    846865                        } 
    847866 
     
    866885                } 
    867886        } 
    868  
    869 } 
    870  
     887} 
    871888 
    872889//------------------------------------------------------------------------- 
     
    879896        size_t  strip_count; 
    880897        size_t  tailIndex; 
    881         //size_t        tail; 
    882898 
    883899        head_found                                                      =       false; 
     
    14761492        { 
    14771493                fgets(geoMesh->mSkeletonName,255,f); 
     1494 
     1495                geoMesh->mSkeletonName[strlen(geoMesh->mSkeletonName) - 1]      =       '\0'; 
    14781496                 
    14791497                geoMesh->hasSkeleton    =       true; 
Note: See TracChangeset for help on using the changeset viewer.