Changeset 1136


Ignore:
Timestamp:
07/17/06 14:24:24 (18 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared/GTGeometry
Files:
7 edited

Legend:

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

    r1083 r1136  
    112112                         
    113113                        //      Saves a Mesh into a file. 
    114                         int     save(Mesh       *geoMesh,       const   char    *fileNameMesh); 
     114                        size_t  save(Mesh       *geoMesh,       const   char    *fileNameMesh); 
    115115 
    116116                        // temporal members used to tweak the lodtree leaf submesh 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp

    r1090 r1136  
    612612void LodStripsConstructor::Save(std::string filename) 
    613613{ 
    614         unsigned int    i, j; 
    615         int                                             k       =       0; 
    616         char                                    simp[256]; 
    617  
    618         int vertexCount = this->cVerts.size(); 
    619         int changesCount = this->cCambios.size(); 
    620         int dataCount = this->cDatos.size(); 
    621         int cambiosCount = this->TOTALCAMBIOS; 
    622         int size =      changesCount*sizeof(LODData) +  
     614        //size_t        i, j; 
     615        int                     k       =       0; 
     616        char            simp[256]; 
     617 
     618        int vertexCount         =       (int)this->cVerts.size(); 
     619        int changesCount        =       (int)this->cCambios.size(); 
     620        int dataCount                   =       (int)this->cDatos.size(); 
     621        int cambiosCount        =       this->TOTALCAMBIOS; 
     622        int size                                        =       changesCount*sizeof(LODData) +  
    623623                                (vertexCount + dataCount + cambiosCount + 4)*sizeof(int) + 
    624624                                CHUNK_OVERHEAD_SIZE; 
     
    631631 
    632632        fwrite(&vertexCount, sizeof(int), 1, f); 
    633         for(i = 0; i < this->cVerts.size(); i++) 
     633        for(size_t      i = 0; i < this->cVerts.size(); i++) 
    634634        { 
    635635                int auxv = cVerts[i].Next; 
     
    648648        this->TOTALINDICES      =       0; 
    649649         
    650         for(i = 0; i < this->cStrips.size(); i++) 
     650        for(size_t      i = 0; i < this->cStrips.size(); i++) 
    651651        { 
    652652                this->TOTALINDICES += int(this->cStrips[i].size()); 
     
    656656        //      Changes 
    657657        fwrite(&changesCount, sizeof(int), 1, f); 
    658         for(i = 0; i < this->cCambios.size(); i++) 
     658        for(size_t      i = 0; i < this->cCambios.size(); i++) 
    659659        { 
    660660                LODData change= cCambios[i]; 
     
    682682 
    683683        fwrite(&dataCount, sizeof(int), 1, f); 
    684         for(i = 0; i < this->cDatos.size(); i++) 
     684 
     685        for(size_t      i = 0; i < this->cDatos.size(); i++) 
    685686        { 
    686687                int data= cDatos[i]; 
     
    698699        } 
    699700*/ 
    700  
    701701 
    702702        //      lines starting with a p. 
    703703        //      Chages made in a LOD. 
    704704        fwrite(&cambiosCount, sizeof(int), 1, f); 
    705         for(i = 0; i < this->TOTALCAMBIOS; i++) 
     705 
     706        for(size_t      i = 0; i < this->TOTALCAMBIOS; i++) 
    706707        { 
    707708                int cambio= pCambios[i]; 
     
    710711 
    711712        fclose(f); 
    712  
    713713 
    714714/* 
     
    12471247{ 
    12481248        int num_no      =       0; 
    1249         int i=0,j=0; 
     1249        //int i=0,j=0; 
    12501250 
    12511251        if(this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer == true) 
     
    12721272                this->mGeoMesh->mVertexBuffer->mVertexInfo              =       this->meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo; 
    12731273 
    1274                 for(i = 0; i < this->mGeoMesh->mSubMeshCount; i++) 
    1275                 { 
    1276                         this->mGeoMesh->mSubMesh[i].mVertexBuffer                               =       this->mGeoMesh->mVertexBuffer; 
     1274                for(size_t      i = 0; i < this->mGeoMesh->mSubMeshCount; i++) 
     1275                { 
     1276                        this->mGeoMesh->mSubMesh[i].mVertexBuffer       =       this->mGeoMesh->mVertexBuffer; 
    12771277                        this->mGeoMesh->mSubMesh[i].mSharedVertexBuffer =       true; 
    12781278                } 
     
    12801280                int     indice  =       0; 
    12811281 
    1282                 for (j = 0; j < this->cVerts.size(); j++) 
     1282                for (size_t     j       =       0;      j < this->cVerts.size();        j++) 
    12831283                { 
    12841284                        //Copiamos las coordeandas de posicion  
     
    13351335                this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer=false; 
    13361336 
    1337                 int indice=0; 
    1338                 for (j=0; j<this->cVerts.size(); j++) 
     1337                int     indice  =       0; 
     1338 
     1339                for (size_t     j       =       0;      j < this->cVerts.size();        j++) 
    13391340                { 
    13401341                        //Copiamos las coordeandas de posicion  
     
    13621363        } 
    13631364         
    1364  
    1365  
    13661365        int indice_acum = 0; 
    1367         for(i=0;i<this->mGeoMesh->mSubMeshCount;i++) 
     1366 
     1367        for(size_t      i = 0;  i < this->mGeoMesh->mSubMeshCount;      i++) 
    13681368        { 
    13691369                Geometry::SubMesh & subMesh = meshoriginal->mSubMesh[i]; 
     
    14351435                } 
    14361436        } 
    1437  
    14381437} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp

    r1090 r1136  
    439439void LodStripsLibrary::LoadStripMesh(const LodStripsLibraryData *lodstripsdata, Mesh *geomesh) 
    440440{ 
    441         FILE                                                                                                                    *fp; 
     441        //FILE                                                                                                                  *fp; 
    442442        SmallIntVector                                                                          strip_aux; 
    443         LODRegisterType                                                                         lod_register; 
     443        //LODRegisterType                                                                               lod_register; 
    444444        std::vector                     <LODRegisterType>       list_pos; 
    445445        std::vector                     <unsigned int>          p_changes; 
    446         int                                                                                                                             value; 
     446        //int                                                                                                                           value; 
    447447        int                                                                                                                             v                       =       0; 
    448448        int                                                                                                                             t                       =       -1; 
     
    450450        int                                                                                                                             next    =       0; 
    451451        int                                                                                                                             c                       =       -1; 
    452         char                                                                                                                    buff[80]; 
     452        //char                                                                                                                  buff[80]; 
    453453        Index                                                                                                                   *index; 
    454454        Index                                                                                                                   *indexBegin; 
     
    578578 
    579579        mStripsSubmesh = new int [geomesh->mSubMeshCount]; 
    580         for (int submesh = 0; submesh < geomesh->mSubMeshCount; submesh++) 
     580        for (size_t     submesh = 0; submesh < geomesh->mSubMeshCount; submesh++) 
    581581        {        
    582582                mStripsSubmesh[submesh]=0; 
     
    612612        dataRetrievalInterface->Begin(); 
    613613 
    614         int counter = 0; 
    615         int target_submesh = 0; 
    616         int strip_count = 0; 
    617  
    618         for (unsigned   int i=0; i<mTotalStrips; i++, strip_count++) 
     614        int                     counter                                 =       0; 
     615        int                     target_submesh  =       0; 
     616        size_t  strip_count                     =       0; 
     617 
     618        for (unsigned   int     i       =       0;      i < mTotalStrips;       i++,    strip_count++) 
    619619        { 
    620620                if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 
    621621                { 
    622622                        indices_x_submesh[target_submesh] = counter; 
     623 
    623624                        if (target_submesh==0) 
     625                        { 
    624626                                offsets_x_submesh[target_submesh] = 0; 
     627                        } 
    625628                        else 
     629                        { 
    626630                                offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 
    627  
    628                         counter = 0; 
    629                         mStripsSubmesh[target_submesh] = strip_count; 
    630                         strip_count = 0; 
     631                        } 
     632 
     633                        counter                                                                                                 =       0; 
     634                        mStripsSubmesh[target_submesh]  =       (int)strip_count; 
     635                        strip_count                                                                                     =       0; 
     636 
    631637                        target_submesh++; 
    632638                } 
     
    665671 
    666672                counter = 0; 
    667                 mStripsSubmesh[target_submesh] = strip_count; 
     673                mStripsSubmesh[target_submesh] = (int)strip_count; 
    668674                strip_count = 0; 
    669675                target_submesh++; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp

    r1090 r1136  
    1717 
    1818        // select the first triangle-list submesh as leaves submesh 
    19         mLeavesSubMesh = -1; 
    20         for (int i=0; i<treeGeoMesh->mSubMeshCount; i++) 
     19        mLeavesSubMesh  =       -1; 
     20 
     21        for (size_t     i       =       0;      i < treeGeoMesh->mSubMeshCount; i++) 
    2122        { 
    2223                if (treeGeoMesh->mSubMesh[i].mType==GEO_TRIANGLE_LIST) 
    2324                { 
    24                         mLeavesSubMesh=i; 
     25                        mLeavesSubMesh  =       (uint32)i; 
    2526                        break; 
    2627                } 
    27         }        
     28        } 
    2829 
    2930        // Cargar la copa del árbol 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshLoader.cpp

    r1098 r1136  
    4949        unsigned        short           source; 
    5050        GeometryElement         aux; 
    51         int                                                             i; 
     51        size_t                                          i; 
    5252        bool                                                    found; 
    5353        VertexElementType       vType; 
    5454 
    55         i                                               =       0; 
     55        i                       =       0; 
    5656        found   =       false; 
    5757 
     
    162162        unsigned        short   vertexSize; 
    163163        unsigned        short   headerID; 
    164         int                                                     i; 
    165         float                                           aux; 
    166         int                                                     k; 
     164        size_t                                  i; 
     165        //float                                         aux; 
     166        size_t                                  k; 
    167167        bool                                            found; 
    168168        float                                           x,y,z; 
     
    170170        VertexBuffer            *vertex_buffer; 
    171171 
    172         i                                               =       0; 
    173         k                                               =       0; 
     172        i                       =       0; 
     173        k                       =       0; 
    174174        found   =       false; 
    175175         
     
    228228                { 
    229229                        //      For each element in this source. 
    230                         for(int j       =       0;      j < list[i].list.size();        j++) 
     230                        for(size_t j    =       0;      j < list[i].list.size();        j++) 
    231231                        { 
    232232                                //      Positions. 
     
    466466                unsigned int aux; 
    467467 
    468                 for (int i = 0; i < numIndices; i++) 
     468                for (size_t     i = 0; i < numIndices; i++) 
    469469                { 
    470470                        fread(&aux,sizeof(unsigned int),1,f); 
     
    472472                        if (option == GEOMESH_BUILD) 
    473473                        { 
    474                                         geoSubMesh->mIndex[i]   =       aux; 
     474                                geoSubMesh->mIndex[i]   =       aux; 
    475475                        } 
    476476                } 
     
    480480                unsigned short aux; 
    481481 
    482                 for (int i = 0; i < numIndices; i++) 
     482                for (size_t     i = 0; i < numIndices; i++) 
    483483                { 
    484484                        fread(&aux,sizeof(unsigned short),1,f); 
     
    866866        bool            head_found; 
    867867        bool            tail_found; 
    868         int                     strip_count; 
    869         int                     tailIndex; 
    870         size_t  tail; 
    871  
     868        size_t  strip_count; 
     869        size_t  tailIndex; 
     870        //size_t        tail; 
    872871 
    873872        head_found                                                      =       false; 
     
    877876        //      Foreachone of the indices. 
    878877        //      Obtains the number of triangle strips. 
    879         for (int i = 0; i < (geoSubMesh->mIndexCount - 1); i++) 
     878        for (size_t     i = 0; i < (geoSubMesh->mIndexCount - 1); i++) 
    880879        { 
    881880                if (geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i+1]) 
     
    906905        } 
    907906 
    908         geoSubMesh->mStrip              =       (Index**) malloc(       sizeof(Index*) 
    909                         * 
    910                         geoSubMesh->mStripCount); 
     907        geoSubMesh->mStrip      =       (Index**) malloc(       sizeof(Index*) 
     908                                                                                                * 
     909                                                                                                geoSubMesh->mStripCount); 
    911910 
    912911        //      Number of strips. Initially there is one triangle strip. 
    913912        strip_count     =       1; 
    914  
    915         head_found                                              =       false; 
    916         tail_found                                              =       false; 
     913        head_found      =       false; 
     914        tail_found      =       false; 
    917915 
    918916        //      Initialize the fist triangle strip. 
     
    921919        //      Foreachone of the indices. 
    922920        //      Assigns the beginning of the triangle strips. 
    923         for(int i = 0;i < (geoSubMesh->mIndexCount - 1); i++) 
     921        for(size_t      i = 0;i < (geoSubMesh->mIndexCount - 1); i++) 
    924922        { 
    925923                if(geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i+1]) 
     
    991989         
    992990        //      For each one of the strips. 
    993         for (int strip = 0; strip < geoSubMesh->mStripCount; strip++) 
     991        for (size_t     strip = 0; strip < geoSubMesh->mStripCount; strip++) 
    994992        { 
    995993                //      Stars of strip without degenerate triangles. 
    996                 new_strip_starts[strip] =       current_index; 
     994                new_strip_starts[strip] =       (Index)current_index; 
    997995                 
    998996                //      First index of the strip. 
     
    10551053 
    10561054        //      Update start of the strip. 
    1057         for (int        strip   =       0; strip < geoSubMesh->mStripCount; strip++) 
     1055        for (size_t     strip   =       0; strip < geoSubMesh->mStripCount; strip++) 
    10581056        { 
    10591057                geoSubMesh->mStrip[strip]       =       &geoSubMesh->mIndex[new_strip_starts[strip]]; 
     
    10741072        unsigned        short   chunkID; 
    10751073        char            version[255]; 
    1076         char            kk; 
    10771074        FILE            *pFile; 
    10781075        SubMesh         *geosubmesh; 
     
    11961193                if (!mError) 
    11971194                { 
    1198                         for (int submesh = 0;   submesh < geoMesh->mSubMeshCount; submesh++) 
     1195                        for (size_t     submesh = 0;    submesh < geoMesh->mSubMeshCount; submesh++) 
    11991196                        { 
    12001197                                //      Gets the actual submesh. 
     
    12381235void    GeoMeshLoader::normalizeModel(Mesh      *geoMesh) 
    12391236{ 
    1240         unsigned        int     i; 
    12411237        float                                   maxx, minx, maxy, miny, maxz, minz; 
    12421238        float                                   cx, cy, cz, w, h, d, max; 
     
    12531249         
    12541250        //      For each submesh. 
    1255         for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     1251        for (size_t     submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
    12561252        { 
    12571253                //      Gets the actual submesh. 
     
    12591255 
    12601256                //      For each index of the strip. 
    1261                 for (int i = 0; i < vertex_buffer->mVertexCount; i++) 
     1257                for (size_t     i = 0; i < vertex_buffer->mVertexCount; i++) 
    12621258                { 
    12631259                        if (maxx < vertex_buffer->mPosition[i].x) 
     
    13051301 
    13061302        //      Calculate center of the model. 
    1307         cx = (maxx + minx) / 2.0; 
    1308         cy = (maxy + miny) / 2.0; 
    1309         cz = (maxz + minz) / 2.0; 
     1303        cx = (maxx + minx) / 2.0f; 
     1304        cy = (maxy + miny) / 2.0f; 
     1305        cz = (maxz + minz) / 2.0f; 
    13101306 
    13111307 
     
    13261322         
    13271323        //      Calculate unitizing scale factor. 
    1328         scale = 1.0 / max; 
     1324        scale = 1.0f / max; 
    13291325 
    13301326        geoMesh->mMeshBounds.scaleFactor                =       scale; 
    13311327 
    13321328 
    1333         bool *sharedmesh; 
    1334         sharedmesh= new bool[geoMesh->mSubMeshCount]; 
    1335         bool firstsharedmesh= true; 
    1336         for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     1329        bool    *sharedmesh; 
     1330 
     1331        sharedmesh      =       new bool[geoMesh->mSubMeshCount]; 
     1332 
     1333        bool    firstsharedmesh =       true; 
     1334 
     1335        for (size_t     submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
    13371336        { 
    13381337                if (geoMesh->mSubMesh[submesh].mSharedVertexBuffer) 
    1339                         sharedmesh[submesh]= true; 
     1338                { 
     1339                        sharedmesh[submesh]     =       true; 
     1340                } 
    13401341                else 
    1341                         sharedmesh[submesh]= false; 
     1342                { 
     1343                        sharedmesh[submesh]     =       false; 
     1344                } 
    13421345        } 
    13431346 
    13441347        //      Translate around center then scale. 
    13451348        //      For each submesh. 
    1346         for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
    1347         { 
    1348  
     1349        for (size_t     submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     1350        { 
    13491351                //      If is a shared vertex Buffer. 
    13501352                if (geoMesh->mSubMesh[submesh].mSharedVertexBuffer) 
    13511353                { 
    13521354                        if (!firstsharedmesh) 
     1355                        { 
    13531356                                continue; 
     1357                        } 
    13541358                        else 
    1355                                 firstsharedmesh= false; 
     1359                        { 
     1360                                firstsharedmesh =       false; 
     1361                        } 
    13561362                } 
    13571363 
     
    13601366 
    13611367                //      For each index of the strip. 
    1362                 for (int i = 0; i < vertex_buffer->mVertexCount; i++) 
     1368                for (size_t     i       =       0;      i < vertex_buffer->mVertexCount;        i++) 
    13631369                { 
    13641370                        vertex_buffer->mPosition[i].x -= cx; 
     
    13691375                        vertex_buffer->mPosition[i].z *= scale; 
    13701376                } 
    1371  
    13721377        } 
    13731378 
     
    13881393GeoMeshLoader::GeoMeshLoader() 
    13891394{ 
    1390         geoMesh                 =       NULL; 
    1391         mFileSize               =       0; 
     1395        geoMesh                         =       NULL; 
     1396        mFileSize                       =       0; 
    13921397        lodstripsdata   =       NULL; 
    13931398        treesimpseq             =       NULL; 
     
    14001405{ 
    14011406        if (geoMesh) 
     1407        { 
    14021408                delete  geoMesh; 
     1409        } 
     1410 
    14031411        if (lodstripsdata) 
     1412        { 
    14041413                delete lodstripsdata; 
     1414        } 
     1415 
    14051416        if (treesimpseq) 
     1417        { 
    14061418                delete treesimpseq; 
     1419        } 
    14071420} 
    14081421 
     
    14101423//      Read bones of the submesh. 
    14111424//--------------------------------------------------------------------------- 
    1412 void GeoMeshLoader::readSubMeshBoneAssignment(FILE* f, SubMesh* geoSubMesh,int option) 
     1425void GeoMeshLoader::readSubMeshBoneAssignment(FILE* f, 
     1426                                                                                                                                                                                        SubMesh* geoSubMesh, 
     1427                                                                                                                                                                                        int option) 
    14131428{ 
    14141429        if (option == GEOMESH_BUILD) 
     
    14421457                // float weight 
    14431458                fread(&(assign.weight),sizeof(float),1,f); 
    1444  
    14451459 
    14461460                geoMesh->mBones.push_back(assign); 
     
    14931507{ 
    14941508public: 
    1495         VertexArranger(Geometry::Mesh *m){ 
    1496                 mesh=m; 
    1497                 current_submesh=0; 
    1498                 current_tris=new int[m->mSubMeshCount]; 
    1499                 for (int i=0; i<m->mSubMeshCount; i++) 
    1500                         current_tris[i] = 0; 
    1501         } 
    1502         ~VertexArranger(void){ 
     1509 
     1510        VertexArranger(Geometry::Mesh *m) 
     1511        { 
     1512                mesh                                            =       m; 
     1513                current_submesh =       0; 
     1514                current_tris            =       new int[m->mSubMeshCount]; 
     1515 
     1516                for (size_t     i       =       0;      i < m->mSubMeshCount;   i++) 
     1517                { 
     1518                        current_tris[i] =       0; 
     1519                } 
     1520        } 
     1521 
     1522        ~VertexArranger(void) 
     1523        { 
    15031524                delete[] current_tris; 
    15041525        } 
     
    15171538                if (res==vertex_map.end()) 
    15181539                { 
    1519                         int val = vertex_map.size(); 
     1540                        int val = (int)vertex_map.size(); 
    15201541                        vertex_map[vertex1] = val; 
    15211542                        submesh->mIndex[j*3+0] = val; 
     
    15271548                if (res==vertex_map.end()) 
    15281549                { 
    1529                         int val = vertex_map.size(); 
     1550                        int val = (int)vertex_map.size(); 
    15301551                        vertex_map[vertex2] = val; 
    15311552                        submesh->mIndex[j*3+1] = val; 
     
    15371558                if (res==vertex_map.end()) 
    15381559                { 
    1539                         int val = vertex_map.size(); 
     1560                        int val = (int)vertex_map.size(); 
    15401561                        vertex_map[vertex3] = val; 
    15411562                        submesh->mIndex[j*3+2] = val; 
    15421563                } 
    15431564                else 
     1565                { 
    15441566                        submesh->mIndex[j*3+2] = res->second; 
     1567                } 
    15451568 
    15461569                current_tris[current_submesh] ++; 
    15471570        } 
    15481571 
    1549         int GetVertexCount(void) const { return vertex_map.size(); } 
    1550  
    1551         void SetCurrentSubMesh(int i){ current_submesh = i; } 
     1572        int GetVertexCount(void) const 
     1573        { 
     1574                return (int)vertex_map.size(); 
     1575        } 
     1576 
     1577        void SetCurrentSubMesh(int i) 
     1578        { 
     1579                current_submesh = i; 
     1580        } 
    15521581         
    15531582        class vertex_arranger_node 
     
    16051634                        vertex_list[it->second] = it->first; 
    16061635 
    1607                 for (int i=0; i<mesh->mSubMeshCount; i++) 
     1636                for (   size_t  i       =       0;      i < mesh->mSubMeshCount;        i++) 
     1637                { 
    16081638                        mesh->mSubMesh[i].mVertexBuffer = mesh->mVertexBuffer; 
     1639                } 
    16091640                 
    1610                 for (int j=0; j<mesh->mVertexBuffer->mVertexCount; j++) 
     1641                for (size_t     j       =       0;      j < mesh->mVertexBuffer->mVertexCount;  j++) 
    16111642                {                
    16121643                        int vi = vertex_list[j].v; 
     
    16151646 
    16161647                        Geometry::Vector3 auxpos(vertices[vi]); 
    1617                         if (auxpos.x < mesh->mMeshBounds.minX) mesh->mMeshBounds.minX = auxpos.x; 
    1618                         if (auxpos.y < mesh->mMeshBounds.minY) mesh->mMeshBounds.minY = auxpos.y; 
    1619                         if (auxpos.z < mesh->mMeshBounds.minZ) mesh->mMeshBounds.minZ = auxpos.z; 
    1620                         if (auxpos.x > mesh->mMeshBounds.maxX) mesh->mMeshBounds.maxX = auxpos.x; 
    1621                         if (auxpos.y > mesh->mMeshBounds.maxY) mesh->mMeshBounds.maxY = auxpos.y; 
    1622                         if (auxpos.z > mesh->mMeshBounds.maxZ) mesh->mMeshBounds.maxZ = auxpos.z; 
    1623  
    1624                         mesh->mVertexBuffer->mPosition[j] = auxpos; 
    1625                         mesh->mVertexBuffer->mNormal[j] = normals[ni]; 
    1626                         if (texcoords.empty()==false) 
    1627                                 mesh->mVertexBuffer->mTexCoords[j] = texcoords[ti];              
     1648 
     1649                        if (auxpos.x < mesh->mMeshBounds.minX) 
     1650                        { 
     1651                                mesh->mMeshBounds.minX = auxpos.x; 
     1652                        } 
     1653 
     1654                        if (auxpos.y < mesh->mMeshBounds.minY) 
     1655                        { 
     1656                                mesh->mMeshBounds.minY = auxpos.y; 
     1657                        } 
     1658 
     1659                        if (auxpos.z < mesh->mMeshBounds.minZ) 
     1660                        { 
     1661                                mesh->mMeshBounds.minZ = auxpos.z; 
     1662                        } 
     1663 
     1664                        if (auxpos.x > mesh->mMeshBounds.maxX) 
     1665                        { 
     1666                                mesh->mMeshBounds.maxX = auxpos.x; 
     1667                        } 
     1668 
     1669                        if (auxpos.y > mesh->mMeshBounds.maxY) 
     1670                        { 
     1671                                mesh->mMeshBounds.maxY = auxpos.y; 
     1672                        } 
     1673 
     1674                        if (auxpos.z > mesh->mMeshBounds.maxZ) 
     1675                        { 
     1676                                mesh->mMeshBounds.maxZ = auxpos.z; 
     1677                        } 
     1678 
     1679                        mesh->mVertexBuffer->mPosition[j]       =       auxpos; 
     1680                        mesh->mVertexBuffer->mNormal[j]         =       normals[ni]; 
     1681 
     1682                        if (texcoords.empty() == false) 
     1683                        { 
     1684                                mesh->mVertexBuffer->mTexCoords[j] = texcoords[ti]; 
     1685                        } 
    16281686                } 
    16291687 
     
    16321690 
    16331691//private: 
    1634         std::map<vertex_arranger_node,int> vertex_map; 
    1635         Geometry::Mesh *mesh; 
    1636         int current_submesh; 
    1637         int *current_tris; 
     1692        std::map<vertex_arranger_node,int>      vertex_map; 
     1693        Geometry::Mesh                                                                                  *mesh; 
     1694        int                                                                                                                                     current_submesh; 
     1695        int                                                                                                                                     *current_tris; 
    16381696}; 
    16391697 
     
    17341792        { 
    17351793                // calculate face normals 
    1736                 for (int i=0, inormal=0; i<mesh->mSubMeshCount; i++) 
     1794                for (size_t i=0, inormal=0; i<mesh->mSubMeshCount; i++) 
    17371795                { 
    17381796                        Geometry::SubMesh *submesh = mesh->mSubMesh+i; 
     
    17421800                        { 
    17431801                                face_t & auxface = *it; 
    1744                                 auxface.n1 = inormal; 
    1745                                 auxface.n2 = inormal; 
    1746                                 auxface.n3 = inormal; 
     1802 
     1803                                auxface.n1 = (int)inormal; 
     1804                                auxface.n2 = (int)inormal; 
     1805                                auxface.n3 = (int)inormal; 
     1806 
    17471807                                Geometry::Vector3 v1,v2,v3,v31,v21,nor; 
    17481808                                v1 = vertices[auxface.v1]; 
     
    17631823                  
    17641824        mesh->mSubMesh=new Geometry::SubMesh[mesh->mSubMeshCount]; 
    1765         for (int i=0; i<mesh->mSubMeshCount; i++) 
     1825        for (size_t     i       =       0;      i < mesh->mSubMeshCount;        i++) 
    17661826        { 
    17671827                Geometry::SubMesh *submesh = mesh->mSubMesh+i; 
     
    17731833                submesh->mIndex=new Geometry::Index[submesh->mIndexCount]; 
    17741834 
    1775                 vertex_arranger.SetCurrentSubMesh(i); 
     1835                vertex_arranger.SetCurrentSubMesh((int)i); 
    17761836                 
    17771837                for (std::vector<face_t>::const_iterator it=vecfaces.begin(); it!=vecfaces.end(); it++,j++) 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSaver.cpp

    r1083 r1136  
    4040//      Saves a Mesh into a file. 
    4141//--------------------------------------------------------------------------- 
    42 int     GeoMeshSaver::save(Mesh *geoMesh,       const   char    *fileNameMesh) 
    43 { 
    44         int                     size; 
     42size_t  GeoMeshSaver::save(Mesh *geoMesh,       const   char    *fileNameMesh) 
     43{ 
     44        size_t  size; 
    4545        String  name(fileNameMesh); 
     46        SubMesh *geosubmesh; 
    4647 
    4748        mGeoMesh        =       new Mesh(); 
     
    6465        unnormalizeModel(mGeoMesh); 
    6566 
    66         if (leavesSubMesh>-1 && leavesVB) 
    67         { 
    68                 Vector3 bmax(geoMesh->mMeshBounds.maxX,geoMesh->mMeshBounds.maxY,geoMesh->mMeshBounds.maxZ); 
    69                 Vector3 bmin(geoMesh->mMeshBounds.minX,geoMesh->mMeshBounds.minY,geoMesh->mMeshBounds.minZ); 
    70                 Vector3 center = (bmax+bmin)*0.5f; 
    71                 float scale = geoMesh->mMeshBounds.scaleFactor; 
    72                  
    73                 mGeoMesh->mSubMesh[leavesSubMesh].mSharedVertexBuffer=false; 
    74                 mGeoMesh->mSubMesh[leavesSubMesh].mStripCount=0; 
    75                 mGeoMesh->mSubMesh[leavesSubMesh].mIndexCount=numindices; 
    76                 int icount = mGeoMesh->mSubMesh[leavesSubMesh].mIndexCount; 
    77                 mGeoMesh->mSubMesh[leavesSubMesh].mIndex=new Index[icount]; 
    78                 for (int i=0; i<icount; i++) 
    79                         mGeoMesh->mSubMesh[leavesSubMesh].mIndex[i]=indices[i]; 
    80  
    81                 mGeoMesh->mSubMesh[leavesSubMesh].mType=GEO_TRIANGLE_LIST; 
    82                 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer=new VertexBuffer(); 
    83                 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mVertexInfo=VERTEX_POSITION; 
    84                 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mVertexCount=leavesVB->mVertexCount;; 
    85                 int vcount = mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mVertexCount; 
    86                 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mPosition=new Vector3[vcount]; 
    87                 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mNormal=new Vector3[vcount]; 
    88                 mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mTexCoords=new Vector2[vcount]; 
    89                 for (int i=0; i<vcount; i++) 
     67        if ((leavesSubMesh > -1) && leavesVB) 
     68        { 
     69                //      Gets the leaves submesh. 
     70                geosubmesh      =       &mGeoMesh->mSubMesh[leavesSubMesh]; 
     71                 
     72                Vector3 bmax(   geoMesh->mMeshBounds.maxX, 
     73                                                                        geoMesh->mMeshBounds.maxY, 
     74                                                                        geoMesh->mMeshBounds.maxZ); 
     75                 
     76                Vector3 bmin(   geoMesh->mMeshBounds.minX, 
     77                                                                        geoMesh->mMeshBounds.minY, 
     78                                                                        geoMesh->mMeshBounds.minZ); 
     79                 
     80                Vector3 center = (bmax + bmin) * 0.5f; 
     81                 
     82                float   scale   =       geoMesh->mMeshBounds.scaleFactor; 
     83                 
     84                geosubmesh->mSharedVertexBuffer =       false; 
     85                geosubmesh->mStripCount                                 =       0; 
     86                geosubmesh->mIndexCount                                 =       numindices; 
     87                 
     88                size_t  icount  =       geosubmesh->mIndexCount; 
     89                 
     90                geosubmesh->mIndex      =       new Index[icount]; 
     91                 
     92                for (size_t     i       =       0;      i < icount;     i++) 
    9093                { 
    91                         mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mPosition[i].x = leavesVB->mPosition[i].x / scale + center.x; 
    92                         mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mPosition[i].y = leavesVB->mPosition[i].y / scale + center.y; 
    93                         mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mPosition[i].z = leavesVB->mPosition[i].z / scale + center.z; 
    94                         mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mNormal[i].x = leavesVB->mNormal[i].x; 
    95                         mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mNormal[i].y = leavesVB->mNormal[i].y; 
    96                         mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mNormal[i].z = leavesVB->mNormal[i].z; 
    97                         mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mTexCoords[i].x = leavesVB->mTexCoords[i].x; 
    98                         mGeoMesh->mSubMesh[leavesSubMesh].mVertexBuffer->mTexCoords[i].y = leavesVB->mTexCoords[i].y; 
     94                        geosubmesh->mIndex[i]   =       indices[i]; 
     95                } 
     96 
     97                geosubmesh->mType                                       =       GEO_TRIANGLE_LIST; 
     98                geosubmesh->mVertexBuffer       =       new VertexBuffer(); 
     99                geosubmesh->mVertexBuffer->mVertexInfo 
     100                                                                                                                                                                                                                =       VERTEX_POSITION; 
     101                 
     102                geosubmesh->mVertexBuffer->mVertexCount 
     103                                                                                                                                                                                                                =       leavesVB->mVertexCount; 
     104                 
     105                size_t  vcount; 
     106                         
     107                vcount = geosubmesh->mVertexBuffer->mVertexCount; 
     108                 
     109                geosubmesh->mVertexBuffer->mPosition 
     110                                                                                                                                                                                                                =       new Vector3[vcount]; 
     111                 
     112                geosubmesh->mVertexBuffer->mNormal 
     113                                                                                                                                                                                                                =       new Vector3[vcount]; 
     114                 
     115                geosubmesh->mVertexBuffer->mTexCoords 
     116                                                                                                                                                                                                                =       new Vector2[vcount]; 
     117                 
     118                for (size_t     i       =       0;      i < vcount;     i++) 
     119                { 
     120                        geosubmesh->mVertexBuffer->mPosition[i].x = leavesVB->mPosition[i].x / scale + center.x; 
     121                        geosubmesh->mVertexBuffer->mPosition[i].y = leavesVB->mPosition[i].y / scale + center.y; 
     122                        geosubmesh->mVertexBuffer->mPosition[i].z = leavesVB->mPosition[i].z / scale + center.z; 
     123                        geosubmesh->mVertexBuffer->mNormal[i].x = leavesVB->mNormal[i].x; 
     124                        geosubmesh->mVertexBuffer->mNormal[i].y = leavesVB->mNormal[i].y; 
     125                        geosubmesh->mVertexBuffer->mNormal[i].z = leavesVB->mNormal[i].z; 
     126                        geosubmesh->mVertexBuffer->mTexCoords[i].x = leavesVB->mTexCoords[i].x; 
     127                        geosubmesh->mVertexBuffer->mTexCoords[i].y = leavesVB->mTexCoords[i].y; 
    99128                } 
    100129        } 
     
    126155{ 
    127156        // Header 
    128         writeChunkHeader(M_MESH, calcMeshSize(geoMesh)); 
     157        writeChunkHeader(M_MESH, (unsigned long)calcMeshSize(geoMesh)); 
    129158 
    130159        //      Debug. 
     
    142171 
    143172        //      Write submeshes. 
    144         for (int i = 0; i < geoMesh->mSubMeshCount;     i++) 
     173        for (size_t i = 0;      i < geoMesh->mSubMeshCount;     i++) 
    145174        { 
    146175                writeSubMesh(&geoMesh->mSubMesh[i]); 
     
    157186                { 
    158187 
    159                         for (int i = 0; i< geoMesh->mBones.size(); i++) 
     188                        for (size_t i = 0; i< geoMesh->mBones.size(); i++) 
    160189                        { 
    161190                                writeMeshBoneAssignment(geoMesh->mBones[i]); 
     
    201230{ 
    202231        bool                                            idx32bit; 
    203         unsigned        long    indexCount; 
    204         Index                                           *index; 
    205         Index                                           *indexBegin; 
    206         Index                                           *indexEnd; 
     232        size_t                                  indexCount; 
     233        //Index                                         *index; 
     234        //Index                                         *indexBegin; 
     235        //Index                                         *indexEnd; 
    207236 
    208237        // Header. 
    209         writeChunkHeader(M_SUBMESH, calcSubMeshSize(geoSubMesh)); 
     238        writeChunkHeader(M_SUBMESH, (unsigned long)calcSubMeshSize(geoSubMesh)); 
    210239 
    211240        //      Debug. 
     
    233262         
    234263        //      Write index count. 
    235         writeInts(indexCount, 1); 
     264        writeInts((unsigned long)indexCount, 1); 
    236265 
    237266        // bool indexes32Bit 
     
    291320        */ 
    292321                //      Write the index array. 
    293                 for (int i = 0; i < geoSubMesh->mIndexCount; i++) 
     322                for (size_t i = 0; i < geoSubMesh->mIndexCount; i++) 
    294323                { 
    295324                        writeInts(geoSubMesh->mIndex[i], 1); 
     
    309338        if (!geoSubMesh->mBones.empty()) 
    310339        { 
    311                 for (int i = 0; i < geoSubMesh->mBones.size(); i++) 
     340                for (size_t i = 0; i < geoSubMesh->mBones.size(); i++) 
    312341                { 
    313342                        writeSubMeshBoneAssignment(geoSubMesh->mBones[i]); 
     
    355384         
    356385        //      Calculate the size in bytes of the geometry chunk. 
    357         size    =       calcGeometrySize(vertexBuffer); 
     386        size    =       (unsigned long)calcGeometrySize(vertexBuffer); 
    358387                 
    359388        //      Header. 
     
    366395                                <<      endl; 
    367396 
    368         writeInts(vertexBuffer->mVertexCount,1); 
     397        writeInts((unsigned long)vertexBuffer->mVertexCount,1); 
    369398 
    370399        //      Vertex declaration. 
     
    561590                                        (sizeof(float)  *       7); 
    562591 
    563         writeChunkHeader(M_MESH_BOUNDS, size); 
     592        writeChunkHeader(M_MESH_BOUNDS, (unsigned long)size); 
    564593 
    565594        //      Debug. 
     
    687716 
    688717        //      Debug. 
    689         cout    <<      "Length Skeleton Link: " 
    690                                 <<      strlen(geoMesh->mSkeletonName) 
    691                                 <<      endl; 
     718        //cout  <<      "Length Skeleton Link: " 
     719        //                      <<      strlen(geoMesh->mSkeletonName) 
     720        //                      <<      endl; 
    692721 
    693722        return  size; 
     
    749778void GeoMeshSaver::writeSkeletonLink(const String& skelName) 
    750779{        
    751         writeChunkHeader(M_MESH_SKELETON_LINK, calcSkeletonLinkSize(mGeoMesh)); 
     780        writeChunkHeader(       M_MESH_SKELETON_LINK,  
     781                                                                                (unsigned long)calcSkeletonLinkSize(mGeoMesh)); 
    752782 
    753783        //      Debug. 
     
    755785                                <<      endl; 
    756786 
    757     writeString(skelName); 
     787        writeString(skelName); 
    758788} 
    759789 
     
    762792        size_t size = CHUNK_OVERHEAD_SIZE + sizeof(unsigned int) + sizeof(unsigned short)+ sizeof(float); 
    763793 
    764         writeChunkHeader(M_MESH_BONE_ASSIGNMENT, size); 
     794        writeChunkHeader(M_MESH_BONE_ASSIGNMENT, (unsigned long)size); 
    765795 
    766796        // unsigned int vertexIndex; 
     
    776806        size_t size = CHUNK_OVERHEAD_SIZE + sizeof(unsigned int) + sizeof(unsigned short)+ sizeof(float); 
    777807 
    778         writeChunkHeader(M_SUBMESH_BONE_ASSIGNMENT, size); 
     808        writeChunkHeader(M_SUBMESH_BONE_ASSIGNMENT, (unsigned long)size); 
    779809 
    780810        // unsigned int vertexIndex; 
     
    811841         
    812842        //      Calculate center of the model. 
    813         cx = (maxx + minx) / 2.0; 
    814         cy = (maxy + miny) / 2.0; 
    815         cz = (maxz + minz) / 2.0; 
     843        cx = (maxx + minx) / 2.0f; 
     844        cy = (maxy + miny) / 2.0f; 
     845        cz = (maxz + minz) / 2.0f; 
    816846 
    817847        //      Translate around center then scale. 
    818848        //      For each submesh. 
    819849 
    820         bool sharedScaled=false; 
    821  
    822         for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     850        bool sharedScaled       =       false; 
     851 
     852        for (size_t submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
    823853        { 
    824854                //      Gets the actual submesh. 
     
    826856 
    827857                if (geoMesh->mSubMesh[submesh].mSharedVertexBuffer && sharedScaled) 
     858                { 
    828859                        continue; 
     860                } 
    829861                         
    830862                //      For each index of the strip. 
    831                 for (int i = 0; i < vertex_buffer->mVertexCount; i++) 
     863                for (size_t i = 0; i < vertex_buffer->mVertexCount; i++) 
    832864                { 
    833865                        vertex_buffer->mPosition[i].x /= scale; 
     
    841873                //      If is a shared vertex Buffer. 
    842874                if (geoMesh->mSubMesh[submesh].mSharedVertexBuffer) 
    843                         sharedScaled=true; 
    844         } 
    845 } 
    846  
     875                { 
     876                        sharedScaled    =       true; 
     877                } 
     878        } 
     879} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoTreeSimpSequence.cpp

    r1090 r1136  
    6060void TreeSimplificationSequence::Save(Serializer &s) 
    6161{ 
    62         // Almacena la secuencia de simplificación en un fichero 
    63 /*      char simp[256]; 
    64  
    65         // Nombre del mesh 
    66         sprintf(simp,"%s\n",meshName); 
    67         s.WriteData(simp,sizeof(char),strlen(simp)); 
    68 */ 
     62        // Stores simplification sequence. 
    6963        unsigned short chunkid = 0xdcba; 
    7064        s.WriteData(&chunkid,sizeof(unsigned short),1); 
    71         unsigned long size = mSteps.size()*8*sizeof(int) + CHUNK_OVERHEAD_SIZE; 
     65 
     66        unsigned long size      =       (unsigned long) 
     67                                                                                                ( 
     68                                                                                                        mSteps.size()*8*sizeof(int) 
     69                                                                                                        + 
     70                                                                                                        CHUNK_OVERHEAD_SIZE 
     71                                                                                                ); 
     72 
    7273        s.WriteData(&size,sizeof(unsigned long),1); 
    7374 
    74         int tam = mSteps.size(); 
     75        int tam = (int)mSteps.size(); 
     76 
    7577        s.WriteData(&tam,sizeof(int),1); 
    76         for(unsigned int i=0; i<tam; i++) 
     78 
     79        for(int i=0; i<tam; i++) 
    7780        { 
    7881                Geometry::TreeSimplificationSequence::Step paso = mSteps.operator [](i); 
Note: See TracChangeset for help on using the changeset viewer.