Changeset 2341


Ignore:
Timestamp:
04/30/07 08:16:31 (17 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshLoader.h

    r1788 r2341  
    5353        const unsigned  short M_EDGE_LIST_LOD                                                           =       0xB100; 
    5454        const unsigned  short M_EDGE_GROUP                                                                      = 0xB110; 
     55        const unsigned  short M_POSES                                                                                           = 0xC000; 
     56        const unsigned  short M_ANIMATIONS                                                                      = 0xD000; 
     57        const unsigned  short M_LODSTRIPS                                                                               = 0xABCD; 
     58        const unsigned  short M_LODTREES                                                                                = 0xDCBA; 
    5559        const   unsigned        short   SUBMESH_COUNT                                                                   =       0; 
    5660        const   unsigned        short   GEOMESH_BUILD                                                                   =       1; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSaver.h

    r1136 r2341  
    1 /*      ========================================================================== 
     1/*======================================================================= 
    22 *      (C) 2005 Universitat Jaume I 
    3  *      ========================================================================== 
     3 *======================================================================= 
    44 *      PROYECT:        GAME TOOLS 
    5  *      ========================================================================*/ 
    6 /*      CONTENT:         
     5 *======================================================================= 
     6 *      CONTENT:         
    77 * 
    88 * 
    99 *      @file   GeoMeshSaver.h 
    10  *      ========================================================================*/ 
     10 *=======================================================================*/ 
    1111 
    1212#ifndef __GEO_MESH_SAVER__ 
     
    2121        { 
    2222                private: 
     23 
    2324                        //      The mesh to write. 
    2425                        Mesh    *mGeoMesh; 
     
    4849                        //      Write Mesh Bounds. 
    4950                        void    writeMeshBounds(Mesh    *geoMesh); 
    50                          
     51 
     52                        // Write submesh name table. 
     53                        void    writeSubMeshNameTable(Mesh      *geoMesh); 
     54         
    5155                        //      Calculate the mesh size in bytes. 
    5256                        size_t  calcMeshSize(const Mesh *geoMesh); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshStripifier.h

    r1559 r2341  
    1 /*========================================================================== 
     1/*======================================================================= 
    22 *      (C) 2005 Universidad Jaime I de Castellón 
    3  *========================================================================== 
     3 *======================================================================= 
    44 *      PROYECT:        GAME TOOLS 
    5  *==========================================================================*/ 
    6 /*      CONTENT:        Make triangle strips meshes from triangle list meshes. 
     5 *======================================================================= 
     6 *      CONTENT:        Make triangle strips meshes from triangle list meshes. 
    77 * 
    88 * 
    99 *      @file   GeoMeshStripifier.h 
    10  *==========================================================================*/ 
     10 *=======================================================================*/ 
    1111 
    1212#ifndef __GEO_STRIPIFIER__ 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoSubMesh.h

    r1009 r2341  
    4949                MeshType        mType;  ///<    Type of mesh 
    5050 
     51                char                    mName[255];                                     ///<    Submesh name. 
    5152                char                    mMaterialName[255];     ///<    Material name 
    5253 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMesh.cpp

    r2322 r2341  
    5959                mSubMesh[i].mType                                                                                               =       mesh.mSubMesh[i].mType; 
    6060 
     61                strcpy(mSubMesh[i].mName,mesh.mSubMesh[i].mName); 
    6162                strcpy(mSubMesh[i].mMaterialName,mesh.mSubMesh[i].mMaterialName); 
    6263                 
     
    202203                mSubMesh[i].mVertexBuffer->mVertexInfo  =       mesh.mSubMesh[i].mVertexBuffer->mVertexInfo; 
    203204                mSubMesh[i].mType                                                                                               =       mesh.mSubMesh[i].mType; 
     205 
     206                strcpy(mSubMesh[i].mName,mesh.mSubMesh[i].mName); 
    204207                strcpy(mSubMesh[i].mMaterialName,mesh.mSubMesh[i].mMaterialName); 
    205208 
     
    515518                mesh->mSubMesh[i].mType                                                         =       mSubMesh[i].mType; 
    516519                 
     520                strcpy(mesh->mSubMesh[i].mName,mSubMesh[i].mName); 
    517521                strcpy(mesh->mSubMesh[i].mMaterialName,mSubMesh[i].mMaterialName); 
    518522                 
  • 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; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSaver.cpp

    r2127 r2341  
    181181        if (geoMesh->hasSkeleton) 
    182182        { 
     183                strcat(geoMesh->mSkeletonName,"\n"); 
     184 
    183185                // Write skeleton link 
    184186                writeSkeletonLink(geoMesh->mSkeletonName); 
     
    199201        writeMeshBounds(geoMesh); 
    200202 
     203        // Write submesh name table. 
     204        writeSubMeshNameTable(geoMesh); 
     205 
    201206        /* 
    202207        // Write LOD data if any 
     
    212217        writeBoundsInfo(pMesh); 
    213218        LogManager::getSingleton().logMessage("Bounds information exported."); 
    214  
    215         // Write submesh name table 
    216         LogManager::getSingleton().logMessage("Exporting submesh name table..."); 
    217         writeSubMeshNameTable(pMesh); 
    218         LogManager::getSingleton().logMessage("Submesh name table exported."); 
    219219 
    220220        // Write edge lists 
     
    414414 
    415415        //      Write the vertex declaration header. 
    416         writeChunkHeader(       M_GEOMETRY_VERTEX_DECLARATION,size); 
     416        writeChunkHeader(M_GEOMETRY_VERTEX_DECLARATION,size); 
    417417 
    418418        //      Debug. 
     
    425425        //      Positions. 
    426426        //      Write the vertex element header for position. 
    427         writeChunkHeader(       M_GEOMETRY_VERTEX_ELEMENT,size); 
     427        writeChunkHeader(M_GEOMETRY_VERTEX_ELEMENT,size); 
    428428 
    429429        //      Debug. 
     
    448448        //      Normals. 
    449449        //      Write the vertex element header for position. 
    450         writeChunkHeader(       M_GEOMETRY_VERTEX_ELEMENT,size); 
     450        writeChunkHeader(M_GEOMETRY_VERTEX_ELEMENT,size); 
    451451         
    452452        //      Debug. 
     
    528528 
    529529        //      Write the vertex buffer header. 
    530         writeChunkHeader(       M_GEOMETRY_VERTEX_BUFFER,       size); 
     530        writeChunkHeader(M_GEOMETRY_VERTEX_BUFFER,      size); 
    531531 
    532532        //      Debug. 
     
    613613        writeFloats(geoMesh->mMeshBounds.maxZ,1); 
    614614        writeFloats(geoMesh->mMeshBounds.radius,1); 
     615} 
     616 
     617//------------------------------------------------------------------------- 
     618// Write submesh name table. 
     619//------------------------------------------------------------------------- 
     620void    GeoMeshSaver::writeSubMeshNameTable(Mesh        *geoMesh) 
     621{ 
     622        size_t  size; 
     623        size_t  names_size; 
     624 
     625        //      Size of the names of the submeshes. 
     626        names_size      =       0; 
     627 
     628        //      For each submesh. 
     629        for (size_t     i = 0; i < geoMesh->mSubMeshCount;      i++) 
     630        { 
     631                names_size      =       strlen(geoMesh->mSubMesh[i].mName); 
     632        } 
     633 
     634        size    =       CHUNK_OVERHEAD_SIZE 
     635                                        + 
     636                                        names_size 
     637                                        + 
     638                                        (CHUNK_OVERHEAD_SIZE + sizeof(short)) * geoMesh->mSubMeshCount; 
     639 
     640        writeChunkHeader(M_SUBMESH_NAME_TABLE, (unsigned long)size); 
     641 
     642        //      For each submesh. 
     643        for (size_t     i = 0;  i < geoMesh->mSubMeshCount;     i++) 
     644        { 
     645                size    =       CHUNK_OVERHEAD_SIZE 
     646                                                + 
     647                                                sizeof(short) 
     648                                                + 
     649                                                strlen(geoMesh->mSubMesh[i].mName); 
     650 
     651                writeChunkHeader(M_SUBMESH_NAME_TABLE_ELEMENT, (unsigned long)size); 
     652 
     653                writeShorts(i, 1); 
     654 
     655                strcat(geoMesh->mSubMesh[i].mName,"\n"); 
     656                mSerializer->WriteData(geoMesh->mSubMesh[i].mName); 
     657        } 
    615658} 
    616659 
     
    751794 
    752795        writeString(mesh_version); 
    753  
    754796} 
    755797 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshStripifier.cpp

    r1559 r2341  
    1 /*      ========================================================================== 
     1/*      ===================================================================== 
    22 *      (C) 2005 Universitat Jaume I 
    3  *      ========================================================================== 
     3 *      ===================================================================== 
    44 *      PROYECT:        GAME TOOLS 
    5  *      ==========================================================================*/ 
    6 /**     CONTENT:        Make triangle strip meshes from triangle list meshes. 
    7         * 
    8         * 
    9         *       @file   GeoMeshStripifier.cpp 
    10 /*===========================================================================*/ 
     5 *      ===================================================================== 
     6 *      CONTENT:        Make triangle strip meshes from triangle list meshes. 
     7 * 
     8 * 
     9 *      @file   GeoMeshStripifier.cpp 
     10 *      =====================================================================*/ 
    1111 
    1212#include "GeoMeshStripifier.h" 
     
    1515using   namespace       std; 
    1616 
    17 //----------------------------------------------------------------------------- 
     17//------------------------------------------------------------------------- 
    1818//      Private. 
    19 //----------------------------------------------------------------------------- 
    20  
    21 //----------------------------------------------------------------------------- 
    22 ///     InitList. 
    23 //----------------------------------------------------------------------------- 
     19//------------------------------------------------------------------------- 
     20 
     21//------------------------------------------------------------------------- 
     22//      InitList. 
     23//------------------------------------------------------------------------- 
    2424BOOL CustomStripifier::InitList(PLISTHEAD LHead) 
    2525{ 
     
    3535} 
    3636 
    37 //----------------------------------------------------------------------------- 
     37//------------------------------------------------------------------------- 
    3838//      AddHead. 
    39 //----------------------------------------------------------------------------- 
     39//------------------------------------------------------------------------- 
    4040BOOL CustomStripifier::AddHead(PLISTHEAD LHead, PLISTINFO LInfo) 
    4141{ 
     
    80628062void CustomStripifier::Save_Walks(int numfaces) 
    80638063{ 
    8064   int x,y,numverts; 
    8065   int front_walk, back_walk; 
    8066   ListHead *pListHead; 
    8067   PF_FACES temp = NULL; 
    8068    
    8069   for (x=0; x<numfaces; x++) 
    8070     {  
    8071       /* for each face, get the face */ 
    8072       pListHead = PolFaces[x]; 
    8073       temp = (PF_FACES) PeekList(pListHead,LISTHEAD,0); 
    8074       numverts = temp->nPolSize; 
    8075       front_walk = 0;  
    8076       back_walk = 0; 
    8077        
    8078       /* we are finding patches only for quads */ 
    8079       if (numverts == 4) 
    8080         { 
    8081           /*    for each face not seen yet, do North and South together 
    8082                 and East and West together 
    8083           */ 
    8084           for (y=0;y<2;y++) 
    8085             { 
    8086               /*   Check if the opposite sides were seen already from another 
    8087                    starting face, if they were then there is no need to do  
    8088                    the walk again 
    8089               */ 
    8090                
    8091               if        ( ((*(temp->walked+y) == -1) && 
    8092                            (*(temp->walked+y+2) == -1) )) 
     8064        int x,y,numverts; 
     8065        int front_walk, back_walk; 
     8066        ListHead *pListHead; 
     8067        PF_FACES temp = NULL; 
     8068 
     8069        for (x=0; x<numfaces; x++) 
     8070        {  
     8071                /* for each face, get the face */ 
     8072                pListHead = PolFaces[x]; 
     8073                temp = (PF_FACES) PeekList(pListHead,LISTHEAD,0); 
     8074                numverts = temp->nPolSize; 
     8075                front_walk = 0;  
     8076                back_walk = 0; 
     8077 
     8078                /* we are finding patches only for quads */ 
     8079                if (numverts == 4) 
    80938080                { 
    8094                   /* Find walk for the first edge */ 
    8095                   front_walk = Calculate_Walks(x,y,temp); 
    8096                   /* Find walk in the opposite direction */ 
    8097                   back_walk = Calculate_Walks(x,y+2,temp); 
    8098                   /*    Now put into the data structure the numbers that 
    8099                         we have found 
    8100                   */ 
    8101                   Assign_Walk(x,temp,front_walk,y,back_walk); 
    8102                   Assign_Walk(x,temp,back_walk,y+2,front_walk); 
     8081                        /*      for each face not seen yet, do North and South together 
     8082                                        and East and West together 
     8083                                        */ 
     8084                        for (y=0;y<2;y++) 
     8085                        { 
     8086                                /*   Check if the opposite sides were seen already from another 
     8087                                                 starting face, if they were then there is no need to do  
     8088                                                 the walk again 
     8089                                                 */ 
     8090 
     8091                                if      ( ((*(temp->walked+y) == -1) && 
     8092                                                        (*(temp->walked+y+2) == -1) )) 
     8093                                { 
     8094                                        /* Find walk for the first edge */ 
     8095                                        front_walk = Calculate_Walks(x,y,temp); 
     8096                                        /* Find walk in the opposite direction */ 
     8097                                        back_walk = Calculate_Walks(x,y+2,temp); 
     8098                                        /*      Now put into the data structure the numbers that 
     8099                                                        we have found 
     8100                                                        */ 
     8101                                        Assign_Walk(x,temp,front_walk,y,back_walk); 
     8102                                        Assign_Walk(x,temp,back_walk,y+2,front_walk); 
     8103                                } 
     8104                        } 
    81038105                } 
    8104             } 
    8105         } 
    8106     } 
     8106        } 
    81078107} 
    81088108 
     
    85578557} 
    85588558 
    8559 //----------------------------------------------------------------------------- 
     8559//------------------------------------------------------------------------- 
    85608560//      Constructors. 
    8561 //----------------------------------------------------------------------------- 
     8561//------------------------------------------------------------------------- 
    85628562 
    85638563MeshStripifier::MeshStripifier() 
     
    85848584} 
    85858585 
    8586 //----------------------------------------------------------------------------- 
     8586//------------------------------------------------------------------------- 
    85878587//      Destroyers. 
    8588 //----------------------------------------------------------------------------- 
     8588//------------------------------------------------------------------------- 
    85898589CustomStripifier::~CustomStripifier() 
    85908590{        
     
    85968596} 
    85978597 
    8598 //----------------------------------------------------------------------------- 
     8598//------------------------------------------------------------------------- 
    85998599//      Public. 
    8600 //----------------------------------------------------------------------------- 
    8601  
    8602 //----------------------------------------------------------------------------- 
     8600//------------------------------------------------------------------------- 
     8601 
     8602//------------------------------------------------------------------------- 
    86038603//      Stripify. 
    8604 //----------------------------------------------------------------------------- 
     8604//------------------------------------------------------------------------- 
    86058605int CustomStripifier::Stripify() 
    86068606{ 
     
    86208620} 
    86218621 
    8622 //----------------------------------------------------------------------------- 
     8622//------------------------------------------------------------------------- 
    86238623//      GetMesh: Return de current Mesh. 
    8624 //----------------------------------------------------------------------------- 
     8624//------------------------------------------------------------------------- 
    86258625Mesh*   CustomStripifier::GetMesh() 
    86268626{ 
     
    86338633} 
    86348634 
    8635 //----------------------------------------------------------------------------- 
     8635//------------------------------------------------------------------------- 
    86368636//      Set the progress bar function. 
    8637 //----------------------------------------------------------------------------- 
     8637//------------------------------------------------------------------------- 
    86388638void    CustomStripifier::SetProgressFunc(TIPOFUNC upb) 
    86398639{ 
     
    86428642} 
    86438643 
    8644 //----------------------------------------------------------------------------- 
     8644//------------------------------------------------------------------------- 
    86458645// Sets what is the submesh that stores the leaves. 
    8646 //----------------------------------------------------------------------------- 
     8646//------------------------------------------------------------------------- 
    86478647void CustomStripifier::SetSubMeshLeaves(size_t  submesh) 
    86488648{ 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoSubMesh.cpp

    r1009 r2341  
    1515        mType(GEO_TRIANGLE_LIST) 
    1616{ 
     17        strcpy(mName,""); 
    1718        strcpy(mMaterialName,""); 
    1819} 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h

    r2127 r2341  
    307307        size_t  getTriangleCount(Mesh   *geoMesh); 
    308308 
     309        //      Get the number of degenerated triangles. 
     310        size_t  getDegeneratedCount(Mesh        *geoMesh); 
     311 
    309312        //      Get the number of strips. 
    310313        size_t  getStripCount(Mesh      *geoMesh); 
     
    340343 
    341344        //      Set textures to mesh model. 
    342         void setTextures(); 
     345        void    setTextures(); 
     346 
     347        //      Write strips into a file. 
     348        void    writeStrips(Mesh        *geomesh); 
    343349 
    344350        public: 
     
    400406        fltk::Widget                            *mVertices; 
    401407        fltk::Widget                            *mTriangles; 
     408        fltk::Widget                            *mDegenerated; 
    402409        fltk::Widget                            *mStrips; 
    403410        fltk::Widget                            *mQuads; 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp

    r2324 r2341  
    3737                        y                               =       fltk::event_y(); 
    3838                         
    39  
    4039                        switch (button) 
    4140                        { 
     
    139138} 
    140139 
    141 //--------------------------------------------------------------------------- 
     140//------------------------------------------------------------------------- 
    142141//      Get the number of frames per second. 
    143 //--------------------------------------------------------------------------- 
     142//------------------------------------------------------------------------- 
    144143size_t  GeoMeshView::getFPS() 
    145144{ 
     
    147146} 
    148147 
    149 //--------------------------------------------------------------------------- 
     148//------------------------------------------------------------------------- 
    150149//      Calculate the number of frames per second. 
    151 //--------------------------------------------------------------------------- 
     150//------------------------------------------------------------------------- 
    152151void    GeoMeshView::calcFPS() 
    153152{ 
     
    643642                { 
    644643                        //      The end of the index array. 
    645                         indexEnd        = &geosubmesh->mIndex[geosubmesh->mIndexCount]; 
    646                         size= indexEnd - indexBegin; 
     644                        indexEnd        =       &geosubmesh->mIndex[geosubmesh->mIndexCount]; 
     645                        size                    =       indexEnd - indexBegin; 
    647646                } 
    648647                else 
     
    678677                } 
    679678 
    680                 //VERTEX ARRAYS 
     679                //      VERTEX ARRAYS. 
    681680                glEnableClientState(GL_VERTEX_ARRAY); 
    682681                glEnableClientState(GL_NORMAL_ARRAY); 
     
    938937                //      For each one of the strips. 
    939938                int indices_to_render = lodTreeLib->GetValidTrunkIndexCount(submesh); 
    940                          
     939  
    941940                glBegin(GL_TRIANGLE_STRIP); 
    942941 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r2323 r2341  
    104104} 
    105105 
    106  
    107  
    108106//------------------------------------------------------------------------- 
    109107//      Repaint the FPS label. 
     
    156154                                                                                cb_menuFileSave_i(o,v); 
    157155} 
     156 
    158157 
    159158//------------------------------------------------------------------------- 
     
    10861085                                stripify(); 
    10871086 
     1087                                //      Debug. 
     1088                                //writeStrips(mGeoMesh); 
     1089 
    10881090                                break; 
    10891091 
     
    12981300{ 
    12991301        char                                    *file_name      =       NULL; 
     1302        char                                    *ptr; 
     1303        char                                    message[255]; 
    13001304        GeoMeshSaver    *mesh_saver; 
    13011305        Serializer              *oSerializer; 
     1306        int                                             answer_yes; 
    13021307 
    13031308        //      Sets the progress bar to process bar. 
     
    13201325                        if (file_name) 
    13211326                        { 
    1322                                 //      Undo the simplification changes. 
    1323                                 undo(); 
    1324  
    1325                                 //      Stripify the mesh object. 
    1326                                 stripify(); 
    1327  
    1328                                 //      Reset the build bar. 
    1329                                 mBuildBar->position(0); 
    1330  
    1331                                 //      Simplification sequence. 
    1332                                 oMeshSimpSequence =     mMeshSimplifier->GetSimplificationSequence(); 
    1333  
    1334                                 //      If the simplification sequence and the mesh exist. 
    1335                                 if (oMeshSimpSequence && mGeoMesh) 
    1336                                 { 
    1337                                         oLodStrip       =       new LodStripsConstructor(       mGeoMesh, 
    1338                                                                                                                                                                                                 oMeshSimpSequence, 
    1339                                                                                                                                                                                                 idMeshLeaves, 
    1340                                                                                                                                                                                                 progress_function); 
    1341  
    1342                                         oLodStrip->UpdateMesh(); 
    1343  
    1344                                         //      Deletes the previous mesh. 
    1345                                         delete mUndoMesh; 
    1346  
    1347                                         mUndoMesh       =       new Mesh(); 
    1348  
    1349                                         //      Sets the undo mesh. 
    1350                                         *mUndoMesh      =       *mGeoMesh; 
    1351  
    1352                                         delete  mGeoMesh; 
    1353  
    1354                                         mGeoMesh        =       oLodStrip->GetMesh(); 
    1355  
    1356                                         geoMeshView->setMesh(mGeoMesh); 
    1357  
    1358                                         mesh_saver      =       new     GeoMeshSaver(); 
    1359  
    1360                                         mesh_saver->leavesSubMesh       =       idMeshLeaves; 
    1361                                         mesh_saver->leavesVB                    =       origSubMeshVB; 
    1362                                         mesh_saver->numindices          =       orig_numindices; 
    1363                                         mesh_saver->indices                             =       orig_indices; 
    1364  
    1365                                         mesh_saver->save(mGeoMesh,file_name); 
    1366  
    1367                                         delete  mesh_saver; 
    1368  
    1369                                         oLodStrip->Save(file_name); 
     1327                                //      Cut extension. 
     1328                                ptr     =       strtok(file_name,"."); 
     1329 
     1330                                //      If has extension. 
     1331                                if (ptr) 
     1332                                { 
     1333                                        strcpy(file_name,ptr); 
     1334                                } 
     1335 
     1336                                //      Adds mesh extension. 
     1337                                strcat(file_name,".mesh"); 
     1338 
     1339                                //      If File Exists. 
     1340                                if (fileExists(file_name)) 
     1341                                { 
     1342                                        //      Compose message. 
     1343                                        strcpy(message,"Do you want to replace "); 
     1344                                        strcat(message,filename_name(file_name)); 
     1345                                        strcat(message,"?"); 
     1346 
     1347                                        //      Question. 
     1348                                        answer_yes      =       fltk::ask(message); 
     1349                                } 
     1350 
     1351                                //      If answer yes to replace question 
     1352                                //      or if file not exists. 
     1353                                if (answer_yes) 
     1354                                { 
     1355 
     1356                                        //      Undo the simplification changes. 
     1357                                        undo(); 
     1358 
     1359                                        //      Stripify the mesh object. 
     1360                                        stripify(); 
     1361 
     1362                                        //      Reset the build bar. 
     1363                                        mBuildBar->position(0); 
     1364 
     1365                                        //      Simplification sequence. 
     1366                                        oMeshSimpSequence =     mMeshSimplifier->GetSimplificationSequence(); 
     1367 
     1368                                        //      If the simplification sequence and the mesh exist. 
     1369                                        if (oMeshSimpSequence && mGeoMesh) 
     1370                                        { 
     1371                                                oLodStrip       =       new LodStripsConstructor(       mGeoMesh, 
     1372                                                                oMeshSimpSequence, 
     1373                                                                idMeshLeaves, 
     1374                                                                progress_function); 
     1375 
     1376                                                oLodStrip->UpdateMesh(); 
     1377 
     1378                                                //      Deletes the previous mesh. 
     1379                                                delete mUndoMesh; 
     1380 
     1381                                                mUndoMesh       =       new Mesh(); 
     1382 
     1383                                                //      Sets the undo mesh. 
     1384                                                *mUndoMesh      =       *mGeoMesh; 
     1385 
     1386                                                delete  mGeoMesh; 
     1387 
     1388                                                mGeoMesh        =       oLodStrip->GetMesh(); 
     1389 
     1390                                                geoMeshView->setMesh(mGeoMesh); 
     1391 
     1392                                                mesh_saver      =       new     GeoMeshSaver(); 
     1393 
     1394                                                mesh_saver->leavesSubMesh       =       idMeshLeaves; 
     1395                                                mesh_saver->leavesVB                    =       origSubMeshVB; 
     1396                                                mesh_saver->numindices          =       orig_numindices; 
     1397                                                mesh_saver->indices                             =       orig_indices; 
     1398 
     1399                                                mesh_saver->save(mGeoMesh,file_name); 
     1400 
     1401                                                delete  mesh_saver; 
     1402 
     1403                                                oLodStrip->Save(file_name); 
     1404                                        } 
    13701405                                } 
    13711406                                else 
     
    18371872{ 
    18381873        char                                            type[10]; 
     1874 
    18391875        unsigned        int             group_index; 
    18401876        unsigned        int             group_count; 
    18411877        unsigned        int             bone_count; 
     1878 
    18421879        fltk::ItemGroup **info_group; 
    18431880         
     
    18671904                        char    *skel_name              =       new char[256]; 
    18681905                        char    *bone_assig             =       new char[256]; 
     1906 
    18691907                        sprintf(group_name,"Skeleton"); 
    18701908                        info_group[group_index] = new fltk::ItemGroup(group_name); 
     
    18791917                                bone_count      +=      mGeoMesh->mSubMesh[i].mBones.size(); 
    18801918                        } 
     1919 
    18811920                        sprintf(bone_assig,"Bone assignamets: %d",bone_count); 
    18821921                        new fltk::Item(bone_assig); 
     
    18861925                } 
    18871926 
    1888                 for(int i=0; i<mGeoMesh->mSubMeshCount;i++) 
     1927                for(int i       =       0; i < mGeoMesh->mSubMeshCount; i++) 
    18891928                { 
    18901929                        char    *group_name     =       new char[256]; 
     
    19071946 
    19081947                        //      Submesh identifier. 
    1909                         sprintf(group_name,"SubMesh %d %s",i,type); 
     1948                        sprintf(group_name, 
     1949                                                        "SubMesh %d %s:%s", 
     1950                                                        i, 
     1951                                                        type, 
     1952                                                        mGeoMesh->mSubMesh[i].mName); 
    19101953                         
    19111954                        info_group[group_index] = new fltk::ItemGroup(group_name); 
    19121955                        info_group[group_index]->begin(); 
    19131956                        fltk::Item *sharedGeometry; 
     1957 
    19141958                        if (mGeoMesh->mSubMesh[i].mSharedVertexBuffer) 
    19151959                        { 
     
    19221966 
    19231967                        //      Adds material name. 
    1924                         char *cadena2=new char[100]; 
     1968                        char *cadena2   =       new char[100]; 
    19251969                        sprintf(cadena2, "Material: %s",mGeoMesh->mSubMesh[i].mMaterialName); 
    19261970                         
    19271971                        fltk::Item      *geomaterial    =       new fltk::Item(cadena2); 
    19281972                         
    1929                         char *cadena3=new char[100]; 
     1973                        char *cadena3   =       new char[100]; 
    19301974                         
    1931                         sprintf(cadena3, "Number of indexes: %d",mGeoMesh->mSubMesh[i].mIndexCount); 
     1975                        sprintf(cadena3, 
     1976                                                        "Number of indexes: %d", 
     1977                                                        mGeoMesh->mSubMesh[i].mIndexCount); 
     1978 
    19321979                        fltk::Item *numberIndex = new fltk::Item(cadena3); 
     1980 
    19331981                        if (mGeoMesh->mSubMesh[i].mType==Geometry::GEO_TRIANGLE_LIST) 
    19341982                        { 
    1935                                 fltk::Item *type = new fltk::Item("Triangle List"); 
     1983                                fltk::Item      *type   =       new fltk::Item("Triangle List"); 
    19361984                        } 
    19371985                        else 
    19381986                        { 
    1939                                 fltk::Item *type = new fltk::Item("Triangle Strips"); 
     1987                                fltk::Item      *type   =       new fltk::Item("Triangle Strips"); 
    19401988                        } 
    19411989 
    1942                         char *cadenavertex=new char[30]; 
    1943                         sprintf(cadenavertex, "Number of vertices: %d",mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount); 
    1944                         fltk::Item *numberVertex = new fltk::Item(cadenavertex); 
    1945  
    1946                         if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
     1990                        char *cadenavertex      =       new char[30]; 
     1991 
     1992                        sprintf(cadenavertex, 
     1993                                                        "Number of vertices: %d", 
     1994                                                        mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount); 
     1995 
     1996                        fltk::Item      *numberVertex   =       new fltk::Item(cadenavertex); 
     1997 
     1998                        if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo 
     1999                                        & 
     2000                                        Geometry::VERTEX_NORMAL) 
    19472001                        { 
    1948                                 fltk::Item *normals = new fltk::Item("Normals: Yes"); 
     2002                                fltk::Item      *normals        =       new fltk::Item("Normals: Yes"); 
    19492003                        } 
    19502004                        else 
    19512005                        { 
    1952                                 fltk::Item *normals = new fltk::Item("Normals: No"); 
     2006                                fltk::Item *normals     =       new fltk::Item("Normals: No"); 
    19532007                        } 
    19542008 
    1955                         if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
     2009                        if (mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexInfo 
     2010                                        & 
     2011                                        Geometry::VERTEX_TEXCOORDS) 
    19562012                        { 
    1957                                 fltk::Item *textures = new fltk::Item("Textures: Yes"); 
     2013                                fltk::Item      *textures       =       new fltk::Item("Textures: Yes"); 
    19582014                        } 
    19592015                        else 
    19602016                        { 
    1961                                 fltk::Item *textures = new fltk::Item("Textures: No"); 
     2017                                fltk::Item      *textures       =       new fltk::Item("Textures: No"); 
    19622018                        } 
    19632019 
    1964  
    19652020                        info_group[group_index]->end(); 
    19662021                } 
     2022 
    19672023                ogeometry->end(); 
    19682024                this->mMeshInfo->add(ogeometry); 
     
    20572113                                        break; 
    20582114                                case    GEO_TRIANGLE_STRIPS: 
    2059                                         triangle_count  +=      geoSubMesh->mIndexCount - 2; 
     2115                                        triangle_count  +=      geoSubMesh->mIndexCount 
     2116                                                                                                                        - 
     2117                                                                                                                        2; 
    20602118                                        break; 
    20612119                        } 
     
    20642122 
    20652123        return  triangle_count; 
     2124} 
     2125 
     2126//------------------------------------------------------------------------- 
     2127//      Get the number of degenerated triangles. 
     2128//------------------------------------------------------------------------- 
     2129size_t  GeoMeshViewUI::getDegeneratedCount(Geometry::Mesh       *geoMesh) 
     2130{ 
     2131        size_t  degenerated; 
     2132        size_t  same_index; 
     2133        SubMesh *geoSubMesh; 
     2134 
     2135        //      Initialize the degenerated count. 
     2136        degenerated     =       0; 
     2137 
     2138        //      Initiazlize same index count. 
     2139        same_index = 1; 
     2140 
     2141        //      For each submesh. 
     2142        for (size_t     submesh =       0; submesh < geoMesh->mSubMeshCount; submesh++) 
     2143        { 
     2144                //      Gets the actual submesh. 
     2145                geoSubMesh      =       &geoMesh->mSubMesh[submesh]; 
     2146 
     2147                if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 
     2148                { 
     2149                        //      Find degenerated triangles. 
     2150                        for (size_t     i = 0; i < (geoSubMesh->mIndexCount - 1); i++) 
     2151                        { 
     2152                                if (geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i + 1]) 
     2153                                { 
     2154                                        same_index++; 
     2155                                } 
     2156                                else 
     2157                                { 
     2158                                        if (same_index > 1) 
     2159                                        { 
     2160                                                degenerated     +=      same_index; 
     2161                                        } 
     2162                                        else if (i < (geoSubMesh->mIndexCount - 2)) 
     2163                                        { 
     2164                                                if (geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i + 2]) 
     2165                                                { 
     2166                                                        degenerated++; 
     2167                                                } 
     2168                                        } 
     2169 
     2170                                        same_index      = 1; 
     2171                                } 
     2172                        } 
     2173                } 
     2174        } 
     2175 
     2176        return  degenerated; 
    20662177} 
    20672178 
     
    24602571        static char     vertices_value[50]; 
    24612572        static char     triangles_value[50]; 
     2573        static char     degenerated_value[50]; 
    24622574        static char     strips_value[50]; 
    24632575         
     
    24712583 
    24722584        mTriangles->label(triangles_value); 
     2585 
     2586        //      Translate the degenerated count to a char value. 
     2587        sprintf(degenerated_value,"Degenerated %d",getDegeneratedCount(mGeoMesh)); 
     2588 
     2589        mDegenerated->label(degenerated_value); 
    24732590 
    24742591        //      Translate the triangle count to a char value. 
     
    26792796} 
    26802797 
     2798//------------------------------------------------------------------------- 
    26812799//      Set textures to mesh model. 
     2800//------------------------------------------------------------------------- 
    26822801void GeoMeshViewUI::setTextures() 
    26832802{ 
     
    32413360                        { 
    32423361                                fltk::Widget* o; 
    3243                                 o = mStrips = new fltk::Widget(354, 3, 30, 15, "Strips"); 
     3362                                o = mDegenerated = new fltk::Widget(354, 3, 30, 15, "Degenerated"); 
     3363                                o->box(fltk::NO_BOX); 
     3364                                o->labelfont(fltk::HELVETICA_BOLD); 
     3365                                o->color((fltk::Color)0xe0dfe300); 
     3366                        } 
     3367 
     3368                        { 
     3369                                fltk::Widget* o; 
     3370                                o = mStrips = new fltk::Widget(454, 3, 30, 15, "Strips"); 
    32443371                                o->box(fltk::NO_BOX); 
    32453372                                o->labelfont(fltk::HELVETICA_BOLD); 
     
    33203447} 
    33213448 
     3449//------------------------------------------------------------------------- 
     3450//      Write file of strips. 
     3451//------------------------------------------------------------------------- 
     3452void    GeoMeshViewUI::writeStrips(Mesh *geomesh) 
     3453{ 
     3454        Index                   *index; 
     3455        Index                   *indexBegin; 
     3456        Index                   *indexEnd; 
     3457        SubMesh         *geosubmesh; 
     3458 
     3459        ofstream        out ("strips.txt"); 
     3460 
     3461        //      For each submesh. 
     3462        for     (size_t submesh =       0;      submesh < geomesh->mSubMeshCount;       submesh++) 
     3463        { 
     3464                geosubmesh      =       &geomesh->mSubMesh[submesh]; 
     3465 
     3466                //      For each one of the strips. 
     3467                for (size_t strip = 0; strip < geosubmesh->mStripCount; strip++) 
     3468                { 
     3469                        //      First index of the strip. 
     3470                        indexBegin      =       geosubmesh->mStrip[strip]; 
     3471 
     3472                        //      If is the final strip 
     3473                        if (strip       == (geosubmesh->mStripCount - 1)) 
     3474                        { 
     3475                                //      The end of the index array. 
     3476                                indexEnd        =       &geosubmesh->mIndex[geosubmesh->mIndexCount]; 
     3477                        } 
     3478                        else 
     3479                        { 
     3480                                //      The beginning of the next strip. 
     3481                                indexEnd        = geosubmesh->mStrip[strip + 1]; 
     3482                        } 
     3483 
     3484                        for (index = indexBegin; index < indexEnd; index++) 
     3485                        { 
     3486                                out <<  index[0] 
     3487                                                <<      " "; 
     3488                        } 
     3489 
     3490                        out     <<      endl; 
     3491                } 
     3492        } 
     3493 
     3494        out.close(); 
     3495} 
     3496 
Note: See TracChangeset for help on using the changeset viewer.