- Timestamp:
- 07/05/06 17:15:14 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsConstructor.h
r1070 r1078 52 52 - It also writes the LODStrips mesh into a file. 53 53 */ 54 class LodStripsConstructor : public Serializable54 class LodStripsConstructor/* : public Serializable*/ 55 55 { 56 56 protected: … … 145 145 146 146 /// Load 147 void Load(Serializer &s);147 /* void Load(Serializer &s);*/ 148 148 149 149 /// Saves the multiresolution model into a LODStrip file and the 150 150 // 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); 152 155 153 156 /// GetMesh: Return de current Mesh. -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h
r1070 r1078 70 70 71 71 */ 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 }; 72 80 class LodStripsLibrary : public Geometry::LodObject 73 81 { … … 125 133 126 134 // Loads Mesh. 127 void LoadStripMesh(c har *name, Mesh *geomesh);135 void LoadStripMesh(const LodStripsLibraryData &, Mesh *geomesh); 128 136 129 137 Geometry::CREATEINDEXDATAFUNC create_index_data_func; … … 132 140 SmallIntVector *mStrips; 133 141 134 void UpdateDataRetrievalInterface(void); 142 void UpdateDataRetrievalInterface(void); 135 143 136 144 public: … … 141 149 * including the multiresolution object. 142 150 */ 143 LodStripsLibrary( std::string, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL);151 LodStripsLibrary(const LodStripsLibraryData &, Mesh *geomesh, CREATEINDEXDATAFUNC idfun=NULL); 144 152 145 153 /// Destructor. … … 164 172 /// Returns the number of vertices of the lowest LOD. 165 173 uint32 MinVertices(); 174 175 int *indices_x_submesh; 166 176 }; 167 177 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodTreeLibrary.h
r1069 r1078 8 8 #include "GeoMesh.h" 9 9 #include "GeoLodStripsLibrary.h" 10 #include "GeoTreeSimpSequence.h" 10 11 #include "GeoLodObject.h" 11 12 … … 21 22 /* LodTreeLibrary( const LodTreeLibrary &); 22 23 LodTreeLibrary(LodTreeLibrary*);*/ 23 LodTreeLibrary( std::string trunkSimpSeqFile,24 std::string leafSimpSeqFile,24 LodTreeLibrary( const LodStripsLibraryData &, 25 const TreeSimplificationSequence &, 25 26 Geometry::Mesh *treeGeoMesh, 26 27 uint32 leafSubMeshID … … 67 68 68 69 // const Geometry::SmallIntVector & GetStrip(uint32 istrip) const { return trunk->mStrips[istrip]; } 70 Geometry::LodStripsLibrary *trunk; 69 71 70 72 private: 71 Geometry::LodStripsLibrary *trunk;72 73 Foliage *foliage; 73 74 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp
r1070 r1078 609 609 // lodStripConstructor object. 610 610 //--------------------------------------------------------------------------- 611 void LodStripsConstructor::Save( Serializer &oSerializer)611 void LodStripsConstructor::Save(std::string filename) 612 612 { 613 613 unsigned int i, j; … … 615 615 char simp[256]; 616 616 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 } 618 635 619 636 // VERTICES. 620 for(i = 0; i < this->cVerts.size(); i++)637 /* for(i = 0; i < this->cVerts.size(); i++) 621 638 { 622 639 sprintf(simp,"v %d\n",cVerts[i].Next); 623 640 oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 624 641 } 625 642 */ 643 626 644 // CSTRIPS. 627 645 this->TOTALINDICES = 0; … … 634 652 // lines starting with a d. 635 653 // Changes 654 fwrite(&changesCount, sizeof(int), 1, f); 636 655 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++) 637 663 { 638 664 sprintf(simp,"c\n"); … … 649 675 oSerializer.WriteData(simp,sizeof(char),strlen(simp)); 650 676 } 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 } 651 744 // Lines starting with a b. 652 745 // Data. … … 670 763 } 671 764 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); */ 864 766 } 865 767 … … 880 782 } 881 783 882 void LodStripsConstructor::Load(Serializer &oSerializer)784 /*void LodStripsConstructor::Load(Serializer &oSerializer) 883 785 { 884 } 786 }*/ 885 787 886 788 //--------------------------------------------------------------------------- … … 1339 1241 } 1340 1242 1243 void 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 17 17 // Constructors. 18 18 //----------------------------------------------------------------------------- 19 LodStripsLibrary::LodStripsLibrary( std::string name, Mesh *geomesh, CREATEINDEXDATAFUNC idfun)19 LodStripsLibrary::LodStripsLibrary(const LodStripsLibraryData &lodstripsdata, Mesh *geomesh, CREATEINDEXDATAFUNC idfun) 20 20 :create_index_data_func(idfun?idfun:DefaultIndexDataCreator) 21 21 { 22 const char *name_of_file;22 // const char *name_of_file; 23 23 24 24 // Sets the current lod. … … 26 26 27 27 // Converts a String to const char *. 28 name_of_file = name.data();28 // name_of_file = name.data(); 29 29 30 30 // Sets the global mesh. … … 32 32 33 33 dataRetrievalInterface=NULL; 34 indices_x_submesh = NULL; 34 35 35 36 // Loads the Level Of Detail file. 36 LodStripsLibrary::LoadStripMesh( (char*)name_of_file,mGeoMesh);37 LodStripsLibrary::LoadStripMesh(lodstripsdata,mGeoMesh); 37 38 38 39 GoToLod(0.0f); … … 55 56 if (dataRetrievalInterface) 56 57 delete dataRetrievalInterface; 58 if (indices_x_submesh) 59 delete[] indices_x_submesh; 57 60 } 58 61 … … 427 430 // LoadStripMesh 428 431 //----------------------------------------------------------------------------- 429 void LodStripsLibrary::LoadStripMesh(c har *name, Mesh *geomesh)432 void LodStripsLibrary::LoadStripMesh(const LodStripsLibraryData &lodstripsdata, Mesh *geomesh) 430 433 { 431 434 FILE *fp; … … 447 450 448 451 // For each one of the submeshes. 452 indices_x_submesh = new int[geomesh->mSubMeshCount]; 449 453 for (unsigned int submesh = 0; submesh < geomesh->mSubMeshCount; submesh++) 450 454 { … … 487 491 int i; 488 492 i = 0; 493 indices_x_submesh[submesh] = 0; 489 494 // For each index of the strip. 490 495 for (index = indexBegin; index < indexEnd; index++) 491 496 { 492 497 mFileStrips[t].push_back(indexBegin[i]); 498 indices_x_submesh[submesh]++; 493 499 i++; 494 500 } … … 498 504 // TODO: LOD file loaded in load file mesh process. 499 505 // Open the LOD file. 500 if ((fp = fopen (name, "r")) == NULL)506 /* if ((fp = fopen (name, "r")) == NULL) 501 507 { 502 508 // Error in open. … … 551 557 } 552 558 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 554 566 555 567 // Max / Min values for LOD. … … 572 584 //Copy the data to the structure we will use 573 585 CopyVectors2Arrays(); 574 }586 // } 575 587 } 576 588 … … 581 593 dataRetrievalInterface->Begin(); 582 594 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 } 585 608 for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, ii++) 609 { 586 610 dataRetrievalInterface->SetIndex(ii,*it); 611 counter++; 612 } 587 613 dataRetrievalInterface->SetNumValidIndices(ii); 588 614 } 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 589 624 dataRetrievalInterface->End(); 590 625 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodTreeLibrary.cpp
r1070 r1078 5 5 using namespace Geometry; 6 6 7 Geometry::LodTreeLibrary::LodTreeLibrary( std::string trunkSimpSeqFile,8 std::string leafSimpSeqFile,7 Geometry::LodTreeLibrary::LodTreeLibrary(const LodStripsLibraryData &lodstripsdata, 8 const TreeSimplificationSequence &simpseq, 9 9 Geometry::Mesh *treeGeoMesh, 10 10 uint32 leafSubMeshID/* … … 14 14 { 15 15 // Cargar el tronco 16 trunk = new LodStripsLibrary( trunkSimpSeqFile,treeGeoMesh);16 trunk = new LodStripsLibrary(lodstripsdata,treeGeoMesh); 17 17 18 18 // Cargar la copa del árbol 19 19 Geometry::SubMesh * leafsSubMesh = &(treeGeoMesh->mSubMesh[leafSubMeshID]); 20 foliage = new Foliage(leafsSubMesh, leafSimpSeqFile.c_str());20 foliage = new Foliage(leafsSubMesh,simpseq); 21 21 GoToFoliageLod(1.0f); 22 22 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoTreeSimpSequence.cpp
r1009 r1078 60 60 { 61 61 // Almacena la secuencia de simplificación en un fichero 62 char simp[256];62 /* char simp[256]; 63 63 64 64 // Nombre del mesh 65 65 sprintf(simp,"%s\n",meshName); 66 66 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); 67 72 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++) 69 76 { 70 77 Geometry::TreeSimplificationSequence::Step paso = mSteps.operator [](i); 71 78 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 72 86 // El último %u que recibe el sprintf es para indicar si un paso es dependiente del anterior. REVISAR 73 87 // ------------------------------------------------------------------------ 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); 75 89 s.WriteData(simp,sizeof(char),strlen(simp)); 76 90 77 91 // los quads 78 92 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));*/ 80 94 //s.WriteData("\n",sizeof(char),1); 81 95 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.cpp
r1058 r1078 10 10 // Parameters --> None 11 11 //-------------------------------------------------------------------------------------------------------------------------------- 12 Foliage::Foliage(const Geometry::SubMesh *leavesSubMesh, const char *simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun):12 Foliage::Foliage(const Geometry::SubMesh *leavesSubMesh, const Geometry::TreeSimplificationSequence & simpSeq, Geometry::CREATEVERTEXDATAFUNC vdfun, Geometry::CREATEINDEXDATAFUNC idfun): 13 13 Acth(NULL), 14 14 create_vertex_data_func(vdfun==NULL?Geometry::DefaultVertexDataCreator:vdfun), … … 304 304 305 305 /// returns the number of total leafs 306 bool Foliage::ReadSimpSeq(const char *simpSeqFile) 307 { 308 FILE* fp_simpli; 306 bool 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; 309 335 char linea[256]; 310 336 int v0, v1, v2, v3, tn, tv1,tv2, e=0; … … 350 376 } 351 377 352 fclose(fp_simpli); 378 fclose(fp_simpli);*/ 353 379 354 380 leafTotal=tn; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/leaves/foliage.h
r1058 r1078 6 6 #include "VertexData.h" 7 7 #include "Leaf.h" 8 #include "GeoTreeSimpSequence.h" 8 9 9 10 class ActiveLeafNode … … 26 27 int active_leaf_count; 27 28 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); 29 30 Foliage (const Foliage *); 30 31 virtual ~Foliage (void); // Destructor … … 56 57 void ReadLeafs(const Geometry::SubMesh *); 57 58 void ReadVertices(const Geometry::SubMesh *); 58 bool ReadSimpSeq(const char*); /// returns true when successful59 bool ReadSimpSeq(const Geometry::TreeSimplificationSequence &); /// returns true when successful 59 60 void FillRoot(void); 60 61 -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshLoader.h
r1070 r1078 22 22 #include "GeoBase.h" 23 23 #include "GeoMesh.h" 24 #include "GeoLodStripsLibrary.h" 25 #include "GeoLodTreeLibrary.h" 24 26 25 27 namespace Geometry … … 204 206 // Get the size in bytes of the file. 205 207 size_t getFileSize(); 208 209 Geometry::LodStripsLibraryData lodstripsdata; 210 Geometry::TreeSimplificationSequence treesimpseq; 206 211 }; 207 212 } -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshViewUI.h
r1050 r1078 372 372 373 373 // Initialize the lodstripslibrary for visualization. 374 void setLodStripsLibrary( std::string lodfile, Mesh *geomesh);374 void setLodStripsLibrary(const Geometry::LodStripsLibraryData &, Mesh *geomesh); 375 375 // 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); 377 377 378 378 // Indentify the mesh of leaves. -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp
r1071 r1078 642 642 // Read a mesh file. 643 643 //--------------------------------------------------------------------------- 644 645 #include "GeoLodStripsLibrary.h" 646 #include "GeoLodStripsConstructor.h" 647 644 648 void GeoMeshLoader::readMesh(FILE *f, Mesh *geoMesh, int option) 645 649 { … … 670 674 chunkID == M_MESH_BOUNDS || 671 675 chunkID == M_SUBMESH_NAME_TABLE || 672 chunkID == M_EDGE_LISTS)) 676 chunkID == M_EDGE_LISTS || 677 chunkID == 0xabcd || 678 chunkID == 0xdcba)) 673 679 { 674 680 switch(chunkID) 675 681 { 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 676 749 case M_GEOMETRY: 677 750 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r1070 r1078 892 892 current_strip = 0; 893 893 894 int begin_index = 0; 895 894 896 // For each submesh. 895 897 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) … … 966 968 }*/ 967 969 970 int indices_to_render = lodStripsLib->indices_x_submesh[submesh]; 971 972 968 973 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 ++) 970 976 { 971 977 position = lodStripsLib->dataRetrievalInterface->GetIndex(index); … … 1001 1007 } 1002 1008 glEnd(); 1009 begin_index += indices_to_render; 1003 1010 1004 1011 } … … 1026 1033 // DRAW THE TRUNK AS A LODSTRIP OBJECT 1027 1034 1035 int begin_index = 0; 1036 1028 1037 // For each submesh. 1029 1038 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) … … 1102 1111 1103 1112 }*/ 1113 1114 int indices_to_render = lodTreeLib->trunk->indices_x_submesh[submesh]; 1115 1104 1116 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 ++) 1106 1118 { 1107 1119 position = lodTreeLib->CurrentLOD_Trunk_Indices()->GetIndex(index); … … 1137 1149 } 1138 1150 glEnd(); 1151 begin_index += indices_to_render; 1139 1152 1140 1153 } -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r1070 r1078 811 811 if (mGeoMesh != NULL) 812 812 { 813 fcho = new fltk::FileChooser("",813 /* fcho = new fltk::FileChooser("", 814 814 "*.lod", 815 815 fltk::FileChooser::CREATE, … … 820 820 // If a file was selected. 821 821 if (fcho->value()) 822 { 822 {*/ 823 823 // Build lod strips library. 824 setLodStripsLibrary( string(fcho->value()), mGeoMesh);824 setLodStripsLibrary(geoMeshLoader->lodstripsdata, mGeoMesh); 825 825 826 826 // Sets the aplication mode. 827 827 mApplicationState = VISUALIZE_LODSTRIPS; 828 }828 /* } 829 829 830 830 // Free memory. 831 delete fcho; 831 delete fcho;*/ 832 832 833 833 // Hide the right panel. … … 883 883 884 884 // If an object is loaded. 885 if (mGeoMesh != NULL)885 /* if (mGeoMesh != NULL) 886 886 { 887 887 fcho = new fltk::FileChooser("", 888 "*. lod",888 "*.mesh", 889 889 fltk::FileChooser::CREATE, 890 890 "Open Lod file"); … … 908 908 if (fcho->value()) 909 909 { 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); 913 914 914 915 // Sets the aplication mode. 915 916 mApplicationState = VISUALIZE_LODTREES; 916 }917 /* } 917 918 } 918 919 919 920 // Free memory. 920 921 delete fcho; 921 922 */ 922 923 // Hide the right panel. 923 924 hideRightPanel(); … … 932 933 // Repaint the window. 933 934 mMainWindow->redraw(); 934 } 935 /* }*/ 935 936 } 936 937 } … … 1243 1244 { 1244 1245 // Choose between aplication state. 1245 switch(mApplicationState)1246 if (mApplicationState==LODSTRIPS_AUTO || mApplicationState==LODTREES_AUTO) 1246 1247 { 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) 1310 1322 { 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 } 1359 1333 } 1334 1360 1335 // Refresh data aplication. 1361 1336 refreshApplicationBar(); … … 2236 2211 tree_sequencer = mTreeSimplifier->GetSimplificationSequence(); 2237 2212 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)); 2240 2215 2241 2216 delete tree_sequencer; … … 2392 2367 // Initialize the lodstripslibrary for visualization. 2393 2368 //--------------------------------------------------------------------------- 2394 void GeoMeshViewUI::setLodStripsLibrary( std::string lodfile, Mesh *geomesh)2369 void GeoMeshViewUI::setLodStripsLibrary(const Geometry::LodStripsLibraryData &loddata, Mesh *geomesh) 2395 2370 { 2396 2371 // If there is no lod strips object. … … 2401 2376 2402 2377 // New lod strips object. 2403 lodStripsLib = new LodStripsLibrary(lod file, geomesh);2378 lodStripsLib = new LodStripsLibrary(loddata, geomesh); 2404 2379 2405 2380 // Sets the slider range. … … 2417 2392 // Initialize the lodTreelibrary for visualization. 2418 2393 //--------------------------------------------------------------------------- 2419 //void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, Mesh *geomesh) 2420 void GeoMeshViewUI::setLodTreesLibrary(std::string lodfile, std::string leafseqfile, Mesh *geomesh, uint32 ileafSubMesh) 2421 2394 void GeoMeshViewUI::setLodTreesLibrary(const LodStripsLibraryData &lodstripsdata, const TreeSimplificationSequence &treesimpseq, Mesh *geomesh, uint32 ileafSubMesh) 2422 2395 { 2423 2396 // If there is no lod strips object. … … 2428 2401 2429 2402 // 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); 2435 2405 2436 2406 // Sets the slider range. 2437 // mLodStripSlider->range(lodTreeLib->MaxTrunkLod(), lodTreeLib->MinTrunkLod());2438 // mLodTreeSlider->range(lodTreeLib->MaxFoliageLod(), lodTreeLib->MinFoliageLod());2439 2407 mLodStripSlider->range(0.0f,1.0f); 2440 2408 mLodTreeSlider->range(0.0f,1.0f);
Note: See TracChangeset
for help on using the changeset viewer.