Changeset 1078


Ignore:
Timestamp:
07/05/06 17:15:14 (18 years ago)
Author:
gumbau
Message:

Extended Mesh implementation

Location:
GTP/trunk/Lib/Geom/shared
Files:
15 edited

Legend:

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

    r1070 r1078  
    5252- It also writes the LODStrips mesh into a file. 
    5353*/ 
    54         class LodStripsConstructor : public Serializable 
     54        class LodStripsConstructor/* : public Serializable*/ 
    5555        { 
    5656                protected: 
     
    145145 
    146146                        /// Load  
    147                         void Load(Serializer &s); 
     147                /*      void Load(Serializer &s);*/ 
    148148 
    149149                        /// Saves the multiresolution model into a LODStrip file and the 
    150150                        //      LODStrips mesh using the serializer given as a parameter. 
    151                         void Save (Serializer &s); 
     151                        //void Save (Serializer &s); 
     152                        void Save (std::string); 
     153 
     154                        void UpdateMesh(void); 
    152155 
    153156                        ///     GetMesh: Return de current Mesh. 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h

    r1070 r1078  
    7070 
    7171        */ 
     72        class LodStripsLibraryData 
     73        { 
     74        public: 
     75                SmallIntVector                                  mFileVertices; 
     76                std::vector     <LODRegisterType>       mFileChangesLOD; 
     77                LongVector                                              mData; 
     78                std::vector<unsigned int>               p_changes; 
     79        }; 
    7280        class LodStripsLibrary : public Geometry::LodObject 
    7381        { 
     
    125133 
    126134                        //      Loads Mesh. 
    127                         void    LoadStripMesh(char *name, Mesh *geomesh); 
     135                        void    LoadStripMesh(const LodStripsLibraryData &, Mesh *geomesh); 
    128136 
    129137                        Geometry::CREATEINDEXDATAFUNC create_index_data_func; 
     
    132140                        SmallIntVector  *mStrips; 
    133141 
    134                         void UpdateDataRetrievalInterface(void); 
     142                        void UpdateDataRetrievalInterface(void);                         
    135143 
    136144                public: 
     
    141149                         *      including the multiresolution object. 
    142150                        */ 
    143                         LodStripsLibrary(std::string, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL); 
     151                        LodStripsLibrary(const LodStripsLibraryData &, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL); 
    144152 
    145153                        /// Destructor. 
     
    164172                        /// Returns the number of vertices of the lowest LOD. 
    165173                        uint32  MinVertices(); 
     174 
     175                        int *indices_x_submesh; 
    166176        }; 
    167177} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h

    r1069 r1078  
    88#include "GeoMesh.h" 
    99#include "GeoLodStripsLibrary.h" 
     10#include "GeoTreeSimpSequence.h" 
    1011#include "GeoLodObject.h" 
    1112 
     
    2122/*              LodTreeLibrary( const LodTreeLibrary &); 
    2223                LodTreeLibrary(LodTreeLibrary*);*/ 
    23                 LodTreeLibrary( std::string trunkSimpSeqFile, 
    24                                                 std::string leafSimpSeqFile, 
     24                LodTreeLibrary( const LodStripsLibraryData &, 
     25                                                const TreeSimplificationSequence &, 
    2526                                                Geometry::Mesh *treeGeoMesh, 
    2627                                                uint32 leafSubMeshID 
     
    6768 
    6869//              const Geometry::SmallIntVector & GetStrip(uint32 istrip) const { return trunk->mStrips[istrip]; } 
     70                Geometry::LodStripsLibrary *trunk; 
    6971 
    7072        private: 
    71                 Geometry::LodStripsLibrary *trunk; 
    7273                Foliage *foliage; 
    7374 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp

    r1070 r1078  
    609609//      lodStripConstructor object. 
    610610//--------------------------------------------------------------------------- 
    611 void LodStripsConstructor::Save(Serializer &oSerializer) 
     611void LodStripsConstructor::Save(std::string filename) 
    612612{ 
    613613        unsigned int    i, j; 
     
    615615        char                                    simp[256]; 
    616616 
    617         //******************  1º CONSTRUCCION DEL FICHERO.LOD ********************* 
     617        int vertexCount = this->cVerts.size(); 
     618        int changesCount = this->cCambios.size(); 
     619        int dataCount = this->cDatos.size(); 
     620        int cambiosCount = this->TOTALCAMBIOS; 
     621        int size= dataCount*sizeof(LODData) + (vertexCount + changesCount + cambiosCount + 4)*sizeof(int); 
     622 
     623        FILE *f = fopen(filename.c_str(),"ab"); 
     624 
     625        unsigned short chunkid = 0xabcd; 
     626        fwrite(&chunkid,sizeof(unsigned short),1,f);     
     627        fwrite(&size,sizeof(unsigned long),1,f); 
     628 
     629        fwrite(&vertexCount, sizeof(int), 1, f); 
     630        for(i = 0; i < this->cVerts.size(); i++) 
     631        { 
     632                int auxv = cVerts[i].Next; 
     633                fwrite(&auxv, sizeof(int), 1, f); 
     634        } 
    618635 
    619636        //      VERTICES. 
    620         for(i = 0; i < this->cVerts.size(); i++) 
     637/*      for(i = 0; i < this->cVerts.size(); i++) 
    621638        { 
    622639                sprintf(simp,"v %d\n",cVerts[i].Next); 
    623640                oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 
    624641        } 
    625  
     642*/ 
     643         
    626644        //      CSTRIPS. 
    627645        this->TOTALINDICES      =       0; 
     
    634652        //      lines starting with a d. 
    635653        //      Changes 
     654        fwrite(&changesCount, sizeof(int), 1, f); 
    636655        for(i = 0; i < this->cCambios.size(); i++) 
     656        { 
     657                LODData change= cCambios[i]; 
     658                fwrite(&change, sizeof(LODData), 1, f); 
     659        } 
     660 
     661 
     662/*      for(i = 0; i < this->cCambios.size(); i++) 
    637663        { 
    638664                sprintf(simp,"c\n"); 
     
    649675                oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 
    650676        } 
     677*/      //      Lines starting with a b. 
     678        //      Data. 
     679 
     680        fwrite(&dataCount, sizeof(int), 1, f); 
     681        for(i = 0; i < this->cDatos.size(); i++) 
     682        { 
     683                int data= cDatos[i]; 
     684                fwrite(&data, sizeof(int), 1, f); 
     685        } 
     686 
     687        sprintf(simp,"a\n"); 
     688/*      oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 
     689         
     690        for(i = 0; i < this->cDatos.size(); i++) 
     691        { 
     692                sprintf(simp,"b %d\n",cDatos[i]); 
     693 
     694                oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 
     695        } 
     696*/ 
     697 
     698 
     699        //      lines starting with a p. 
     700        //      Chages made in a LOD. 
     701        fwrite(&cambiosCount, sizeof(int), 1, f); 
     702        for(i = 0; i < this->TOTALCAMBIOS; i++) 
     703        { 
     704                int cambio= pCambios[i]; 
     705                fwrite(&cambio, sizeof(int), 1, f); 
     706        } 
     707 
     708        fclose(f); 
     709 
     710 
     711/* 
     712        //      VERTICES. 
     713        for(i = 0; i < this->cVerts.size(); i++) 
     714        { 
     715                sprintf(simp,"v %d\n",cVerts[i].Next); 
     716                oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 
     717        } 
     718 
     719        //      CSTRIPS. 
     720        this->TOTALINDICES      =       0; 
     721         
     722        for(i = 0; i < this->cStrips.size(); i++) 
     723        { 
     724                this->TOTALINDICES += int(this->cStrips[i].size()); 
     725        } 
     726 
     727        //      lines starting with a d. 
     728        //      Changes 
     729        for(i = 0; i < this->cCambios.size(); i++) 
     730        { 
     731                sprintf(simp,"c\n"); 
     732                oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 
     733                 
     734                sprintf(simp, 
     735                                                "d %u %u %u %u %u\n", 
     736                                                cCambios[i].strip, 
     737                                                cCambios[i].nP, 
     738                                                cCambios[i].nL1, 
     739                                                cCambios[i].nL2, 
     740                                                cCambios[i].obligatory); 
     741                 
     742                oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 
     743        } 
    651744        //      Lines starting with a b. 
    652745        //      Data. 
     
    670763        } 
    671764 
    672         oSerializer.WriteData("\n",sizeof(char),1); 
    673  
    674         //*******************  2º DEVOLVER EL MESH CON LAS MODIFICACIONES EFECTUADAS  ********************* 
    675         int num_no      =       0; 
    676  
    677         if(this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer == true) 
    678         { 
    679                 //mPosition 
    680                 delete[] this->mGeoMesh->mVertexBuffer->mPosition; 
    681                 this->mGeoMesh->mVertexBuffer->mPosition = new Vector3[this->cVerts.size()]; 
    682  
    683                 //mNormal 
    684                 if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    685                 { 
    686                         delete[] this->mGeoMesh->mVertexBuffer->mNormal; 
    687                         this->mGeoMesh->mVertexBuffer->mNormal = new Vector3[this->cVerts.size()]; 
    688                 } 
    689  
    690                 //mTexCoords 
    691                 if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    692                 { 
    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; 
    704                 } 
    705  
    706                 int     indice  =       0; 
    707  
    708                 for (j = 0; j < this->cVerts.size(); j++) 
    709                 { 
    710                         //Copiamos las coordeandas de posicion  
    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]; 
    714  
    715                         //Copiamos las normales 
    716                         if (meshoriginal->mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    717                         { 
    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]; 
    721                         } 
    722  
    723                         //Copiamos las coordenadas de textura 
    724                         if (meshoriginal->mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    725                         { 
    726                                 this->mGeoMesh->mVertexBuffer->mTexCoords[indice].x     =       this->cVerts[j].TexCoords[0]; 
    727                                 this->mGeoMesh->mVertexBuffer->mTexCoords[indice].y     =       this->cVerts[j].TexCoords[1]; 
    728                         } 
    729  
    730                         indice++; 
    731  
    732                 } 
    733  
    734                 this->mGeoMesh->mVertexBuffer->mVertexCount     =       indice; 
    735         } 
    736         else    //OSCAR 
    737         { 
    738                 //Supondre que solo tengo un submesh con vertices no compartidos 
    739                 //mPosition 
    740                 delete[]        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition; 
    741                  
    742                 this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition    =       new Vector3[this->cVerts.size()]; 
    743  
    744                 //mNormal 
    745                 if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    746                 { 
    747                         delete[] this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal; 
    748                         this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal = new Vector3[this->cVerts.size()]; 
    749                 } 
    750  
    751                 //mTexCoords 
    752                 if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    753                 { 
    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; 
    762  
    763                 int indice=0; 
    764                 for (j=0; j<this->cVerts.size(); j++) 
    765                 { 
    766                         //Copiamos las coordeandas de posicion  
    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]; 
    770  
    771                         //Copiamos las normales 
    772                         if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    773                         { 
    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]; 
    777                         } 
    778  
    779                         //Copiamos las coordenadas de textura 
    780                         if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    781                         { 
    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]; 
    784                         } 
    785                         indice++; 
    786                 } 
    787                 this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexCount =indice; 
    788         } 
    789          
    790  
    791  
    792         int indice_acum = 0; 
    793         for(i=0;i<this->mGeoMesh->mSubMeshCount;i++) 
    794         { 
    795                 Geometry::SubMesh & subMesh = meshoriginal->mSubMesh[i]; 
    796                 Geometry::SubMesh & mGeoMeshSubMesh = this->mGeoMesh->mSubMesh[i]; 
    797  
    798                 for (size_t ind=0; ind < subMesh.mIndexCount; ind++)  
    799                 { 
    800                         Index indIndex = subMesh.mIndex[ind]; 
    801                         if (subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
    802                         { 
    803                                 //Hay coordenadas de textura y normales 
    804                                 if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    805                                 { 
    806                                         for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
    807                                         { 
    808                                                 if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    809                                                 { 
    810                                                         if (igual(subMesh.mVertexBuffer->mNormal[indIndex],mGeoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
    811                                                         { 
    812                                                                 if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],mGeoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
    813                                                                 { 
    814                                                                         mGeoMeshSubMesh.mIndex[ind]= int(indvo);//+indice_acum; 
    815                                                                 } 
    816                                                         } 
    817                                                 } 
    818                                         } 
    819                                 } 
    820                                 else            //Hay coordenadas de textura pero no hay normales 
    821                                 { 
    822                                         for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
    823                                         { 
    824                                                 if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    825                                                 { 
    826                                                         if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],mGeoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
    827                                                         { 
    828                                                                 mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
    829                                                         } 
    830                                                 } 
    831                                         } 
    832                                 } 
    833                         } 
    834                         else 
    835                         { 
    836                                 // No hay coordenadas de textura pero si normales 
    837                                 if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
    838                                 { 
    839                                         for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
    840                                         { 
    841                                                 if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    842                                                 { 
    843                                                         if (igual(subMesh.mVertexBuffer->mNormal[indIndex],mGeoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
    844                                                         { 
    845                                                                 mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
    846                                                         } 
    847                                                 } 
    848                                         } 
    849                                 } 
    850                                 else            //No hay coordenadas de texturas ni normales 
    851                                 { 
    852                                         for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
    853                                         { 
    854                                                 if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
    855                                                 { 
    856                                                         mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
    857                                                 } 
    858                                         } 
    859                                 } 
    860                         } 
    861                 } 
    862         } 
    863          
     765        oSerializer.WriteData("\n",sizeof(char),1);     */ 
    864766} 
    865767 
     
    880782} 
    881783 
    882 void LodStripsConstructor::Load(Serializer &oSerializer) 
     784/*void LodStripsConstructor::Load(Serializer &oSerializer) 
    883785{ 
    884 } 
     786}*/ 
    885787 
    886788//--------------------------------------------------------------------------- 
     
    13391241} 
    13401242 
     1243void Geometry::LodStripsConstructor::UpdateMesh(void) 
     1244{ 
     1245        int num_no      =       0; 
     1246        int i=0,j=0; 
     1247 
     1248        if(this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer == true) 
     1249        { 
     1250                //mPosition 
     1251                delete[] this->mGeoMesh->mVertexBuffer->mPosition; 
     1252                this->mGeoMesh->mVertexBuffer->mPosition = new Vector3[this->cVerts.size()]; 
     1253 
     1254                //mNormal 
     1255                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
     1256                { 
     1257                        delete[] this->mGeoMesh->mVertexBuffer->mNormal; 
     1258                        this->mGeoMesh->mVertexBuffer->mNormal = new Vector3[this->cVerts.size()]; 
     1259                } 
     1260 
     1261                //mTexCoords 
     1262                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
     1263                { 
     1264                        delete[] this->mGeoMesh->mVertexBuffer->mTexCoords; 
     1265                        this->mGeoMesh->mVertexBuffer->mTexCoords = new Vector2[this->cVerts.size()]; 
     1266                } 
     1267 
     1268                this->mGeoMesh->mVertexBuffer->mVertexCount     =       this->cVerts.size(); 
     1269                this->mGeoMesh->mVertexBuffer->mVertexInfo              =       this->meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo; 
     1270 
     1271                for(i = 0; i < this->mGeoMesh->mSubMeshCount; i++) 
     1272                { 
     1273                        this->mGeoMesh->mSubMesh[i].mVertexBuffer                               =       this->mGeoMesh->mVertexBuffer; 
     1274                        this->mGeoMesh->mSubMesh[i].mSharedVertexBuffer =       true; 
     1275                } 
     1276 
     1277                int     indice  =       0; 
     1278 
     1279                for (j = 0; j < this->cVerts.size(); j++) 
     1280                { 
     1281                        //Copiamos las coordeandas de posicion  
     1282                        this->mGeoMesh->mVertexBuffer->mPosition[indice].x      =       this->cVerts[j].Vertex[0]; 
     1283                        this->mGeoMesh->mVertexBuffer->mPosition[indice].y      =       this->cVerts[j].Vertex[1]; 
     1284                        this->mGeoMesh->mVertexBuffer->mPosition[indice].z      =       this->cVerts[j].Vertex[2]; 
     1285 
     1286                        //Copiamos las normales 
     1287                        if (meshoriginal->mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
     1288                        { 
     1289                                this->mGeoMesh->mVertexBuffer->mNormal[indice].x        =       this->cVerts[j].Normal[0]; 
     1290                                this->mGeoMesh->mVertexBuffer->mNormal[indice].y        =       this->cVerts[j].Normal[1]; 
     1291                                this->mGeoMesh->mVertexBuffer->mNormal[indice].z        =       this->cVerts[j].Normal[2]; 
     1292                        } 
     1293 
     1294                        //Copiamos las coordenadas de textura 
     1295                        if (meshoriginal->mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
     1296                        { 
     1297                                this->mGeoMesh->mVertexBuffer->mTexCoords[indice].x     =       this->cVerts[j].TexCoords[0]; 
     1298                                this->mGeoMesh->mVertexBuffer->mTexCoords[indice].y     =       this->cVerts[j].TexCoords[1]; 
     1299                        } 
     1300 
     1301                        indice++; 
     1302 
     1303                } 
     1304 
     1305                this->mGeoMesh->mVertexBuffer->mVertexCount     =       indice; 
     1306        } 
     1307        else    //OSCAR 
     1308        { 
     1309                //Supondre que solo tengo un submesh con vertices no compartidos 
     1310                //mPosition 
     1311                delete[]        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition; 
     1312                 
     1313                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition    =       new Vector3[this->cVerts.size()]; 
     1314 
     1315                //mNormal 
     1316                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
     1317                { 
     1318                        delete[] this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal; 
     1319                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal = new Vector3[this->cVerts.size()]; 
     1320                } 
     1321 
     1322                //mTexCoords 
     1323                if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
     1324                { 
     1325                        delete[] this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords; 
     1326                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords = new Vector2[this->cVerts.size()]; 
     1327                } 
     1328 
     1329                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexCount =this->cVerts.size(); 
     1330                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexInfo = this->meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo; 
     1331 
     1332                this->mGeoMesh->mSubMesh[0].mSharedVertexBuffer=false; 
     1333 
     1334                int indice=0; 
     1335                for (j=0; j<this->cVerts.size(); j++) 
     1336                { 
     1337                        //Copiamos las coordeandas de posicion  
     1338                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].x=this->cVerts[j].Vertex[0]; 
     1339                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].y=this->cVerts[j].Vertex[1]; 
     1340                        this->mGeoMesh->mSubMesh[0].mVertexBuffer->mPosition[indice].z=this->cVerts[j].Vertex[2]; 
     1341 
     1342                        //Copiamos las normales 
     1343                        if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
     1344                        { 
     1345                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].x=this->cVerts[j].Normal[0]; 
     1346                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].y=this->cVerts[j].Normal[1]; 
     1347                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mNormal[indice].z=this->cVerts[j].Normal[2]; 
     1348                        } 
     1349 
     1350                        //Copiamos las coordenadas de textura 
     1351                        if (meshoriginal->mSubMesh[0].mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
     1352                        { 
     1353                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords[indice].x=this->cVerts[j].TexCoords[0]; 
     1354                                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mTexCoords[indice].y=this->cVerts[j].TexCoords[1]; 
     1355                        } 
     1356                        indice++; 
     1357                } 
     1358                this->mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexCount =indice; 
     1359        } 
     1360         
     1361 
     1362 
     1363        int indice_acum = 0; 
     1364        for(i=0;i<this->mGeoMesh->mSubMeshCount;i++) 
     1365        { 
     1366                Geometry::SubMesh & subMesh = meshoriginal->mSubMesh[i]; 
     1367                Geometry::SubMesh & mGeoMeshSubMesh = this->mGeoMesh->mSubMesh[i]; 
     1368 
     1369                for (size_t ind=0; ind < subMesh.mIndexCount; ind++)  
     1370                { 
     1371                        Index indIndex = subMesh.mIndex[ind]; 
     1372                        if (subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_TEXCOORDS) 
     1373                        { 
     1374                                //Hay coordenadas de textura y normales 
     1375                                if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
     1376                                { 
     1377                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     1378                                        { 
     1379                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
     1380                                                { 
     1381                                                        if (igual(subMesh.mVertexBuffer->mNormal[indIndex],mGeoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
     1382                                                        { 
     1383                                                                if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],mGeoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
     1384                                                                { 
     1385                                                                        mGeoMeshSubMesh.mIndex[ind]= int(indvo);//+indice_acum; 
     1386                                                                } 
     1387                                                        } 
     1388                                                } 
     1389                                        } 
     1390                                } 
     1391                                else            //Hay coordenadas de textura pero no hay normales 
     1392                                { 
     1393                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     1394                                        { 
     1395                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
     1396                                                { 
     1397                                                        if (igual(subMesh.mVertexBuffer->mTexCoords[indIndex],mGeoMeshSubMesh.mVertexBuffer->mTexCoords[indvo])) 
     1398                                                        { 
     1399                                                                mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
     1400                                                        } 
     1401                                                } 
     1402                                        } 
     1403                                } 
     1404                        } 
     1405                        else 
     1406                        { 
     1407                                // No hay coordenadas de textura pero si normales 
     1408                                if(subMesh.mVertexBuffer->mVertexInfo & Geometry::VERTEX_NORMAL) 
     1409                                { 
     1410                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     1411                                        { 
     1412                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
     1413                                                { 
     1414                                                        if (igual(subMesh.mVertexBuffer->mNormal[indIndex],mGeoMeshSubMesh.mVertexBuffer->mNormal[indvo])) 
     1415                                                        { 
     1416                                                                mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
     1417                                                        } 
     1418                                                } 
     1419                                        } 
     1420                                } 
     1421                                else            //No hay coordenadas de texturas ni normales 
     1422                                { 
     1423                                        for (size_t indvo=0; indvo<mGeoMeshSubMesh.mVertexBuffer->mVertexCount; indvo++) 
     1424                                        { 
     1425                                                if (igual(subMesh.mVertexBuffer->mPosition[indIndex],mGeoMeshSubMesh.mVertexBuffer->mPosition[indvo])) 
     1426                                                { 
     1427                                                        mGeoMeshSubMesh.mIndex[ind]=int(indvo);//+indice_acum; 
     1428                                                } 
     1429                                        } 
     1430                                } 
     1431                        } 
     1432                } 
     1433        } 
     1434 
     1435} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp

    r1070 r1078  
    1717//      Constructors. 
    1818//----------------------------------------------------------------------------- 
    19 LodStripsLibrary::LodStripsLibrary(std::string  name, Mesh *geomesh, CREATEINDEXDATAFUNC idfun) 
     19LodStripsLibrary::LodStripsLibrary(const LodStripsLibraryData &lodstripsdata, Mesh *geomesh, CREATEINDEXDATAFUNC idfun) 
    2020:create_index_data_func(idfun?idfun:DefaultIndexDataCreator) 
    2121{ 
    22         const   char    *name_of_file; 
     22//      const   char    *name_of_file; 
    2323 
    2424        //      Sets the current lod. 
     
    2626 
    2727        //      Converts a String to const char *. 
    28         name_of_file    =       name.data(); 
     28//      name_of_file    =       name.data(); 
    2929 
    3030        //      Sets the global mesh. 
     
    3232 
    3333        dataRetrievalInterface=NULL; 
     34        indices_x_submesh = NULL; 
    3435         
    3536        //      Loads the Level Of Detail file. 
    36         LodStripsLibrary::LoadStripMesh((char*)name_of_file,mGeoMesh); 
     37        LodStripsLibrary::LoadStripMesh(lodstripsdata,mGeoMesh); 
    3738 
    3839        GoToLod(0.0f);   
     
    5556        if (dataRetrievalInterface) 
    5657                delete dataRetrievalInterface; 
     58        if (indices_x_submesh) 
     59                delete[] indices_x_submesh; 
    5760} 
    5861 
     
    427430//      LoadStripMesh 
    428431//----------------------------------------------------------------------------- 
    429 void LodStripsLibrary::LoadStripMesh(char *name, Mesh *geomesh) 
     432void LodStripsLibrary::LoadStripMesh(const LodStripsLibraryData &lodstripsdata, Mesh *geomesh) 
    430433{ 
    431434        FILE                                                                                                                    *fp; 
     
    447450 
    448451        //      For each one of the submeshes. 
     452        indices_x_submesh = new int[geomesh->mSubMeshCount]; 
    449453        for (unsigned int submesh       =       0; submesh < geomesh->mSubMeshCount; submesh++) 
    450454        { 
     
    487491                        int i; 
    488492                        i       = 0; 
     493                        indices_x_submesh[submesh] = 0; 
    489494                        //      For each index of the strip. 
    490495                        for (index = indexBegin; index < indexEnd; index++) 
    491496                        { 
    492497                                mFileStrips[t].push_back(indexBegin[i]); 
     498                                indices_x_submesh[submesh]++; 
    493499                                i++; 
    494500                        } 
     
    498504        //      TODO:   LOD file loaded in load file mesh process. 
    499505        //      Open the LOD file. 
    500         if ((fp = fopen (name, "r")) == NULL) 
     506/*      if ((fp = fopen (name, "r")) == NULL) 
    501507        { 
    502508                //      Error in open. 
     
    551557                } 
    552558                 
    553                 fclose(fp); 
     559                fclose(fp);*/ 
     560 
     561        mFileVertices = lodstripsdata.mFileVertices; 
     562        mFileChangesLOD = lodstripsdata.mFileChangesLOD; 
     563        mData = lodstripsdata.mData; 
     564        p_changes = lodstripsdata.p_changes; 
     565                 
    554566                 
    555567                //      Max / Min values for LOD. 
     
    572584                //Copy the data to the structure we will use 
    573585                CopyVectors2Arrays(); 
    574         } 
     586//      } 
    575587} 
    576588 
     
    581593        dataRetrievalInterface->Begin(); 
    582594 
    583         for (unsigned   int i=0; i<mTotalStrips; i++) 
    584         { 
     595        int counter = 0; 
     596        int target_submesh = 0; 
     597        int strip_count = 0; 
     598 
     599        for (unsigned   int i=0; i<mTotalStrips; i++, strip_count++) 
     600        { 
     601                if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 
     602                { 
     603                        indices_x_submesh[target_submesh] = counter; 
     604                        counter = 0; 
     605                        strip_count = 0; 
     606                        target_submesh++; 
     607                } 
    585608                for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, ii++) 
     609                { 
    586610                        dataRetrievalInterface->SetIndex(ii,*it); 
     611                        counter++; 
     612                } 
    587613                dataRetrievalInterface->SetNumValidIndices(ii); 
    588614        } 
     615 
     616        if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 
     617        { 
     618                indices_x_submesh[target_submesh] = counter; 
     619                counter = 0; 
     620                strip_count = 0; 
     621                target_submesh++; 
     622        } 
     623 
    589624        dataRetrievalInterface->End(); 
    590625} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp

    r1070 r1078  
    55using namespace Geometry; 
    66 
    7 Geometry::LodTreeLibrary::LodTreeLibrary(std::string trunkSimpSeqFile, 
    8                                                                                  std::string leafSimpSeqFile, 
     7Geometry::LodTreeLibrary::LodTreeLibrary(const LodStripsLibraryData &lodstripsdata, 
     8                                                                                 const TreeSimplificationSequence &simpseq, 
    99                                                                                 Geometry::Mesh *treeGeoMesh, 
    1010                                                                                 uint32 leafSubMeshID/* 
     
    1414{ 
    1515        // Cargar el tronco 
    16         trunk = new LodStripsLibrary(trunkSimpSeqFile,treeGeoMesh); 
     16        trunk = new LodStripsLibrary(lodstripsdata,treeGeoMesh); 
    1717 
    1818        // Cargar la copa del árbol 
    1919        Geometry::SubMesh * leafsSubMesh = &(treeGeoMesh->mSubMesh[leafSubMeshID]); 
    20         foliage = new Foliage(leafsSubMesh,leafSimpSeqFile.c_str()); 
     20        foliage = new Foliage(leafsSubMesh,simpseq); 
    2121        GoToFoliageLod(1.0f); 
    2222} 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoTreeSimpSequence.cpp

    r1009 r1078  
    6060{ 
    6161        // Almacena la secuencia de simplificación en un fichero 
    62         char simp[256]; 
     62/*      char simp[256]; 
    6363 
    6464        // Nombre del mesh 
    6565        sprintf(simp,"%s\n",meshName); 
    6666        s.WriteData(simp,sizeof(char),strlen(simp)); 
     67*/ 
     68        unsigned short chunkid = 0xdcba; 
     69        s.WriteData(&chunkid,sizeof(unsigned short),1); 
     70        unsigned long size = mSteps.size()*8*sizeof(int); 
     71        s.WriteData(&size,sizeof(unsigned long),1); 
    6772 
    68         for(unsigned int i=0; i<mSteps.size(); i++) 
     73        int tam = mSteps.size(); 
     74        s.WriteData(&tam,sizeof(int),1); 
     75        for(unsigned int i=0; i<tam; i++) 
    6976        { 
    7077                Geometry::TreeSimplificationSequence::Step paso = mSteps.operator [](i); 
    7178 
     79                s.WriteData(&paso.mV0,sizeof(int),1); 
     80                s.WriteData(&paso.mV1,sizeof(int),1); 
     81                s.WriteData(&paso.mT0,sizeof(int),1); 
     82                s.WriteData(&paso.mT1,sizeof(int),1); 
     83 
     84                s.WriteData(paso.mNewQuad,sizeof(int),4); 
     85 
    7286                // El último %u que recibe el sprintf es para indicar si un paso es dependiente del anterior. REVISAR 
    7387                // ------------------------------------------------------------------------ 
    74                 sprintf(simp,"%u %u %u %u &", paso.mV0, paso.mV1, paso.mT0, paso.mT1); 
     88/*              sprintf(simp,"%u %u %u %u &", paso.mV0, paso.mV1, paso.mT0, paso.mT1); 
    7589                s.WriteData(simp,sizeof(char),strlen(simp)); 
    7690 
    7791                // los quads 
    7892                sprintf(simp," %u %u %u %u\n",paso.mNewQuad[0],paso.mNewQuad[1],paso.mNewQuad[2],paso.mNewQuad[3]); 
    79                 s.WriteData(simp,sizeof(char),strlen(simp)); 
     93                s.WriteData(simp,sizeof(char),strlen(simp));*/ 
    8094                //s.WriteData("\n",sizeof(char),1); 
    8195        } 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp

    r1058 r1078  
    1010// Parameters --> None 
    1111//-------------------------------------------------------------------------------------------------------------------------------- 
    12 Foliage::Foliage(const Geometry::SubMesh *leavesSubMesh, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun):  
     12Foliage::Foliage(const Geometry::SubMesh *leavesSubMesh, const Geometry::TreeSimplificationSequence & simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun):  
    1313Acth(NULL), 
    1414create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun), 
     
    304304 
    305305/// returns the number of total leafs 
    306 bool Foliage::ReadSimpSeq(const char *simpSeqFile) 
    307 { 
    308         FILE* fp_simpli; 
     306bool Foliage::ReadSimpSeq(const Geometry::TreeSimplificationSequence & simpSeq) 
     307{ 
     308        int tn, tv1,tv2, e=0; 
     309 
     310        tn = leafCount; 
     311        for (std::vector<Geometry::TreeSimplificationSequence::Step>::const_iterator it = simpSeq.mSteps.begin(); it != simpSeq.mSteps.end(); it++) 
     312        { 
     313                Leaves[tn].vertsLeaf[0] = it->mNewQuad[0]; 
     314                Leaves[tn].vertsLeaf[1] = it->mNewQuad[1]; 
     315                Leaves[tn].vertsLeaf[2] = it->mNewQuad[2]; 
     316                Leaves[tn].vertsLeaf[3] = it->mNewQuad[3]; 
     317 
     318                Leaves[tn].visible = 0; 
     319 
     320                GetNormalH  (Leaves[tn]); 
     321 
     322                tv1 = it->mV0/2; 
     323                tv2 = it->mT0/2; 
     324 
     325                Leaves[tn].childLeft= tv1; 
     326                Leaves[tn].childRight= tv2; 
     327 
     328                Leaves[tv1].parent = tn; 
     329                Leaves[tv2].parent = tn;                 
     330 
     331                tn++; 
     332        } 
     333 
     334/*      FILE* fp_simpli; 
    309335        char linea[256]; 
    310336        int v0, v1, v2, v3, tn, tv1,tv2, e=0; 
     
    350376        } 
    351377 
    352         fclose(fp_simpli); 
     378        fclose(fp_simpli);*/ 
    353379 
    354380        leafTotal=tn; 
  • GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.h

    r1058 r1078  
    66#include "VertexData.h" 
    77#include "Leaf.h" 
     8#include "GeoTreeSimpSequence.h" 
    89 
    910class ActiveLeafNode 
     
    2627                int active_leaf_count; 
    2728 
    28                 Foliage (const Geometry::SubMesh *, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); 
     29                Foliage (const Geometry::SubMesh *, const Geometry::TreeSimplificationSequence &, Geometry::CREATEVERTEXDATAFUNC vdfun=NULL, Geometry::CREATEINDEXDATAFUNC idfun=NULL); 
    2930                Foliage (const Foliage *); 
    3031                virtual ~Foliage (void); // Destructor 
     
    5657                void ReadLeafs(const Geometry::SubMesh *); 
    5758                void ReadVertices(const Geometry::SubMesh *); 
    58                 bool ReadSimpSeq(const char*); /// returns true when successful 
     59                bool ReadSimpSeq(const Geometry::TreeSimplificationSequence &); /// returns true when successful 
    5960                void FillRoot(void); 
    6061 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshLoader.h

    r1070 r1078  
    2222#include "GeoBase.h" 
    2323#include "GeoMesh.h" 
     24#include "GeoLodStripsLibrary.h" 
     25#include "GeoLodTreeLibrary.h" 
    2426 
    2527namespace Geometry  
     
    204206                        //      Get the size in bytes of the file. 
    205207                        size_t  getFileSize(); 
     208 
     209                        Geometry::LodStripsLibraryData lodstripsdata; 
     210                        Geometry::TreeSimplificationSequence treesimpseq; 
    206211        }; 
    207212} 
  • GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h

    r1050 r1078  
    372372 
    373373        //      Initialize the lodstripslibrary for visualization. 
    374         void    setLodStripsLibrary(std::string lodfile, Mesh   *geomesh); 
     374        void    setLodStripsLibrary(const Geometry::LodStripsLibraryData &, Mesh        *geomesh); 
    375375        //      Initialize the lodtreelibrary for visualization. 
    376         void    setLodTreesLibrary(std::string lodfile, std::string leafseqfile, Mesh   *geomesh, uint32 ileafSubMesh); 
     376        void    setLodTreesLibrary(const Geometry::LodStripsLibraryData &, const Geometry::TreeSimplificationSequence &, Mesh   *geomesh, uint32 ileafSubMesh); 
    377377 
    378378        // Indentify the mesh of leaves. 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp

    r1071 r1078  
    642642//      Read a mesh file. 
    643643//--------------------------------------------------------------------------- 
     644 
     645#include "GeoLodStripsLibrary.h" 
     646#include "GeoLodStripsConstructor.h" 
     647 
    644648void GeoMeshLoader::readMesh(FILE       *f, Mesh        *geoMesh, int option) 
    645649{ 
     
    670674                                 chunkID == M_MESH_BOUNDS || 
    671675                                 chunkID == M_SUBMESH_NAME_TABLE || 
    672                                  chunkID == M_EDGE_LISTS)) 
     676                                 chunkID == M_EDGE_LISTS || 
     677                                 chunkID == 0xabcd ||  
     678                                 chunkID == 0xdcba)) 
    673679                { 
    674680                        switch(chunkID) 
    675681                        { 
     682                                case 0xabcd: 
     683                                        cout << "LODSTRIPS_Chunk" << endl; 
     684                                        int                             aux,v,c; 
     685                                        LODRegisterType lod_register; 
     686                                        LODData                 dataaux; 
     687                                        int                             tam; 
     688 
     689                                        fread(&tam, sizeof(int), 1, f); 
     690                                        lodstripsdata.mFileVertices.clear(); 
     691                                        for (v=0; v<tam; v++) 
     692                                        { 
     693                                                fread(&aux, sizeof(int), 1, f); 
     694                                                lodstripsdata.mFileVertices.push_back(aux); 
     695                                        } 
     696 
     697                                        lodstripsdata.mFileChangesLOD.clear(); 
     698                                        fread(&tam, sizeof(int), 1, f); 
     699                                        for (c=0; c<tam; c++) 
     700                                        { 
     701                                                fread(&dataaux, sizeof(LODData), 1, f); 
     702                                                lod_register.strip= dataaux.strip; 
     703                                                lod_register.position= dataaux.nP; 
     704                                                lod_register.vertexRepetition= dataaux.nL1; 
     705                                                lod_register.edgeRepetition= dataaux.nL2; 
     706                                                //lod_register.obligatory=false; 
     707                                                //lod_register.obligatory= dataaux.obligatory; 
     708 
     709                                                lodstripsdata.mFileChangesLOD.push_back(lod_register); 
     710                                        } 
     711                                         
     712                                        lodstripsdata.mData.clear(); 
     713                                        fread(&tam, sizeof(int), 1, f); 
     714                                        for (int b=0; b<tam; b++) 
     715                                        { 
     716                                                fread(&aux, sizeof(int), 1, f); 
     717                                                lodstripsdata.mData.push_back(aux); 
     718                                        } 
     719 
     720                                        lodstripsdata.p_changes.clear(); 
     721                                        fread(&tam, sizeof(int), 1, f); 
     722                                        for (int p=0; p<tam; p++) 
     723                                        { 
     724                                                fread(&aux, sizeof(int), 1, f); 
     725                                                lodstripsdata.p_changes.push_back(aux); 
     726                                        }                                        
     727 
     728                                        break; 
     729 
     730                                case 0xdcba: 
     731                                        cout << "LODTREES_Chunk" << endl; 
     732                                        int size; 
     733                                        fread(&size, sizeof(int), 1, f); 
     734                                        treesimpseq.mSteps.clear(); 
     735                                        for (int i=0; i<size; i++) 
     736                                        { 
     737                                                Geometry::TreeSimplificationSequence::Step auxstep; 
     738                                                fread(&auxstep.mV0,sizeof(int),1,f); 
     739                                                fread(&auxstep.mV1,sizeof(int),1,f); 
     740                                                fread(&auxstep.mT0,sizeof(int),1,f); 
     741                                                fread(&auxstep.mT1,sizeof(int),1,f); 
     742                                                fread(auxstep.mNewQuad,sizeof(int),4,f); 
     743                                                treesimpseq.mSteps.push_back(auxstep); 
     744                                        } 
     745 
     746                                        break; 
     747 
     748 
    676749                                case M_GEOMETRY: 
    677750 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp

    r1070 r1078  
    892892        current_strip = 0; 
    893893 
     894        int begin_index = 0; 
     895 
    894896        //      For each submesh. 
    895897        for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     
    966968                }*/ 
    967969 
     970                int indices_to_render = lodStripsLib->indices_x_submesh[submesh]; 
     971 
     972 
    968973                glBegin(GL_TRIANGLE_STRIP); 
    969                 for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(); index ++) 
     974                //for (int index = 0; index < lodStripsLib->dataRetrievalInterface->GetNumValidIndices(); index ++) 
     975                for (int index = begin_index; index < indices_to_render+begin_index; index ++) 
    970976                { 
    971977                        position = lodStripsLib->dataRetrievalInterface->GetIndex(index); 
     
    10011007                } 
    10021008                glEnd(); 
     1009                begin_index += indices_to_render; 
    10031010 
    10041011        } 
     
    10261033        // DRAW THE TRUNK AS A LODSTRIP OBJECT 
    10271034 
     1035        int begin_index = 0; 
     1036 
    10281037        //      For each submesh. 
    10291038        for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 
     
    11021111 
    11031112                }*/ 
     1113         
     1114                int indices_to_render = lodTreeLib->trunk->indices_x_submesh[submesh]; 
     1115                         
    11041116                glBegin(GL_TRIANGLE_STRIP); 
    1105                 for (int index = 0; index < lodTreeLib->CurrentLOD_Trunk_Indices()->GetNumValidIndices(); index ++) 
     1117                for (int index = begin_index; index < lodTreeLib->trunk->indices_x_submesh[submesh]; index ++) 
    11061118                { 
    11071119                        position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(index); 
     
    11371149                } 
    11381150                glEnd(); 
     1151                begin_index += indices_to_render; 
    11391152 
    11401153        } 
  • GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp

    r1070 r1078  
    811811        if (mGeoMesh != NULL) 
    812812        { 
    813                 fcho    =       new fltk::FileChooser("", 
     813/*              fcho    =       new fltk::FileChooser("", 
    814814                                "*.lod", 
    815815                                fltk::FileChooser::CREATE, 
     
    820820                //      If a file was selected. 
    821821                if (fcho->value()) 
    822                 { 
     822                {*/ 
    823823                        //      Build lod strips library. 
    824                         setLodStripsLibrary(string(fcho->value()), mGeoMesh); 
     824                        setLodStripsLibrary(geoMeshLoader->lodstripsdata, mGeoMesh); 
    825825 
    826826                        //      Sets the aplication mode. 
    827827                        mApplicationState       =       VISUALIZE_LODSTRIPS; 
    828                 } 
     828        /*      } 
    829829 
    830830                //      Free memory. 
    831                 delete  fcho; 
     831                delete  fcho;*/ 
    832832 
    833833                //      Hide the right panel. 
     
    883883 
    884884                //      If an object is loaded. 
    885                 if (mGeoMesh != NULL) 
     885/*              if (mGeoMesh != NULL) 
    886886                { 
    887887                        fcho    =       new fltk::FileChooser("", 
    888                                         "*.lod", 
     888                                        "*.mesh", 
    889889                                        fltk::FileChooser::CREATE, 
    890890                                        "Open Lod file"); 
     
    908908                                if (fcho->value()) 
    909909                                { 
    910                                         std::string leafseqFile(fcho->value()); 
    911  
    912                                         setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 
     910                                        std::string leafseqFile(fcho->value());*/ 
     911 
     912                                        //setLodTreesLibrary(lodstripFile, leafseqFile, mGeoMesh, leafsSubMeshID); 
     913                                        setLodTreesLibrary(geoMeshLoader->lodstripsdata, geoMeshLoader->treesimpseq, mGeoMesh, leafsSubMeshID); 
    913914 
    914915                                        //      Sets the aplication mode. 
    915916                                        mApplicationState       =       VISUALIZE_LODTREES; 
    916                                 } 
     917/*                              } 
    917918                        } 
    918919 
    919920                        //      Free memory. 
    920921                        delete  fcho; 
    921  
     922*/ 
    922923                        //      Hide the right panel. 
    923924                        hideRightPanel(); 
     
    932933                        //      Repaint the window. 
    933934                        mMainWindow->redraw(); 
    934                 } 
     935/*              }*/ 
    935936        } 
    936937} 
     
    12431244        { 
    12441245                //      Choose between aplication state. 
    1245                 switch(mApplicationState) 
     1246                if (mApplicationState==LODSTRIPS_AUTO || mApplicationState==LODTREES_AUTO) 
    12461247                { 
    1247                         //      Build the LOD file. 
    1248                         case    LODTREES_AUTO: 
    1249  
    1250                                 //      Open file chooser dialog. 
    1251                                 file_name       =       fltk::file_chooser("Build LOD","*",""); 
    1252                                  
    1253                                 if (!file_name) 
    1254                                 { 
    1255                                         break; 
    1256                                 } 
    1257  
    1258                                 std::cout << "Creando secuencia de simplificacion de hojas..."; 
    1259                                  
    1260                                 createLeavesSequence(file_name+std::string(".leafseq")); 
    1261                                  
    1262                                 std::cout << "OK!" << std::endl; 
    1263  
    1264                                 /*                              TreeSimplificationSequence * auxTreeSimpSequence = new TreeSimplificationSequence(); 
    1265                                                                         auxTreeSimpSequence->Load(Serializer("leavesSimplification.txt",Serializer::READ)); 
    1266  
    1267                                                                         if (auxTreeSimpSequence && mGeoMesh) 
    1268                                                                         { 
    1269                                                                         LodTreeConstructor * auxLodTreeConstructor = new LodTreeConstructor(mGeoMesh,auxTreeSimpSequence); 
    1270                                                                         delete auxLodTreeConstructor; 
    1271                                                                         } 
    1272                                                                         else 
    1273                                                                         { 
    1274                                                                         fltk::alert("There is no leaf simplification sequence."); 
    1275                                                                         break; 
    1276                                                                         } 
    1277  
    1278  
    1279                                                                         delete auxTreeSimpSequence;*/ 
    1280  
    1281                         case    LODSTRIPS_AUTO: 
    1282  
    1283                                 //      Builder 
    1284                                 if (!file_name) 
    1285                                 { 
    1286                                         file_name       =       fltk::file_chooser("Build LOD","*",""); 
    1287                                 } 
    1288                                  
    1289                                 //      If a file was selected. 
    1290                                 if (file_name) 
    1291                                 { 
    1292                                         //      Undo the simplification changes. 
    1293                                         undo(); 
    1294  
    1295                                         //      Stripify the mesh object. 
    1296                                         stripify(); 
    1297  
    1298                                         //      Reset the build bar. 
    1299                                         mBuildBar->position(0); 
    1300  
    1301                                         //      Simplification sequence. 
    1302                                         oMeshSimpSequence = new MeshSimplificationSequence(); 
    1303  
    1304                                         //      Loads a simplification sequence file. 
    1305                                         oMeshSimpSequence->Load(Serializer(     "SimplifSequence.txt", 
    1306                                                                                                                                                                                         Serializer::READ)); 
    1307  
    1308                                         //      If the simplification sequence and the mesh exist. 
    1309                                         if (oMeshSimpSequence && mGeoMesh) 
     1248                        file_name       =       fltk::file_chooser("Build LOD","*.mesh",""); 
     1249                         
     1250                        //      If a file was selected. 
     1251                        if (file_name) 
     1252                        { 
     1253                                //      Undo the simplification changes. 
     1254                                undo(); 
     1255 
     1256                                //      Stripify the mesh object. 
     1257                                stripify(); 
     1258 
     1259                                //      Reset the build bar. 
     1260                                mBuildBar->position(0); 
     1261 
     1262                                //      Simplification sequence. 
     1263                                oMeshSimpSequence = new MeshSimplificationSequence(); 
     1264 
     1265                                //      Loads a simplification sequence file. 
     1266                                oMeshSimpSequence->Load(Serializer("SimplifSequence.txt",Serializer::READ)); 
     1267 
     1268                                //      If the simplification sequence and the mesh exist. 
     1269                                if (oMeshSimpSequence && mGeoMesh) 
     1270                                { 
     1271                                        oLodStrip               =       new LodStripsConstructor(       mGeoMesh, 
     1272                                                        oMeshSimpSequence, 
     1273                                                        idMeshLeaves, 
     1274                                                        progress_function); 
     1275 
     1276//                                              oSerializer     = new Serializer(file_name,Serializer::Mode::WRITE); 
     1277 
     1278                    oLodStrip->UpdateMesh(); 
     1279 
     1280                                        //      Deletes the previous mesh. 
     1281                                        delete mUndoMesh; 
     1282 
     1283                                        mUndoMesh       =       new Mesh(); 
     1284 
     1285                                        //      Sets the undo mesh. 
     1286                                        *mUndoMesh      =       *mGeoMesh; 
     1287 
     1288                                        delete  mGeoMesh; 
     1289 
     1290                                        mGeoMesh        =       oLodStrip->GetMesh(); 
     1291 
     1292                                        geoMeshView->setMesh(mGeoMesh); 
     1293 
     1294                                        mesh_saver      =       new     GeoMeshSaver(); 
     1295//                                      file_name[strlen(file_name) - 4]        =       '\0'; 
     1296                                         
     1297                                        mesh_saver->leavesSubMesh=idMeshLeaves; 
     1298                                        mesh_saver->leavesVB=origSubMeshVB; 
     1299                                        mesh_saver->numindices=orig_numindices; 
     1300                                        mesh_saver->indices=orig_indices; 
     1301                                        mesh_saver->save(mGeoMesh,file_name); 
     1302                                        delete  mesh_saver; 
     1303                                        oLodStrip->Save(file_name); 
     1304                                        //      Close file. 
     1305//                                              delete  oSerializer;                             
     1306                                } 
     1307                                else 
     1308                                { 
     1309                                        //      Error message. 
     1310                                        fltk::alert("There is no simplification sequence."); 
     1311                                } 
     1312 
     1313                                //      Deletes the siplification sequence object. 
     1314                                delete  oMeshSimpSequence; 
     1315 
     1316                                if (mApplicationState==LODTREES_AUTO) 
     1317                                { 
     1318                                        //      Open file chooser dialog. 
     1319/*                                      file_name       =       fltk::file_chooser("Build LOD","*",""); 
     1320                                         
     1321                                        if (!file_name) 
    13101322                                        { 
    1311                                                 oLodStrip               =       new LodStripsConstructor(       mGeoMesh, 
    1312                                                                 oMeshSimpSequence, 
    1313                                                                 idMeshLeaves, 
    1314                                                                 progress_function); 
    1315  
    1316                                                 oSerializer     =       new Serializer( strcat(file_name,".lod"), 
    1317                                                                                                                                                                         Serializer::Mode::WRITE); 
    1318  
    1319                                                 oLodStrip->Save(*oSerializer); 
    1320  
    1321                                                 //      Close file. 
    1322                                                 delete  oSerializer; 
    1323  
    1324                                                 //      Deletes the previous mesh. 
    1325                                                 delete mUndoMesh; 
    1326  
    1327                                                 mUndoMesh       =       new Mesh(); 
    1328  
    1329                                                 //      Sets the undo mesh. 
    1330                                                 *mUndoMesh      =       *mGeoMesh; 
    1331  
    1332                                                 delete  mGeoMesh; 
    1333  
    1334                                                 mGeoMesh        =       oLodStrip->GetMesh(); 
    1335  
    1336                                                 geoMeshView->setMesh(mGeoMesh); 
    1337  
    1338                                                 mesh_saver      =       new     GeoMeshSaver(); 
    1339                                                 file_name[strlen(file_name) - 4]        =       '\0'; 
    1340                                                  
    1341                                                 mesh_saver->leavesSubMesh=idMeshLeaves; 
    1342                                                 mesh_saver->leavesVB=origSubMeshVB; 
    1343                                                 mesh_saver->numindices=orig_numindices; 
    1344                                                 mesh_saver->indices=orig_indices; 
    1345                                                 mesh_saver->save(mGeoMesh,strcat(file_name,".mesh")); 
    1346                                                  
    1347                                                 delete  mesh_saver; 
    1348                                         } 
    1349                                         else 
    1350                                         { 
    1351                                                 //      Error message. 
    1352                                                 fltk::alert("There is no simplification sequence."); 
    1353                                         } 
    1354  
    1355                                         //      Deletes the siplification sequence object. 
    1356                                         delete  oMeshSimpSequence; 
    1357                                 } 
    1358                                 break; 
     1323                                                break; 
     1324                                        }*/ 
     1325 
     1326                                        std::cout << "Creando secuencia de simplificacion de hojas..."; 
     1327                                         
     1328                                        createLeavesSequence(file_name); 
     1329                                         
     1330                                        std::cout << "OK!" << std::endl;                 
     1331                                } 
     1332                        } 
    13591333                } 
     1334 
    13601335                //      Refresh data aplication. 
    13611336                refreshApplicationBar(); 
     
    22362211        tree_sequencer  =       mTreeSimplifier->GetSimplificationSequence(); 
    22372212         
    2238         tree_sequencer->putMeshName(nombremesh);  
    2239         tree_sequencer->Save(Serializer(filename,Serializer::WRITE)); 
     2213        tree_sequencer->putMeshName(nombremesh);         
     2214        tree_sequencer->Save(Serializer(filename,Serializer::APPEND)); 
    22402215 
    22412216        delete  tree_sequencer; 
     
    23922367//      Initialize the lodstripslibrary for visualization. 
    23932368//--------------------------------------------------------------------------- 
    2394 void    GeoMeshViewUI::setLodStripsLibrary(std::string lodfile, Mesh    *geomesh) 
     2369void    GeoMeshViewUI::setLodStripsLibrary(const Geometry::LodStripsLibraryData &loddata, Mesh  *geomesh) 
    23952370{ 
    23962371        //      If there is no lod strips object. 
     
    24012376 
    24022377        //      New lod strips object. 
    2403         lodStripsLib    =       new     LodStripsLibrary(lodfile, geomesh); 
     2378        lodStripsLib    =       new     LodStripsLibrary(loddata, geomesh); 
    24042379 
    24052380        //      Sets the slider range. 
     
    24172392//      Initialize the lodTreelibrary for visualization. 
    24182393//--------------------------------------------------------------------------- 
    2419 //void  GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh     *geomesh) 
    2420 void    GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, std::string leafseqfile, Mesh *geomesh, uint32 ileafSubMesh) 
    2421  
     2394void    GeoMeshViewUI::setLodTreesLibrary(const LodStripsLibraryData &lodstripsdata, const TreeSimplificationSequence &treesimpseq, Mesh *geomesh, uint32 ileafSubMesh) 
    24222395{ 
    24232396        //      If there is no lod strips object. 
     
    24282401 
    24292402        //      New lod strips object. 
    2430 /*      lodTreeLib      =       new     Geometry::LodTreeLibrary(lodfile, geomesh,"\\\\quake\\home\\\Modelos\\betula_populifolia\\vertices.obj", 
    2431                                                                                 "\\\\quake\\home\\\Modelos\\betula_populifolia\\hojas.obj", 
    2432                                                                                 "\\\\quake\\home\\\Modelos\\betula_populifolia\\simplifica.obj");*/ 
    2433  
    2434         lodTreeLib = new Geometry::LodTreeLibrary(lodfile,leafseqfile,geomesh,ileafSubMesh); 
     2403 
     2404        lodTreeLib = new Geometry::LodTreeLibrary(lodstripsdata,treesimpseq,geomesh,ileafSubMesh); 
    24352405 
    24362406        //      Sets the slider range. 
    2437 //      mLodStripSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod()); 
    2438 //      mLodTreeSlider->range(lodTreeLib->MaxFoliageLod(), lodTreeLib->MinFoliageLod()); 
    24392407        mLodStripSlider->range(0.0f,1.0f); 
    24402408        mLodTreeSlider->range(0.0f,1.0f); 
Note: See TracChangeset for help on using the changeset viewer.