Changeset 1078 for GTP/trunk/Lib/Geom/shared/GTGeometry
- Timestamp:
- 07/05/06 17:15:14 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry
- Files:
-
- 10 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
Note: See TracChangeset
for help on using the changeset viewer.