Changeset 1070


Ignore:
Timestamp:
06/30/06 14:22:34 (18 years ago)
Author:
gumbau
Message:
 
Location:
GTP/trunk/Lib/Geom/shared
Files:
18 edited

Legend:

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

    r1014 r1070  
    1212. 
    1313*/ 
    14 namespace Geometry { 
    15  
     14namespace Geometry 
     15{ 
    1616        //      Basic types. 
    1717        typedef float                                   Real; 
     
    4141                unsigned short boneIndex; 
    4242                Real weight; 
    43  
    4443        }; 
    4544 
     
    5554                float   scaleFactor; 
    5655        }; 
    57          
     56 
    5857        //      Needed to update the progress bar. 
    5958        typedef float updateProgressBar(float); 
     
    6261 
    6362} // end of Geometry namespace 
    64  
    6563 
    6664#define GEO_ENDIAN_LITTLE 1 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsConstructor.h

    r1018 r1070  
    6767                        //      Lista que contiene el modelo en varias tiras y cada tira 
    6868                        //      contiene la secuencia 
     69                        //      de vertices que la forma 
    6970 
    70                         // de vertices que la forma 
    7171                        uint32 MARCA; //Para delimitar el final de tira. 
    7272                        uint32 TOTALTIRAS; 
     
    8080                        size_t  mSubMeshLeaves; 
    8181 
    82                         Mesh    *geoMesh; 
     82                        Mesh    *mGeoMesh; 
     83                        Mesh    *mInitialMesh; 
     84 
    8385                        const   Geometry::Mesh *meshoriginal; 
    84                         /*const */MeshSimplificationSequence *geoMeshSQ; 
     86                        /*const */MeshSimplificationSequence *mGeoMeshSQ; 
    8587                        int             NumVertsRepetidos; 
    8688 
     
    120122                        void leeVerticesyTirasDeMesh(); 
    121123 
     124                        //      Sort submesh bones. 
     125                        void    sortBones(); 
     126                         
    122127                public: 
    123128 
     
    149154                        Mesh    *       GetMesh(); 
    150155 
    151                         // Sets what is the submesh that stores the leaves 
     156                        ///     Sets what is the submesh that stores the leaves. 
    152157                        void SetSubMeshLeaves(size_t    submesh); 
    153  
    154158        }; 
    155159 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h

    r1069 r1070  
    4242        typedef struct 
    4343        { 
    44                 float Vertex[3]; 
    45                 SmallInt Next; 
     44                float                   Vertex[3]; 
     45                SmallInt        Next; 
    4646        } VertexType; 
    4747 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMesh.h

    r980 r1070  
    5959 
    6060#endif 
    61  
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshSimplifier.h

    r1024 r1070  
    5959                        //private: // fer protected 
    6060                        Mesh                                                                                            *mGeoMesh; 
     61                        Mesh                                                                                            *mInitialMesh; 
    6162                        MeshSimplificationSequence      *msimpsequence; 
    6263                        const Mesh                                                                      *objmesh; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoTreeSimplifier.h

    r1019 r1070  
    9494                void RecursiveFillOctreeWithLeaves(LeafOctree*); 
    9595                LeafOctree* CreateLeafOctree(int deep); // generates a new leaf octree and returns its root node 
    96                 int vertex_count; 
     96                size_t  vertex_count; 
    9797                LeafOctree ** octree_owning_leaf; 
    9898                LeafOctree *GetMinOctreeNodeForLeaf(LeafOctree *start, const Leaf &leaf); 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp

    r1048 r1070  
    11#include <iostream> 
    22#include <fstream> 
    3  
     3#include <time.h> 
    44#include "GeoLodStripsConstructor.h" 
    55 
    66using namespace Geometry; 
    77 
    8  
    9 //-------------------------------------------------------------------------- 
    10 //Call GenerarModeloV and CopiarVectorsArraysNUEVAED to make changes 
    11 //--------------------------------------------------------------------------- 
    12 //      Se utiliza en el constructor sobrecargado. 
     8//--------------------------------------------------------------------------- 
     9//      Call GenerarModeloV and CopiarVectorsArraysNUEVAED to make changes. 
     10//--------------------------------------------------------------------------- 
    1311void LodStripsConstructor::GenerarModeloCompleto(TIPOFUNC       upb) 
    1412{        
    1513        float   percent; 
    1614 
    17  
    1815        this->GenerarModeloV(upb); 
    1916        this->CopiarVectors2ArraysNUEVAED(); 
     
    2421} 
    2522 
    26 //----------------------------------------------------------------------------------- 
    27 //It makes Lods changes and count them 
    28 //----------------------------------------------------------------------------------- 
     23//--------------------------------------------------------------------------- 
     24//      It makes Lods changes and count them. 
     25//--------------------------------------------------------------------------- 
    2926void LodStripsConstructor::CalcularCambiosLODsVNuevaED(TIPOFUNC upb) 
    3027{ 
     
    203200 
    204201 
    205                                         r= 0; 
    206                                         k=cStripsT.size()-3; 
     202                                        r       =       0; 
     203 
     204                                        k       =       (long)(cStripsT.size() - 3); 
    207205 
    208206                                } 
     
    295293} 
    296294 
    297 //----------------------------------------------------------------------- 
     295//--------------------------------------------------------------------------- 
    298296//Put in order vertex of Mesh from simplification sequence 
    299 //----------------------------------------------------------------------- 
    300 #include <time.h> 
     297//--------------------------------------------------------------------------- 
    301298void LodStripsConstructor::OrdenarModeloVQSLIM(TIPOFUNC upb) 
    302299{ 
     
    326323        bEncontrado = false; 
    327324 
    328         int mStepsSize = geoMeshSQ->mSteps.size(); 
     325        size_t  mStepsSize = mGeoMeshSQ->mSteps.size(); 
    329326 
    330327        c1                                      =       0; 
     
    343340                } 
    344341                 
    345                 const Geometry::MeshSimplificationSequence::Step & theStep = this->geoMeshSQ->mSteps[i]; 
     342                const Geometry::MeshSimplificationSequence::Step & theStep = this->mGeoMeshSQ->mSteps[i]; 
    346343 
    347344                mV1Aux.push_back(theStep.mV1); 
     
    426423        int contestaban =       0; 
    427424 
    428         int cVertsSize = this->cVerts.size(); 
     425        size_t  cVertsSize = this->cVerts.size(); 
    429426        for(i = 0; i < cVertsSize; i++) 
    430427        { 
     
    481478 
    482479        //Creacion de nuevas tiras con las mismas dimensiones 
    483         int cStripsSize = this->cStrips.size(); 
     480        size_t  cStripsSize = this->cStrips.size(); 
    484481        for(t = 0; t < cStripsSize; t++) 
    485482        { 
    486483                tira.clear(); 
    487484 
    488                 int cStripsSizeT = this->cStrips[t].size(); 
     485                size_t  cStripsSizeT = this->cStrips[t].size(); 
    489486                for(i = 0; i < cStripsSizeT; i++) 
    490487                        tira.push_back(0); 
     
    501498        //      2 min. 
    502499        //Cambiar los vertices de las tiras 
    503         int NuevosVertsSize = NuevosVerts.size();        
     500        size_t  NuevosVertsSize = NuevosVerts.size();    
    504501        for(v = 0; v < NuevosVertsSize; v++) 
    505502        { 
     
    516513                        std::vector<int> & thisStrip = cStrips[t];                       
    517514                        std::vector<int> & NuevasTirasT = NuevasTiras[t]; 
    518                         int cStripsSizeT = thisStrip.size(); 
     515                        size_t  cStripsSizeT = thisStrip.size(); 
    519516                        for(i = 0; i < cStripsSizeT; i++) 
    520517                        { 
     
    545542} 
    546543 
    547 //----------------------------------------------------------------------------- 
     544//--------------------------------------------------------------------------- 
    548545//      Constructor of LodStripsConstructor object from 
    549 //      a Mesh and MeshSimplificationSequence 
    550 //      Constructor del objeto LodStripsConstructor. 
    551 //      Tomamos el Mesh y la secuencia de simplificacion que se pasan 
    552 //      como parametros y llamamos a la funcion GenerarModeloCompleto para 
    553 //      que se realicen las modificaciones a efectuar 
    554 //----------------------------------------------------------------------------- 
     546//      a Mesh and MeshSimplificationSequence. 
     547//--------------------------------------------------------------------------- 
    555548LodStripsConstructor::LodStripsConstructor(const Mesh                                           *m, 
    556549                                                                                                                const MeshSimplificationSequence        *ms, 
     
    560553        MARCA   =       TOTALTIRAS      =       TOTALVERTS      =       TOTALCAMBIOS    =       0; 
    561554         
    562         meshoriginal            =       m; 
    563         this->geoMesh           =       new Geometry::Mesh(); 
    564         *this->geoMesh  =       *m; 
    565         this->geoMeshSQ = const_cast<MeshSimplificationSequence*>(ms); 
     555        meshoriginal    =       m; 
     556         
     557        mGeoMesh                        =       new Mesh(); 
     558        *mGeoMesh                       =       *m; 
     559         
     560        mInitialMesh    =       new Mesh(); 
     561        *mInitialMesh   =       *m; 
     562         
     563        this->mGeoMeshSQ        =       const_cast<MeshSimplificationSequence*>(ms); 
    566564 
    567565        //      Set the leaves submesh. 
    568566        mSubMeshLeaves  =       submesh; 
     567         
    569568        this->GenerarModeloCompleto(upb); 
    570 } 
    571  
    572 //--------------------------------------------- 
     569 
     570        //      Sort submesh bones. 
     571        this->sortBones(); 
     572} 
     573 
     574//--------------------------------------------------------------------------- 
    573575//      Destructor LodStripsConstructor object 
    574 //      Destructor de la clase LodStripsConstructor 
    575 //--------------------------------------------- 
     576//--------------------------------------------------------------------------- 
    576577LodStripsConstructor::~LodStripsConstructor() 
    577578{ 
     
    600601        delete [] pCambios; 
    601602 
    602         delete this->geoMesh; 
    603 } 
    604  
    605 //------------------------------------------------------------------------------ 
    606 //      build lod file with necessary information and save all changes at 
    607 //      lodStripConstructor object 
    608 //      Construimos el archivo Lod donde se guarda la informacion sobre los 
    609 //      cambios realizados en el mesh 
    610 //      y copiamos todos los cambios realizados sobre las estructuras que 
    611 //      contienen los vertices y los indices  
    612 //      modificados sobre el objeto Mesh de la clase 
    613 //------------------------------------------------------------------------------ 
     603        delete  mInitialMesh; 
     604        delete  mGeoMesh; 
     605} 
     606 
     607//--------------------------------------------------------------------------- 
     608//      Build lod file with necessary information and save all changes at 
     609//      lodStripConstructor object. 
     610//--------------------------------------------------------------------------- 
    614611void LodStripsConstructor::Save(Serializer &oSerializer) 
    615612{ 
     
    678675        int num_no      =       0; 
    679676 
    680         if(this->geoMesh->mSubMesh[0].mSharedVertexBuffer == true) 
     677        if(this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer == true) 
    681678        { 
    682679                //mPosition 
    683                 delete[] this->geoMesh->mVertexBuffer->mPosition; 
    684                 this->geoMesh->mVertexBuffer->mPosition = new Vector3[this->cVerts.size()]; 
     680                delete[] this->mGeoMesh->mVertexBuffer->mPosition; 
     681                this->mGeoMesh->mVertexBuffer->mPosition = new Vector3[this->cVerts.size()]; 
    685682 
    686683                //mNormal 
    687684                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    688685                { 
    689                         delete[] this->geoMesh->mVertexBuffer->mNormal; 
    690                         this->geoMesh->mVertexBuffer->mNormal = new Vector3[this->cVerts.size()]; 
     686                        delete[] this->mGeoMesh->mVertexBuffer->mNormal; 
     687                        this->mGeoMesh->mVertexBuffer->mNormal = new Vector3[this->cVerts.size()]; 
    691688                } 
    692689 
     
    694691                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    695692                { 
    696                         delete[] this->geoMesh->mVertexBuffer->mTexCoords; 
    697                         this->geoMesh->mVertexBuffer->mTexCoords = new Vector2[this->cVerts.size()]; 
    698                 } 
    699  
    700                 this->geoMesh->mVertexBuffer->mVertexCount      =       this->cVerts.size(); 
    701                 this->geoMesh->mVertexBuffer->mVertexInfo               =       this->meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo; 
    702  
    703                 for(i = 0; i < this->geoMesh->mSubMeshCount; i++) 
    704                 { 
    705                         this->geoMesh->mSubMesh[i].mVertexBuffer                                =       this->geoMesh->mVertexBuffer; 
    706                         this->geoMesh->mSubMesh[i].mSharedVertexBuffer  =       true; 
     693                        delete[] this->mGeoMesh->mVertexBuffer->mTexCoords; 
     694                        this->mGeoMesh->mVertexBuffer->mTexCoords = new Vector2[this->cVerts.size()]; 
     695                } 
     696 
     697                this->mGeoMesh->mVertexBuffer->mVertexCount     =       this->cVerts.size(); 
     698                this->mGeoMesh->mVertexBuffer->mVertexInfo              =       this->meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo; 
     699 
     700                for(i = 0; i < this->mGeoMesh->mSubMeshCount; i++) 
     701                { 
     702                        this->mGeoMesh->mSubMesh[i].mVertexBuffer                               =       this->mGeoMesh->mVertexBuffer; 
     703                        this->mGeoMesh->mSubMesh[i].mSharedVertexBuffer =       true; 
    707704                } 
    708705 
     
    712709                { 
    713710                        //Copiamos las coordeandas de posicion  
    714                         this->geoMesh->mVertexBuffer->mPosition[indice].x       =       this->cVerts[j].Vertex[0]; 
    715                         this->geoMesh->mVertexBuffer->mPosition[indice].y       =       this->cVerts[j].Vertex[1]; 
    716                         this->geoMesh->mVertexBuffer->mPosition[indice].z       =       this->cVerts[j].Vertex[2]; 
     711                        this->mGeoMesh->mVertexBuffer->mPosition[indice].x      =       this->cVerts[j].Vertex[0]; 
     712                        this->mGeoMesh->mVertexBuffer->mPosition[indice].y      =       this->cVerts[j].Vertex[1]; 
     713                        this->mGeoMesh->mVertexBuffer->mPosition[indice].z      =       this->cVerts[j].Vertex[2]; 
    717714 
    718715                        //Copiamos las normales 
    719716                        if (meshoriginal->mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    720717                        { 
    721                                 this->geoMesh->mVertexBuffer->mNormal[indice].x =       this->cVerts[j].Normal[0]; 
    722                                 this->geoMesh->mVertexBuffer->mNormal[indice].y =       this->cVerts[j].Normal[1]; 
    723                                 this->geoMesh->mVertexBuffer->mNormal[indice].z =       this->cVerts[j].Normal[2]; 
     718                                this->mGeoMesh->mVertexBuffer->mNormal[indice].x        =       this->cVerts[j].Normal[0]; 
     719                                this->mGeoMesh->mVertexBuffer->mNormal[indice].y        =       this->cVerts[j].Normal[1]; 
     720                                this->mGeoMesh->mVertexBuffer->mNormal[indice].z        =       this->cVerts[j].Normal[2]; 
    724721                        } 
    725722 
     
    727724                        if (meshoriginal->mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    728725                        { 
    729                                 this->geoMesh->mVertexBuffer->mTexCoords[indice].x      =       this->cVerts[j].TexCoords[0]; 
    730                                 this->geoMesh->mVertexBuffer->mTexCoords[indice].y      =       this->cVerts[j].TexCoords[1]; 
     726                                this->mGeoMesh->mVertexBuffer->mTexCoords[indice].x     =       this->cVerts[j].TexCoords[0]; 
     727                                this->mGeoMesh->mVertexBuffer->mTexCoords[indice].y     =       this->cVerts[j].TexCoords[1]; 
    731728                        } 
    732729 
     
    735732                } 
    736733 
    737                 this->geoMesh->mVertexBuffer->mVertexCount      =       indice; 
     734                this->mGeoMesh->mVertexBuffer->mVertexCount     =       indice; 
    738735        } 
    739736        else    //OSCAR 
     
    741738                //Supondre que solo tengo un submesh con vertices no compartidos 
    742739                //mPosition 
    743                 delete[]        this->geoMesh->mSubMesh[0].mVertexBuffer->mPosition; 
     740                delete[]        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition; 
    744741                 
    745                 this->geoMesh->mSubMesh[0].mVertexBuffer->mPosition     =       new Vector3[this->cVerts.size()]; 
     742                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition    =       new Vector3[this->cVerts.size()]; 
    746743 
    747744                //mNormal 
    748745                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    749746                { 
    750                         delete[] this->geoMesh->mSubMesh[0].mVertexBuffer->mNormal; 
    751                         this->geoMesh->mSubMesh[0].mVertexBuffer->mNormal = new Vector3[this->cVerts.size()]; 
     747                        delete[] this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal; 
     748                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal = new Vector3[this->cVerts.size()]; 
    752749                } 
    753750 
     
    755752                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    756753                { 
    757                         delete[] this->geoMesh->mSubMesh[0].mVertexBuffer->mTexCoords; 
    758                         this->geoMesh->mSubMesh[0].mVertexBuffer->mTexCoords = new Vector2[this->cVerts.size()]; 
    759                 } 
    760  
    761                 this->geoMesh->mSubMesh[0].mVertexBuffer->mVertexCount =this->cVerts.size(); 
    762                 this->geoMesh->mSubMesh[0].mVertexBuffer->mVertexInfo = this->meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo; 
    763  
    764                 this->geoMesh->mSubMesh[0].mSharedVertexBuffer=false; 
     754                        delete[] this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords; 
     755                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords = new Vector2[this->cVerts.size()]; 
     756                } 
     757 
     758                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexCount =this->cVerts.size(); 
     759                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexInfo = this->meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo; 
     760 
     761                this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer=false; 
    765762 
    766763                int indice=0; 
     
    768765                { 
    769766                        //Copiamos las coordeandas de posicion  
    770                         this->geoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].x=this->cVerts[j].Vertex[0]; 
    771                         this->geoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].y=this->cVerts[j].Vertex[1]; 
    772                         this->geoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].z=this->cVerts[j].Vertex[2]; 
     767                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].x=this->cVerts[j].Vertex[0]; 
     768                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].y=this->cVerts[j].Vertex[1]; 
     769                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].z=this->cVerts[j].Vertex[2]; 
    773770 
    774771                        //Copiamos las normales 
    775772                        if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    776773                        { 
    777                                 this->geoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].x=this->cVerts[j].Normal[0]; 
    778                                 this->geoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].y=this->cVerts[j].Normal[1]; 
    779                                 this->geoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].z=this->cVerts[j].Normal[2]; 
     774                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].x=this->cVerts[j].Normal[0]; 
     775                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].y=this->cVerts[j].Normal[1]; 
     776                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].z=this->cVerts[j].Normal[2]; 
    780777                        } 
    781778 
     
    783780                        if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    784781                        { 
    785                                 this->geoMesh->mSubMesh[0].mVertexBuffer->mTexCoords[indice].x=this->cVerts[j].TexCoords[0]; 
    786                                 this->geoMesh->mSubMesh[0].mVertexBuffer->mTexCoords[indice].y=this->cVerts[j].TexCoords[1]; 
     782                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords[indice].x=this->cVerts[j].TexCoords[0]; 
     783                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords[indice].y=this->cVerts[j].TexCoords[1]; 
    787784                        } 
    788785                        indice++; 
    789786                } 
    790                 this->geoMesh->mSubMesh[0].mVertexBuffer->mVertexCount =indice; 
     787                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexCount =indice; 
    791788        } 
    792789         
     
    794791 
    795792        int indice_acum = 0; 
    796         for(i=0;i<this->geoMesh->mSubMeshCount;i++) 
     793        for(i=0;i<this->mGeoMesh->mSubMeshCount;i++) 
    797794        { 
    798795                Geometry::SubMesh & subMesh = meshoriginal->mSubMesh[i]; 
    799                 Geometry::SubMesh & geoMeshSubMesh = this->geoMesh->mSubMesh[i]; 
     796                Geometry::SubMesh & mGeoMeshSubMesh = this->mGeoMesh->mSubMesh[i]; 
    800797 
    801798                for (size_t ind=0; ind < subMesh.mIndexCount; ind++)  
     
    807804                                if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    808805                                { 
    809                                         for (size_t indvo=0; indvo<geoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
    810                                         { 
    811                                                 if (igual(subMesh.mVertexBuffer->mPosition[indIndex],geoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
     806                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     807                                        { 
     808                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    812809                                                { 
    813                                                         if (igual(subMesh.mVertexBuffer->mNormal[indIndex],geoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
     810                                                        if (igual(subMesh.mVertexBuffer->mNormal[indIndex],mGeoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
    814811                                                        { 
    815                                                                 if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],geoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
     812                                                                if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],mGeoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
    816813                                                                { 
    817                                                                         geoMeshSubMesh.mIndex[ind]= int(indvo);//+indice_acum; 
     814                                                                        mGeoMeshSubMesh.mIndex[ind]= int(indvo);//+indice_acum; 
    818815                                                                } 
    819816                                                        } 
     
    823820                                else            //Hay coordenadas de textura pero no hay normales 
    824821                                { 
    825                                         for (size_t indvo=0; indvo<geoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
    826                                         { 
    827                                                 if (igual(subMesh.mVertexBuffer->mPosition[indIndex],geoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
     822                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     823                                        { 
     824                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    828825                                                { 
    829                                                         if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],geoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
     826                                                        if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],mGeoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
    830827                                                        { 
    831                                                                 geoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
     828                                                                mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
    832829                                                        } 
    833830                                                } 
     
    840837                                if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    841838                                { 
    842                                         for (size_t indvo=0; indvo<geoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
    843                                         { 
    844                                                 if (igual(subMesh.mVertexBuffer->mPosition[indIndex],geoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
     839                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     840                                        { 
     841                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    845842                                                { 
    846                                                         if (igual(subMesh.mVertexBuffer->mNormal[indIndex],geoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
     843                                                        if (igual(subMesh.mVertexBuffer->mNormal[indIndex],mGeoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
    847844                                                        { 
    848                                                                 geoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
     845                                                                mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
    849846                                                        } 
    850847                                                } 
     
    853850                                else            //No hay coordenadas de texturas ni normales 
    854851                                { 
    855                                         for (size_t indvo=0; indvo<geoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
    856                                         { 
    857                                                 if (igual(subMesh.mVertexBuffer->mPosition[indIndex],geoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
     852                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     853                                        { 
     854                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    858855                                                { 
    859                                                         geoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
     856                                                        mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
    860857                                                } 
    861858                                        } 
     
    887884} 
    888885 
    889 //----------------------------------------------------------------------------------------------- 
    890 //Call leeVerticesyTirasDeMesh, OrdenarModeloVQSLIM and CalcularCambiosLODsVNuevaED to make changes  
    891 //at vertex and index strutures 
    892 //Llama a los metodos que realizan los cambios sobre las estructuras que contienen la informacion  
    893 //de los vertices y los indices 
    894 //----------------------------------------------------------------------------------------------- 
    895  
     886//--------------------------------------------------------------------------- 
     887//      Call leeVerticesyTirasDeMesh, OrdenarModeloVQSLIM  
     888//      and CalcularCambiosLODsVNuevaED to make changes at vertex  
     889//      and index strutures. 
     890//--------------------------------------------------------------------------- 
    896891void LodStripsConstructor::GenerarModeloV(TIPOFUNC      upb) 
    897892{ 
     
    927922} 
    928923 
    929 //----------------------------------------------------------------------------------------- 
    930 //It fills structs with vertex and index information 
    931 //Rellena estructuras de datos que contienen la informacion de vertices y tiras modificadas 
    932 //----------------------------------------------------------------------------------------- 
     924//--------------------------------------------------------------------------- 
     925//      It fills structs with vertex and index information. 
     926//--------------------------------------------------------------------------- 
    933927void LodStripsConstructor::CopiarVectors2ArraysNUEVAED() 
    934928{ 
     
    1002996} 
    1003997 
    1004 //--------------------------------------------------------------------------------------------------- 
    1005 //It fills cVerts and cStrips with original Mesh vertex and strips information  
    1006 //Rellena las estructuras cVerts Y cStrips a partir de de los vertices y las tiras del mesh original 
    1007 //--------------------------------------------------------------------------------------------------- 
     998//--------------------------------------------------------------------------- 
     999//      It fills cVerts and cStrips with original Mesh vertex and strips  
     1000//      information. 
     1001//--------------------------------------------------------------------------- 
    10081002void LodStripsConstructor::leeVerticesyTirasDeMesh() 
    10091003{ 
     
    10161010        error   =       false; 
    10171011         
    1018         if(this->geoMesh->mSubMeshCount == 1) 
     1012        if(this->mGeoMesh->mSubMeshCount == 1) 
    10191013        { 
    10201014                error   =       false; 
     
    10221016        else 
    10231017        { 
    1024                 for     (i = 0; i < this->geoMesh->mSubMeshCount;i++) 
    1025                 { 
    1026                         if      (this->geoMesh->mSubMesh[i].mSharedVertexBuffer == true) 
     1018                for     (i = 0; i < this->mGeoMesh->mSubMeshCount;i++) 
     1019                { 
     1020                        if      (this->mGeoMesh->mSubMesh[i].mSharedVertexBuffer == true) 
    10271021                        { 
    10281022                                error   =       false; 
     
    10381032        if(!error) 
    10391033        { 
    1040                 if      (       (this->geoMesh->mSubMesh[0].mSharedVertexBuffer == true) 
     1034                if      (       (this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer == true) 
    10411035                                        && 
    1042                                         (this->geoMesh->mSubMeshCount > 1) 
     1036                                        (this->mGeoMesh->mSubMeshCount > 1) 
    10431037                                ) 
    10441038                { 
    1045                         for     (j = 0; j < this->geoMesh->mVertexBuffer->mVertexCount; j++) 
     1039                        for     (j = 0; j < this->mGeoMesh->mVertexBuffer->mVertexCount; j++) 
    10461040                        { 
    10471041                                //      Si hay mas de un submesh ListaIndices no se rellena correctamente 
    1048                                 vAux.Vertex[0] = this->geoMesh->mVertexBuffer->mPosition[j].x; 
    1049                                 vAux.Vertex[1] = this->geoMesh->mVertexBuffer->mPosition[j].y; 
    1050                                 vAux.Vertex[2] = this->geoMesh->mVertexBuffer->mPosition[j].z; 
     1042                                vAux.Vertex[0] = this->mGeoMesh->mVertexBuffer->mPosition[j].x; 
     1043                                vAux.Vertex[1] = this->mGeoMesh->mVertexBuffer->mPosition[j].y; 
     1044                                vAux.Vertex[2] = this->mGeoMesh->mVertexBuffer->mPosition[j].z; 
    10511045 
    10521046                                //      Añadimos las normales en cVerts. 
    1053                                 if      (       this->geoMesh->mVertexBuffer->mVertexInfo 
     1047                                if      (       this->mGeoMesh->mVertexBuffer->mVertexInfo 
    10541048                                                        & 
    10551049                                                        Geometry::VERTEX_NORMAL 
    10561050                                                ) 
    10571051                                { 
    1058                                         vAux.Normal[0] = this->geoMesh->mVertexBuffer->mNormal[j].x; 
    1059                                         vAux.Normal[1] = this->geoMesh->mVertexBuffer->mNormal[j].y; 
    1060                                         vAux.Normal[2] = this->geoMesh->mVertexBuffer->mNormal[j].z; 
     1052                                        vAux.Normal[0] = this->mGeoMesh->mVertexBuffer->mNormal[j].x; 
     1053                                        vAux.Normal[1] = this->mGeoMesh->mVertexBuffer->mNormal[j].y; 
     1054                                        vAux.Normal[2] = this->mGeoMesh->mVertexBuffer->mNormal[j].z; 
    10611055                                } 
    10621056 
    10631057                                //      Añadimos las coordenadas de textura a cVerts. 
    1064                                 if      (       this->geoMesh->mVertexBuffer->mVertexInfo 
     1058                                if      (       this->mGeoMesh->mVertexBuffer->mVertexInfo 
    10651059                                                        & 
    10661060                                                        Geometry::VERTEX_TEXCOORDS 
    10671061                                                ) 
    10681062                                { 
    1069                                         vAux.TexCoords[0] = this->geoMesh->mVertexBuffer->mTexCoords[j].x; 
    1070                                         vAux.TexCoords[1] = this->geoMesh->mVertexBuffer->mTexCoords[j].y; 
     1063                                        vAux.TexCoords[0] = this->mGeoMesh->mVertexBuffer->mTexCoords[j].x; 
     1064                                        vAux.TexCoords[1] = this->mGeoMesh->mVertexBuffer->mTexCoords[j].y; 
    10711065                                } 
    10721066 
     
    10811075                else 
    10821076                { 
    1083                         for     (i = 0; i < this->geoMesh->mSubMeshCount; i++) 
     1077                        for     (i = 0; i < this->mGeoMesh->mSubMeshCount; i++) 
    10841078                        { 
    10851079                                for     (       j = 0; 
    1086                                                 j < this->geoMesh->mSubMesh[i].mVertexBuffer->mVertexCount; 
     1080                                                j < this->mGeoMesh->mSubMesh[i].mVertexBuffer->mVertexCount; 
    10871081                                                j++) 
    10881082                                { 
    10891083                                        //      Si hay mas de un submesh ListaIndices  
    10901084                                        //      no se rellena correctamente. 
    1091                                         vAux.Vertex[0] = this->geoMesh->mSubMesh[i]. 
     1085                                        vAux.Vertex[0] = this->mGeoMesh->mSubMesh[i]. 
    10921086                                                mVertexBuffer->mPosition[j].x; 
    1093                                         vAux.Vertex[1] = this->geoMesh->mSubMesh[i]. 
     1087                                        vAux.Vertex[1] = this->mGeoMesh->mSubMesh[i]. 
    10941088                                                mVertexBuffer->mPosition[j].y; 
    1095                                         vAux.Vertex[2] = this->geoMesh->mSubMesh[i]. 
     1089                                        vAux.Vertex[2] = this->mGeoMesh->mSubMesh[i]. 
    10961090                                                mVertexBuffer->mPosition[j].z; 
    10971091                                        //      Añadimos las normales en cVerts. 
    1098                                         vAux.Normal[0] = this->geoMesh->mSubMesh[i]. 
     1092                                        vAux.Normal[0] = this->mGeoMesh->mSubMesh[i]. 
    10991093                                                mVertexBuffer->mNormal[j].x; 
    1100                                         vAux.Normal[1] = this->geoMesh->mSubMesh[i]. 
     1094                                        vAux.Normal[1] = this->mGeoMesh->mSubMesh[i]. 
    11011095                                                mVertexBuffer->mNormal[j].y; 
    1102                                         vAux.Normal[2] = this->geoMesh->mSubMesh[i]. 
     1096                                        vAux.Normal[2] = this->mGeoMesh->mSubMesh[i]. 
    11031097                                                mVertexBuffer->mNormal[j].z; 
    11041098 
    11051099                                        //      Añadimos las coordenadas de textura a cVerts. 
    1106                                         vAux.TexCoords[0]       =       this->geoMesh->mSubMesh[i]. 
     1100                                        vAux.TexCoords[0]       =       this->mGeoMesh->mSubMesh[i]. 
    11071101                                                mVertexBuffer->mTexCoords[j].x; 
    1108                                         vAux.TexCoords[1] = this->geoMesh->mSubMesh[i]. 
     1102                                        vAux.TexCoords[1] = this->mGeoMesh->mSubMesh[i]. 
    11091103                                                mVertexBuffer->mTexCoords[j].y; 
    11101104 
     
    11221116                num_vert        =       0; 
    11231117                 
    1124                 for     (i = 0; i < this->geoMesh->mSubMeshCount; i++) 
     1118                for     (i = 0; i < this->mGeoMesh->mSubMeshCount; i++) 
    11251119                { 
    11261120                        //      If is not the leaves submesh. 
     
    11291123                                indice_acum     =       0; 
    11301124 
    1131                                 for     (j = 0; j < this->geoMesh->mSubMesh[i].mStripCount; j++) 
    1132                                 { 
    1133                                         Index   *aux    =       this->geoMesh->mSubMesh[i].mStrip[j]; 
     1125                                for     (j = 0; j < this->mGeoMesh->mSubMesh[i].mStripCount; j++) 
     1126                                { 
     1127                                        Index   *aux    =       this->mGeoMesh->mSubMesh[i].mStrip[j]; 
    11341128 
    11351129                                        /* 
     
    11431137                                        */ 
    11441138 
    1145                                         if (j+1 < this->geoMesh->mSubMesh[i].mStripCount) 
    1146                                         { 
    1147                                                 Index   *siguiente      =       this->geoMesh->mSubMesh[i].mStrip[j+1]; 
     1139                                        if (j+1 < this->mGeoMesh->mSubMesh[i].mStripCount) 
     1140                                        { 
     1141                                                Index   *siguiente      =       this->mGeoMesh->mSubMesh[i].mStrip[j+1]; 
    11481142 
    11491143                                                tira.clear(); 
     
    11671161 
    11681162                                                for     (       unsigned int k = indice_acum; 
    1169                                                                 k < this->geoMesh->mSubMesh[i].mIndexCount; 
     1163                                                                k < this->mGeoMesh->mSubMesh[i].mIndexCount; 
    11701164                                                                k++) 
    11711165                                                { 
    1172                                                         tira.push_back(this->geoMesh->mSubMesh[i].mIndex[k]); 
     1166                                                        tira.push_back(this->mGeoMesh->mSubMesh[i].mIndex[k]); 
    11731167                                                } 
    11741168 
     
    11771171                                } 
    11781172 
    1179                                 num_vert        +=      int(this->geoMesh->mSubMesh[i]. 
     1173                                num_vert        +=      int(this->mGeoMesh->mSubMesh[i]. 
    11801174                                        mVertexBuffer->mVertexCount); 
    11811175                        } 
     
    11911185} 
    11921186 
     1187//--------------------------------------------------------------------------- 
    11931188//      GetMesh: Return de current Mesh. 
     1189//--------------------------------------------------------------------------- 
    11941190Mesh    *       LodStripsConstructor::GetMesh() 
    11951191{ 
     
    11971193 
    11981194        mesh_built              =       new Mesh(); 
    1199         *mesh_built             =       *geoMesh; 
     1195        *mesh_built             =       *mGeoMesh; 
    12001196 
    12011197        return  mesh_built; 
    12021198} 
    12031199 
     1200//--------------------------------------------------------------------------- 
    12041201// Sets what is the submesh that stores the leaves. 
     1202//--------------------------------------------------------------------------- 
    12051203void LodStripsConstructor::SetSubMeshLeaves(size_t      submesh) 
    12061204{ 
     
    12081206} 
    12091207 
     1208//--------------------------------------------------------------------------- 
     1209//      Sort submesh bones. 
     1210//--------------------------------------------------------------------------- 
     1211void LodStripsConstructor::sortBones() 
     1212{ 
     1213        bool                                                                    shared_found; 
     1214        int                                                                             n; 
     1215        int                                                                             o; 
     1216        int                                                                             p; 
     1217        VertexBoneAssignment    assign; 
     1218        SubMesh                                                         *submesh; 
     1219        SubMesh                                                         *copysubmesh; 
     1220        VertexBuffer                                    *mesh_vb; 
     1221        VertexBuffer                                    *copy_vb; 
     1222 
     1223        std::vector<VertexBoneAssignment>       *mesh_bones; 
     1224        std::vector<VertexBoneAssignment>       *copy_bones; 
     1225 
     1226        //      Initialize shared vertex flag. 
     1227        shared_found    =       false; 
     1228 
     1229        //      For each submesh. 
     1230        for (size_t     i = 0;  i       <       mGeoMesh->mSubMeshCount;        i++) 
     1231        { 
     1232                submesh                 =       &mGeoMesh->mSubMesh[i]; 
     1233                copysubmesh     =       &mInitialMesh->mSubMesh[i]; 
     1234 
     1235                //      If submesh has shared vertex. 
     1236                if (submesh->mSharedVertexBuffer) 
     1237                { 
     1238                        if (shared_found) 
     1239                        { 
     1240                                continue; 
     1241                        } 
     1242 
     1243                        shared_found    =       true; 
     1244                         
     1245                        //      Vertex buffers. 
     1246                        mesh_vb =       mGeoMesh->mVertexBuffer; 
     1247                        copy_vb =       mInitialMesh->mVertexBuffer; 
     1248 
     1249                        //      Bones. 
     1250                        mesh_bones      =       &mGeoMesh->mBones; 
     1251                        copy_bones      =       &mInitialMesh->mBones; 
     1252                } 
     1253                else 
     1254                { 
     1255                        //      Vertex buffers. 
     1256                        mesh_vb =       submesh->mVertexBuffer; 
     1257                        copy_vb =       copysubmesh->mVertexBuffer; 
     1258 
     1259                        //      Bones. 
     1260                        mesh_bones      =       &submesh->mBones; 
     1261                        copy_bones      =       &copysubmesh->mBones; 
     1262                } 
     1263                 
     1264                if (!mesh_bones->empty()) 
     1265                { 
     1266                        assign.boneIndex        =       0; 
     1267                        assign.weight                   =       1; 
     1268 
     1269                        for (   size_t  m = copy_vb->mVertexCount; 
     1270                                                m < mesh_vb->mVertexCount; 
     1271                                                m++) 
     1272                        { 
     1273                                assign.vertexIndex      =       (unsigned int)m; 
     1274                                 
     1275                                mesh_bones->push_back(assign); 
     1276                        } 
     1277 
     1278                        //      Change bones. 
     1279                        for (size_t     m = 0;  m < mesh_bones->size(); m++) 
     1280                        { 
     1281                                n       =       (*mesh_bones)[m].vertexIndex; 
     1282 
     1283                                o       =       0; 
     1284                                 
     1285                                while (!(       (mesh_vb->mPosition[n].x == copy_vb->mPosition[o].x) 
     1286                                                                        && 
     1287                                                                        (mesh_vb->mPosition[n].y == copy_vb->mPosition[o].y) 
     1288                                                                        && 
     1289                                                                        (mesh_vb->mPosition[n].z == copy_vb->mPosition[o].z))) 
     1290                                { 
     1291                                        o++; 
     1292                                } 
     1293 
     1294                                p = 0; 
     1295                                 
     1296                                while ((*copy_bones)[p].vertexIndex != o) 
     1297                                { 
     1298                                        p++; 
     1299                                } 
     1300 
     1301                                //      Same bone for 'm' and 'p'. 
     1302                                (*mesh_bones)[m].boneIndex      =       (*copy_bones)[p].boneIndex; 
     1303                        } 
     1304 
     1305                        //      Look for repeated bones. 
     1306                        for (size_t     m       =       0;      m < mesh_vb->mVertexCount;      m++) 
     1307                        { 
     1308                                for (size_t     n       =       m + 1;  n < mesh_vb->mVertexCount;      n++) 
     1309                                { 
     1310                                        if ((mesh_vb->mPosition[m].x == mesh_vb->mPosition[n].x) 
     1311                                                        && 
     1312                                                        (mesh_vb->mPosition[m].y == mesh_vb->mPosition[n].y) 
     1313                                                        && 
     1314                                                        (mesh_vb->mPosition[m].z == mesh_vb->mPosition[n].z)) 
     1315                                        { 
     1316                                                o       =       0; 
     1317                                                 
     1318                                                while ((*mesh_bones)[o].vertexIndex != m) 
     1319                                                { 
     1320                                                        o++; 
     1321                                                } 
     1322 
     1323                                                p       =       0; 
     1324                                                 
     1325                                                while ((*mesh_bones)[p].vertexIndex != n) 
     1326                                                { 
     1327                                                        p++; 
     1328                                                } 
     1329 
     1330                                                if ((*mesh_bones)[o].boneIndex != (*mesh_bones)[p].boneIndex) 
     1331                                                { 
     1332                                                        printf("-->Error en los vertices %d y %d\n",m,n); 
     1333                                                } 
     1334                                        } 
     1335                                } 
     1336                        } 
     1337                } 
     1338        } 
     1339} 
     1340 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp

    r1069 r1070  
    8383        uint32                                                                          return_value; 
    8484 
    85         uint32 newLOD = (1.0f-lodfactor) * mLods; 
     85        uint32 newLOD = (uint32)((1.0f - lodfactor) * mLods); 
    8686     
    8787        //      Initialize the return value to the current LOD. 
     
    352352void LodStripsLibrary::CopyVectors2Arrays() 
    353353{ 
    354         unsigned int                    i; 
    355         unsigned int                    j; 
    356354        SmallInt                                        max; 
    357355        SmallInt                                        t; 
     
    372370//      unsigned int * strip_sizes = new unsigned int[mFileStrips.size()]; 
    373371        unsigned int total_strip_size = 0; 
    374         for (i = 0; i < mFileStrips.size(); i++) 
     372         
     373        for (unsigned   int     i = 0; i < mFileStrips.size(); i++) 
    375374        { 
    376375                total_strip_size += t = int(mFileStrips[i].size()); 
     
    383382         
    384383        //      Fill up changes array. 
    385         for (i = 0; i < mFileChangesLOD.size(); ++i) 
     384        for (unsigned   int     i = 0; i < mFileChangesLOD.size(); ++i) 
    386385        { 
    387386                changes_array[i]        =       mFileChangesLOD[i]; 
     
    392391        //      Copy strips. 
    393392        dataRetrievalInterface=create_index_data_func(total_strip_size); 
    394         dataRetrievalInterface->Begin();         
    395         for (int ii = 0, i = 0; i < mFileStrips.size(); i++) 
    396         { 
    397                 for (j = 0; j < mFileStrips[i].size(); j++,ii++) 
     393        dataRetrievalInterface->Begin(); 
     394 
     395        unsigned        int     ii = 0; 
     396 
     397        for (unsigned   int     i = 0; i < mFileStrips.size(); i++) 
     398        { 
     399                for (unsigned   int     j = 0; j < mFileStrips[i].size(); j++,ii++) 
    398400                { 
    399401                        mStrips[i].push_back(mFileStrips[i][j]); 
     
    406408        dataRetrievalInterface->End(); 
    407409 
    408         for (i = 0; i < mData.size(); i++) 
     410        for (unsigned   int     i = 0; i < mData.size(); i++) 
    409411        { 
    410412                data_array[i]   =       mData[i]; 
     
    414416 
    415417        //      Fill up mVertex. 
    416         for(i = 0; i < mFileVertices.size(); i++) 
     418        for(unsigned    int     i = 0; i < mFileVertices.size(); i++) 
    417419        { 
    418420                mVertex[i]      =       mFileVertices[i]; 
     
    444446        SubMesh                                                                                                         *geoSubMesh; 
    445447 
    446  
    447  
    448448        //      For each one of the submeshes. 
    449449        for (unsigned int submesh       =       0; submesh < geomesh->mSubMeshCount; submesh++) 
     
    496496        } 
    497497 
     498        //      TODO:   LOD file loaded in load file mesh process. 
    498499        //      Open the LOD file. 
    499500        if ((fp = fopen (name, "r")) == NULL) 
     
    574575} 
    575576 
    576  
    577577void LodStripsLibrary::UpdateDataRetrievalInterface(void) 
    578578{ 
     579        unsigned        int     ii      =       0; 
     580         
    579581        dataRetrievalInterface->Begin(); 
    580         for (int i=0, ii=0; i<mTotalStrips; i++) 
     582 
     583        for (unsigned   int i=0; i<mTotalStrips; i++) 
    581584        { 
    582585                for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, ii++) 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp

    r1069 r1070  
    8989void LodTreeLibrary::GoToFoliageLod(float newlod) 
    9090{ 
    91         uint32 targetLeaves = (1.0f-newlod)*foliage->minLeaves + newlod*foliage->leafCount; 
     91        uint32 targetLeaves = (uint32) 
     92                                                                                                ( 
     93                                                                                                        (1.0f - newlod) 
     94                                                                                                        * 
     95                                                                                                        foliage->minLeaves 
     96                                                                                                        + 
     97                                                                                                        newlod 
     98                                                                                                        * 
     99                                                                                                        foliage->leafCount 
     100                                                                                                ); 
     101 
    92102        foliage->CalculateLOD(targetLeaves); 
    93103 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMesh.cpp

    r1009 r1070  
    514514                } 
    515515                 
     516                //      Shared bones. 
     517                if (!mSubMesh[i].mBones.empty()) 
     518                { 
     519                        for (unsigned int j = 0; j < mSubMesh[i].mBones.size(); j++) 
     520                        { 
     521                                mesh->mBones.push_back(mSubMesh[i].mBones[j]); 
     522                                 
     523                                mesh->mBones.back().vertexIndex += acumVerts; 
     524                        } 
     525                } 
     526 
    516527                acumVerts       +=      long(mSubMesh[i].mVertexBuffer->mVertexCount); 
    517  
    518                 //      Copy submesh bones. 
    519                 if (!mSubMesh[i].mBones.empty()) 
    520                 { 
    521                         for (unsigned int j = 0; j < mSubMesh[i].mBones.size(); j++) 
    522                         { 
    523                                 mesh->mSubMesh[i].mBones.push_back(mSubMesh[i].mBones[j]); 
    524                         } 
    525                 } 
    526  
    527528        } 
    528529 
     
    535536        } 
    536537 
     538        /* 
    537539        //      Copy mesh bones. 
    538540        if (!mBones.empty()) 
     
    543545                } 
    544546        } 
     547        */ 
    545548 
    546549        return mesh; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp

    r1024 r1070  
    2020                                                                                                                                TIPOFUNC                upb) 
    2121{ 
     22        //      Saves initial state of mesh. 
     23        mInitialMesh    =       new Mesh(); 
     24        *mInitialMesh   =       *m; 
     25         
    2226        objmesh                                 =       m; 
    2327        mGeoMesh                                =       NULL; 
     
    3438MeshSimplifier::~MeshSimplifier() 
    3539{ 
    36         delete msimpsequence; 
     40        delete  mInitialMesh; 
     41        delete  msimpsequence; 
    3742} 
    3843 
     
    6671void    MeshSimplifier::sortBones() 
    6772{ 
    68         Mesh                                                                    *mesh_copy; 
     73        bool                                                                    shared_found; 
    6974        int                                                                             n; 
    7075        int                                                                     o; 
     
    7277        VertexBoneAssignment    assign; 
    7378        VertexBuffer                                    *mesh_vb; 
    74         VertexBuffer                                    *undo_vb; 
     79        VertexBuffer                                    *copy_vb; 
    7580        SubMesh                                                         *geosubmesh; 
    76         SubMesh                                                         *undosubmesh; 
    77          
    78         //      Gets a copy of the mesh. 
    79         mesh_copy               =       new Mesh(); 
    80         *mesh_copy      =       *mGeoMesh; 
    81          
     81        SubMesh                                                         *copysubmesh; 
     82 
     83        std::vector<VertexBoneAssignment>       *mesh_bones; 
     84        std::vector<VertexBoneAssignment>       *copy_bones; 
     85         
     86        //      Initialize shared flag. 
     87        shared_found    =       false; 
     88 
    8289        //      For each submesh. 
    8390        for (size_t     i       =       0; i < mGeoMesh->mSubMeshCount; i++) 
    8491        { 
    8592                geosubmesh      =       &mGeoMesh->mSubMesh[i]; 
    86                 undosubmesh     =       &mesh_copy->mSubMesh[i]; 
     93                copysubmesh     =       &mInitialMesh->mSubMesh[i]; 
     94 
     95                //      If submesh has shared vertex. 
     96                if (geosubmesh->mSharedVertexBuffer) 
     97                { 
     98                        if (shared_found) 
     99                        { 
     100                                continue; 
     101                        } 
     102 
     103                        shared_found    =       true; 
     104                         
     105                        //      Vertex buffers. 
     106                        mesh_vb =       mGeoMesh->mVertexBuffer; 
     107                        copy_vb =       mInitialMesh->mVertexBuffer; 
     108 
     109                        //      Bones. 
     110                        mesh_bones      =       &mGeoMesh->mBones; 
     111                        copy_bones      =       &mInitialMesh->mBones; 
     112                } 
     113                else 
     114                { 
     115                        //      Vertex buffers. 
     116                        mesh_vb =       geosubmesh->mVertexBuffer; 
     117                        copy_vb =       copysubmesh->mVertexBuffer; 
     118 
     119                        //      Bones. 
     120                        mesh_bones      =       &geosubmesh->mBones; 
     121                        copy_bones      =       &copysubmesh->mBones; 
     122                } 
    87123                 
    88124                //      If there is submesh bones. 
    89                 if (!geosubmesh->mBones.empty()) 
     125                if (!mesh_bones->empty()) 
    90126                { 
    91127                        assign.boneIndex        =       0; 
    92128                        assign.weight                   =       1; 
    93129 
    94                         geosubmesh->mBones.clear(); 
    95  
    96                         for (int        m       =       0;      m < geosubmesh->mVertexBuffer->mVertexCount;    m++) 
     130                        mesh_bones->clear(); 
     131 
     132                        for (size_t     m       =       0;      m < mesh_vb->mVertexCount;      m++) 
    97133                        { 
    98                                 assign.vertexIndex      =       m; 
     134                                assign.vertexIndex      =       (int)m; 
    99135                                 
    100                                 geosubmesh->mBones.push_back(assign); 
     136                                mesh_bones->push_back(assign); 
    101137                        } 
    102138 
    103139                        //      Change bones. 
    104                         for (int        m = 0;  m < geosubmesh->mBones.size();  m++) 
     140                        for (size_t     m = 0;  m < mesh_bones->size(); m++) 
    105141                        { 
    106                                 n       =       geosubmesh->mBones[m].vertexIndex; 
     142                                n       =       (*mesh_bones)[m].vertexIndex; 
    107143 
    108144                                //      Initialize o. 
    109145                                o       =       0; 
    110146 
    111                                 mesh_vb =       geosubmesh->mVertexBuffer; 
    112                                 undo_vb =       undosubmesh->mVertexBuffer; 
    113  
    114147                                while (!( 
    115                                                         (mesh_vb->mPosition[n].x == undo_vb->mPosition[o].x) 
     148                                                        (mesh_vb->mPosition[n].x == copy_vb->mPosition[o].x) 
    116149                                                        && 
    117                                                         (mesh_vb->mPosition[n].y == undo_vb->mPosition[o].y) 
     150                                                        (mesh_vb->mPosition[n].y == copy_vb->mPosition[o].y) 
    118151                                                        && 
    119                                                         (mesh_vb->mPosition[n].z == undo_vb->mPosition[o].z) 
     152                                                        (mesh_vb->mPosition[n].z == copy_vb->mPosition[o].z) 
    120153                                                        )) 
    121154                                { 
     
    126159                                p       =       0; 
    127160 
    128                                 while (undosubmesh->mBones[p].vertexIndex != o) 
     161                                while ((*copy_bones)[p].vertexIndex != o) 
    129162                                { 
    130163                                        p++; 
     
    132165 
    133166                                //      Same bone for 'm' and 'p'. 
    134                                 geosubmesh->mBones[m].boneIndex =       undosubmesh->mBones[p].boneIndex; 
     167                                (*mesh_bones)[m].boneIndex      =       (*copy_bones)[p].boneIndex; 
    135168                        } 
    136169                } 
    137170        } 
    138171 
    139         //      Delete copy of the mesh. 
    140         delete  mesh_copy; 
    141172} 
    142173 
     
    176207        mGeoMesh        =       m_qslim->GetMesh(); 
    177208         
     209        //      Sort bones. 
     210        sortBones(); 
     211         
    178212        delete  m_qslim; 
    179213} 
     
    191225 
    192226        mGeoMesh        =       m_qslim->GetMesh(); 
     227         
     228        //      Sort bones. 
     229        sortBones(); 
    193230         
    194231        delete m_qslim; 
     
    278315 
    279316        VMI::initialIs  =       VMI::initIs(VMI::numCameras); 
    280  
    281317} 
    282318 
     
    313349        loadMesh(); 
    314350 
     351        //      Sort bones. 
     352        sortBones(); 
     353         
    315354        GetMeshSimpSequence(); 
    316355} 
     
    339378        loadMesh(); 
    340379 
     380        //      Sort bones. 
     381        sortBones(); 
     382         
    341383        GetMeshSimpSequence(); 
    342384} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshStripifier.cpp

    r1009 r1070  
    3636 
    3737//----------------------------------------------------------------------------- 
    38 ///     AddHead. 
     38//      AddHead. 
    3939//----------------------------------------------------------------------------- 
    4040BOOL CustomStripifier::AddHead(PLISTHEAD LHead, PLISTINFO LInfo) 
     
    84528452                        { 
    84538453                                v_indices                                                               =               mi_vector[i]; 
    8454                                 geoSubMesh->mIndexCount +=      v_indices.size() /*+ 2*/; 
    8455  
    8456                                 /* 
     8454                                geoSubMesh->mIndexCount +=      v_indices.size() + 2; 
     8455 
    84578456                                //      Insert a new vertex if the strip es odd. 
    84588457                                if(oddStrip) 
     
    84708469                                        oddStrip        =       FALSE; 
    84718470                                } 
    8472                                 */ 
    84738471                        } 
    84748472 
     
    84838481                        //      Obtiene el total de indices de la primera strip. 
    84848482                        //geoSubMesh->mIndexCount       =       v_indices.size(); 
    8485  
    8486  
    84878483 
    84888484                        //      Copia la primera tira en el array de indices. 
     
    85038499                        //----------------------- 
    85048500 
    8505                         /* 
    85068501                        //      Number of vertices of a strip odd or even. 
    85078502                        if(v_indices.size() % 2) 
     
    85138508                                oddStrip        =       FALSE; 
    85148509                        } 
    8515                         */ 
    85168510 
    85178511                        //      Para todas las tiras menos la primera. 
    85188512                        for(i   =       2;      i <= num_tiras; i++) 
    85198513                        { 
    8520                                  
    85218514                                /*      copia en el inicio de la tira el final de la anterior. 
    85228515                                                triangulos degenerados. */ 
    8523                                 /* 
    85248516                                geoSubMesh->mIndex[totalStripIndices++] =       geoSubMesh-> 
    85258517                                        mIndex[totalStripIndices-1]; 
    8526                                 */ 
    85278518 
    85288519                                v_indices                                                               =       mi_vector[i]; 
    8529  
    8530                                 //geoSubMesh->mIndexCount       =       geoSubMesh->mIndexCount +       v_indices.size() + 2; 
    85318520 
    85328521                                /*      copia el inicio de la tira 2 veces. 
    85338522                                                triangulos degenerados. 
    85348523                                                */ 
    8535                                  
    85368524                                geoSubMesh->mIndex[totalStripIndices++] =       v_indices[0]; 
    85378525 
     
    85408528 
    85418529                                //      Triangulo Degenerado. 
    8542                                 //geoSubMesh->mIndex[totalStripIndices++]       =       v_indices[0]; 
    8543  
    8544                                 /* 
     8530                                geoSubMesh->mIndex[totalStripIndices++] =       v_indices[0]; 
     8531 
    85458532                                //      Insert a new vertex if the strip es odd. 
    85468533                                if(oddStrip) 
    85478534                                { 
    8548                                         //      geoSubMesh->mIndexCount++; 
    85498535                                        geoSubMesh->mIndex[totalStripIndices++] =       v_indices[0]; 
    85508536                                } 
     
    85598545                                        oddStrip        =       FALSE; 
    85608546                                } 
    8561                                 */ 
    85628547                                 
    85638548                                //      Copia la tira en curso en el array de indices. 
    8564                                 for(j=1;j<v_indices.size();j++) 
     8549                                for(j   =       1;      j < v_indices.size();   j++) 
    85658550                                { 
    85668551                                        geoSubMesh->mIndex[totalStripIndices++] =       v_indices[j]; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoTreeSimplifier.cpp

    r1019 r1070  
    136136void TreeSimplifier::Mesh2Structure(const Mesh *mesh, Index meshLeaves) 
    137137{ 
    138         long int countv=0; 
    139         long int pos=0; 
    140         long int v1, v2, v3; 
    141         long int triangleID=0; 
     138        size_t          countv=0; 
     139        long int        pos=0; 
     140        long int        v1, v2, v3; 
     141        long int        triangleID=0; 
    142142 
    143143        countv += vertex_count = mesh->mSubMesh[meshLeaves].mVertexBuffer->mVertexCount;         
    144144        Vertex  = new float[2*countv][3]; 
    145145                 
    146         int update_each = mesh->mSubMesh[meshLeaves].mVertexBuffer->mVertexCount/5; 
     146        size_t  update_each = mesh->mSubMesh[meshLeaves].mVertexBuffer->mVertexCount/5; 
    147147         
    148148        for (unsigned int j=0; j<mesh->mSubMesh[meshLeaves].mVertexBuffer->mVertexCount; j++) 
    149149        { 
    150                 static int ticks_since_last_update = 0; 
     150                static size_t   ticks_since_last_update = 0; 
    151151                if (mUPB && ticks_since_last_update>=update_each) 
    152152                { 
     
    179179        for (unsigned int j=0; j<mesh->mSubMesh[meshLeaves].mIndexCount; j=j+6)  
    180180        { 
    181                 static int ticks_since_last_update = 0; 
     181                static size_t   ticks_since_last_update = 0; 
    182182                if (mUPB && ticks_since_last_update>=update_each) 
    183183                { 
     
    11931193 
    11941194        // calcualte the limits of the octree 
    1195         for (int i=0; i<vertex_count; i++) 
     1195        for (size_t     i       =       0; i < vertex_count; i++) 
    11961196        { 
    11971197                if (leafoctree->left>Vertex[i][0]) 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshLoader.h

    r1050 r1070  
    33 *      ========================================================================== 
    44 *      PROYECT:        GAME TOOLS 
    5  *      =========================================================================*/ 
    6 /**     CONTENT:         
    7         * 
    8         * 
    9         *       @file   GeoMeshLoader.h 
    10 /*===========================================================================*/ 
     5 *      ========================================================================== 
     6 *      CONTENT:         
     7 * 
     8 * 
     9 *      @file   GeoMeshLoader.h 
     10 *===========================================================================*/ 
    1111#ifndef __GEO_MESH_LOADER__ 
    1212#define __GEO_MESH_LOADER__ 
     
    6464                VET_SHORT2, 
    6565                VET_SHORT3, 
    66                 VET_SHORT4,  
     66                VET_SHORT4, 
    6767                VET_UBYTE4 
    6868        }; 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp

    r1050 r1070  
    426426        } 
    427427         
    428         list.clear();  
     428        list.clear(); 
    429429 
    430430        //      Gets material name. 
     
    879879 
    880880        //      Remove degenerate triangles of a submesh given. 
    881         geoSubMesh      =       removeDegenerateTriangles(geoSubMesh); 
     881        //geoSubMesh    =       removeDegenerateTriangles(geoSubMesh); 
    882882 
    883883        return  geoSubMesh; 
     
    910910        indices =       new     Index[new_index_count]; 
    911911 
    912         //      Initialize the current index; 
     912        //      Initialize the current index. 
    913913        current_index   =       0; 
    914914         
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp

    r1024 r1070  
    2323GeoMeshSaver::GeoMeshSaver() 
    2424{ 
    25         leavesSubMesh=-1; 
    26         leavesVB=NULL; 
    27         numindices=0; 
    28         indices=NULL; 
     25        leavesSubMesh   =       -1; 
     26        leavesVB                        =       NULL; 
     27        numindices              =       0; 
     28        indices                         =       NULL; 
    2929} 
    3030 
     
    147147        } 
    148148 
    149         //OSCAR 
    150149        // Write skeleton info if required 
    151150        if (geoMesh->hasSkeleton) 
     
    158157                { 
    159158 
    160                         for (int i=0; i< geoMesh->mBones.size(); i++) 
     159                        for (int i = 0; i< geoMesh->mBones.size(); i++) 
    161160                        { 
    162161                                writeMeshBoneAssignment(geoMesh->mBones[i]); 
     
    206205        Index                                           *indexBegin; 
    207206        Index                                           *indexEnd; 
    208          
     207 
    209208        // Header. 
    210209        writeChunkHeader(M_SUBMESH, calcSubMeshSize(geoSubMesh)); 
     
    222221 
    223222        indexCount      =       geoSubMesh->mIndexCount; 
    224  
     223         
     224        /* 
    225225        //      If the submesh is in triangle strips. 
    226226        if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 
    227227        { 
    228                 indexCount      +=      2 * geoSubMesh->mStripCount - 2; 
    229         } 
     228                indexCount      +=      (2 * geoSubMesh->mStripCount) 
     229                                                                                - 
     230                                                                                2; 
     231        } 
     232        */ 
    230233         
    231234        //      Write index count. 
     
    236239        writeBools(idx32bit, 1); 
    237240 
     241        /* 
    238242        //      If the submesh is in triangle strips. 
    239243        if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 
     
    260264                        i       = 0; 
    261265 
     266                        //      Degenerate. 
    262267                        if (strip != 0) 
    263268                        { 
     
    274279                        } 
    275280 
     281                        //      Degenerate. 
    276282                        if (strip       != (geoSubMesh->mStripCount - 1)) 
    277283                        { 
    278284                                writeInts(indexBegin[i - 1], 1); 
    279285                        } 
    280  
    281286                } 
    282287        } 
     
    284289        else 
    285290        { 
     291        */ 
    286292                //      Write the index array. 
    287293                for (int i = 0; i < geoSubMesh->mIndexCount; i++) 
     
    289295                        writeInts(geoSubMesh->mIndex[i], 1); 
    290296                } 
    291         } 
     297        //} 
    292298 
    293299        // M_GEOMETRY stream (Optional: present only if useSharedVertices = false) 
     
    300306        writeSubMeshOperation(geoSubMesh); 
    301307 
    302         // Bone assignments 
     308        // Bone assignments. 
    303309        if (!geoSubMesh->mBones.empty()) 
    304310        { 
     
    347353 
    348354        buffer_count    =       3; 
    349  
    350355         
    351356        //      Calculate the size in bytes of the geometry chunk. 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp

    r1069 r1070  
    10071007}//End drawTriangleStrip. 
    10081008 
    1009  
    10101009//--------------------------------------------------------------------------- 
    10111010//      Paint lodtree object. 
     
    11721171} 
    11731172 
    1174  
    1175  
    11761173//--------------------------------------------------------------------------- 
    11771174//      Sets the lodstripslibrary object. 
     
    12131210        draw(); 
    12141211} 
    1215  
    12161212 
    12171213//--------------------------------------------------------------------------- 
     
    13191315 
    13201316        //      Calculate the FPS. 
    1321         calcFPS(); 
    1322 } 
    1323  
     1317        //calcFPS(); 
     1318} 
    13241319 
    13251320#include <IL/ILUT.h> 
     
    13381333} 
    13391334 
    1340  
    13411335void    GeoMeshView::LoadTextureSubMesh(int isubmesh, const char *imgfile) 
    13421336{ 
     
    13661360        } 
    13671361} 
    1368  
    13691362 
    13701363bool    GeoMeshView::SetTextureRenderingState(int submesh) 
     
    13881381} 
    13891382 
    1390  
    13911383int             GeoMeshView::findLeavesSubMesh(void) 
    13921384{ 
     
    13961388        return -1; 
    13971389} 
     1390 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r1058 r1070  
    183183                        } 
    184184 
    185                         //      If answer yes to replace question. 
     185                        //      If answer yes to replace question 
    186186                        //      or if file not exists. 
    187187                        if (answer_yes) 
    188188                        { 
    189189                                mesh_saver      =       new     GeoMeshSaver(); 
     190 
     191                                //      Debug. 
     192                                mGeoMesh        =       mGeoMesh->toSharedVertex(); 
     193                                //------------------------------------- 
    190194 
    191195                                mesh_saver->save(mGeoMesh,filename_name(file_name)); 
     
    803807        //      Loads a mesh file. 
    804808        openMeshFile(); 
    805          
    806809 
    807810        //      If an object is loaded. 
     
    828831                delete  fcho; 
    829832 
    830         //      Hide the right panel. 
    831         hideRightPanel(); 
    832  
    833         //      Show title. 
    834         mProcessTitle->label("Visualize LodStrips"); 
    835  
    836         //      Show the Visulize LodStrips panel. 
    837         showLodStripSlider(); 
    838          
    839         //      Repaint the window. 
    840         mMainWindow->redraw(); 
     833                //      Hide the right panel. 
     834                hideRightPanel(); 
     835 
     836                //      Show title. 
     837                mProcessTitle->label("Visualize LodStrips"); 
     838 
     839                //      Show the Visulize LodStrips panel. 
     840                showLodStripSlider(); 
     841 
     842                //      Repaint the window. 
     843                mMainWindow->redraw(); 
    841844 
    842845        } 
     
    24082411         
    24092412        //      Puts the slider in the max position. 
    2410         //mLodStripSlider->value(lodStripsLib->MinLod()); 
     2413        mLodStripSlider->value(1.0f); 
    24112414} 
    24122415 
     
    31093112                        o->begin(); 
    31103113 
     3114                        /* 
    31113115                        { 
    31123116                                fltk::Widget* o; 
     
    31163120                                o->color((fltk::Color)0xe0dfe300); 
    31173121                        } 
     3122                        */ 
    31183123 
    31193124                        { 
     
    31333138 
    31343139                                //      Hide triangle count. 
    3135                                 o->hide(); 
     3140                                //o->hide(); 
    31363141                        } 
    31373142 
Note: See TracChangeset for help on using the changeset viewer.