Changeset 1560 for GTP/trunk/Lib/Geom/shared/GTGeometry
- Timestamp:
- 10/03/06 14:11:36 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoLodStripsLibrary.h
r1552 r1560 35 35 { 36 36 unsigned long strip; // change this to uint32 37 char position;38 char vertexRepetition;39 char edgeRepetition;40 char obligatory;37 char position; 38 char vertexRepetition; 39 char edgeRepetition; 40 char obligatory; 41 41 } LODRegisterType; 42 42 … … 73 73 class LodStripsLibraryData 74 74 { 75 public: 76 SmallIntVector mFileVertices; 77 std::vector <LODRegisterType> mFileChangesLOD; 78 LongVector mData; 79 std::vector<unsigned int> p_changes; 75 public: 76 77 SmallIntVector mFileVertices; 78 std::vector <LODRegisterType> mFileChangesLOD; 79 LongVector mData; 80 std::vector<unsigned int> p_changes; 80 81 }; 82 81 83 class LodStripsLibrary : public Geometry::LodObject 82 84 { … … 88 90 // Structures with the data read from the file 89 91 // We won't work with these structures 90 SmallIntVector mFileVertices;92 SmallIntVector mFileVertices; 91 93 std::vector <LODRegisterType> mFileChangesLOD; 92 94 std::vector <SmallIntVector> mFileStrips; 93 LongVector mData;95 LongVector mData; 94 96 95 97 // Structures with the data to work with … … 113 115 114 116 // For the efficient version. 115 SmallInt mTotalFaces;116 SmallInt *mCurrentData;117 SmallInt *mStripsChanges;117 SmallInt mTotalFaces; 118 SmallInt *mCurrentData; 119 SmallInt *mStripsChanges; 118 120 LODRegisterType *mCurrentRegLOD; 119 SmallInt *mVertex;121 SmallInt *mVertex; 120 122 121 123 SmallInt minFaces, maxFaces; … … 140 142 // Strips vector. 141 143 SmallIntVector *mStrips; 142 int *indices_x_submesh; 144 145 int *indices_x_submesh; 143 146 int *offsets_x_submesh; 144 147 145 void UpdateDataRetrievalInterface(void); 148 void UpdateDataRetrievalInterface(void); 146 149 147 150 //Number of strips in each submesh 148 int* mStripsSubmesh; 149 bool delete_indexdata; 150 int *submesh_x_strip; 151 Real lodFactor; 152 IndexData *dataRetrievalInterface; 153 uint32 current_triangle_count; 151 int *mStripsSubmesh; 152 bool delete_indexdata; 153 int *submesh_x_strip; 154 Real lodFactor; 155 156 IndexData *dataRetrievalInterface; 157 uint32 current_triangle_count; 154 158 155 159 public: 156 160 157 IndexData *GetIndexDataInterface(void){ return dataRetrievalInterface; } 161 IndexData *GetIndexDataInterface(void) 162 { 163 return dataRetrievalInterface; 164 } 158 165 159 166 /** Constructor, receives as a parameter the name of the file 160 167 * including the multiresolution object. 161 168 */ 162 LodStripsLibrary(const LodStripsLibraryData *, Mesh *geomesh, IndexData * userindexdata = NULL); 169 LodStripsLibrary( const LodStripsLibraryData *, 170 Mesh *geomesh, 171 IndexData *userindexdata = NULL); 163 172 164 173 /// Destructor. … … 184 193 uint32 MinVertices(); 185 194 186 uint32 GetValidIndexCount(int submeshid) const { return indices_x_submesh[submeshid]; } 187 // uint32 GetValidOffset(int submeshid) const { return offsets_x_submesh[submeshid]; } 188 uint32 GetTotalStripCount(void) const { return mTotalStrips; } 189 uint32 GetSubMeshtripCount(int submeshid) const { return mStripsSubmesh[submeshid]; } 190 uint32 GetCurrentTriangleCount(void) const { return current_triangle_count; } 191 192 virtual Real GetCurrentLodFactor(void) const { return lodFactor; } 195 uint32 GetValidIndexCount(int submeshid) const 196 { 197 return indices_x_submesh[submeshid]; 198 } 199 200 uint32 GetTotalStripCount(void) const 201 { 202 return mTotalStrips; 203 } 204 205 uint32 GetSubMeshtripCount(int submeshid) const 206 { 207 return mStripsSubmesh[submeshid]; 208 } 209 210 uint32 GetCurrentTriangleCount(void) const 211 { 212 return current_triangle_count; 213 } 214 215 virtual Real GetCurrentLodFactor(void) const 216 { 217 return lodFactor; 218 } 193 219 }; 194 220 } -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsLibrary.cpp
r1552 r1560 18 18 // Constructor. 19 19 //----------------------------------------------------------------------------- 20 LodStripsLibrary::LodStripsLibrary(const LodStripsLibraryData *lodstripsdata, Mesh *geomesh, IndexData *userindexdata) 21 //:dataRetrievalInterface(idfun?idfun:DefaultIndexDataCreator) 22 { 23 // const char *name_of_file; 24 20 LodStripsLibrary::LodStripsLibrary( const LodStripsLibraryData *lodstripsdata, 21 Mesh *geomesh, 22 IndexData *userindexdata) 23 { 25 24 // Sets the current lod. 26 25 mCurrentLod = 0; 27 26 28 // Converts a String to const char *.29 // name_of_file = name.data();30 31 27 // Sets the global mesh. 32 28 mGeoMesh = geomesh; 33 29 34 delete_indexdata=false; 35 dataRetrievalInterface=userindexdata; 36 37 indices_x_submesh = NULL; 38 offsets_x_submesh = NULL; 39 mStripsSubmesh = NULL; 40 submesh_x_strip = NULL; 41 lodFactor=1.0f; 42 current_triangle_count=0; 30 delete_indexdata = false; 31 dataRetrievalInterface = userindexdata; 32 indices_x_submesh = NULL; 33 offsets_x_submesh = NULL; 34 mStripsSubmesh = NULL; 35 submesh_x_strip = NULL; 36 lodFactor = 1.0f; 37 current_triangle_count = 0; 43 38 44 39 // Loads the Level Of Detail file. 45 40 LodStripsLibrary::LoadStripMesh(lodstripsdata,mGeoMesh); 46 41 47 GoToLod(0.0f); 48 minFaces = 0; 42 GoToLod(0.0f); 43 44 minFaces = 0; 45 49 46 for (unsigned int strip = 0; strip < mTotalStrips; strip++) 50 minFaces += int(mStrips[strip].size() - 2); 47 { 48 minFaces += int(mStrips[strip].size() - 2); 49 } 51 50 52 51 GoToLod(1.0f); 53 maxFaces = 0; 52 53 maxFaces = 0; 54 54 55 for (unsigned int strip = 0; strip < mTotalStrips; strip++) 55 maxFaces += int(mStrips[strip].size() - 2); 56 { 57 maxFaces += int(mStrips[strip].size() - 2); 58 } 56 59 } 57 60 … … 668 671 void LodStripsLibrary::UpdateDataRetrievalInterface(void) 669 672 { 670 int target_submesh = 0; 671 size_t strip_count = 0; 672 unsigned int ii_submesh = 0; 673 int target_submesh = 0; 674 size_t strip_count = 0; 675 unsigned int ii_submesh = 0; 676 673 677 current_triangle_count = 0; 674 678 675 679 // indices_x_submesh is calculated without degenerates, 676 680 // we must add the degenerate indices added here 677 uint32 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2; 678 679 dataRetrievalInterface->Begin(target_submesh, indices_x_submesh[target_submesh] + numdeg); 680 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 681 681 uint32 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount * 2 - 2; 682 683 dataRetrievalInterface->Begin(target_submesh, 684 indices_x_submesh[target_submesh] + numdeg); 685 686 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 687 688 // For each strip. 682 689 for (unsigned int i = 0; i < mTotalStrips; i++, strip_count++) 683 690 { 684 691 if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 685 692 { 686 if (target_submesh==0) 693 if (target_submesh == 0) 694 { 687 695 offsets_x_submesh[target_submesh] = 0; 696 } 688 697 else 689 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 698 { 699 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] 700 + 701 offsets_x_submesh[target_submesh-1]; 702 } 690 703 691 704 mStripsSubmesh[target_submesh] = (int)strip_count; … … 695 708 ii_submesh = 0; 696 709 dataRetrievalInterface->End(); 710 711 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2; 712 713 dataRetrievalInterface->Begin(target_submesh, 714 indices_x_submesh[target_submesh] + numdeg); 697 715 698 numdeg = mGeoMesh->mSubMesh[target_submesh].mStripCount*2 - 2; 699 dataRetrievalInterface->Begin(target_submesh, indices_x_submesh[target_submesh] + numdeg); 700 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 701 } 702 716 current_triangle_count += indices_x_submesh[target_submesh] + numdeg; 717 } 718 703 719 int lastindex = -1; 704 for (SmallIntVector::iterator it=mStrips[i].begin(); it!=mStrips[i].end(); it++, ii_submesh++) 720 721 for ( SmallIntVector::iterator it = mStrips[i].begin(); 722 it != mStrips[i].end(); 723 it++, ii_submesh++) 705 724 { 706 725 // repeat the first index of the strip: degenerate (DEG!) 707 726 // except for the first strip in a mesh 708 if (lastindex==-1 && strip_count>0) 709 { 710 lastindex=*it; 727 if ((lastindex == -1) && (strip_count > 0)) 728 { 729 lastindex = *it; 730 711 731 dataRetrievalInterface->SetIndex(ii_submesh,*it); 712 732 ii_submesh++; 713 733 } 714 lastindex=*it; 734 735 lastindex = *it; 715 736 dataRetrievalInterface->SetIndex(ii_submesh,*it); 716 737 } … … 718 739 // repeat last vertex of the strip: degenerate (DEG!) 719 740 // except for the last strip in a mesh 720 if (strip_count <mGeoMesh->mSubMesh[target_submesh].mStripCount-1)741 if (strip_count < mGeoMesh->mSubMesh[target_submesh].mStripCount-1) 721 742 { 722 743 dataRetrievalInterface->SetIndex(ii_submesh,lastindex); … … 727 748 if (strip_count >= mGeoMesh->mSubMesh[target_submesh].mStripCount) 728 749 { 729 if (target_submesh==0) 750 if (target_submesh == 0) 751 { 730 752 offsets_x_submesh[target_submesh] = 0; 753 } 731 754 else 732 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] + offsets_x_submesh[target_submesh-1]; 733 734 mStripsSubmesh[target_submesh] = (int)strip_count; 735 strip_count = 0; 755 { 756 offsets_x_submesh[target_submesh] = indices_x_submesh[target_submesh-1] 757 + 758 offsets_x_submesh[target_submesh-1]; 759 } 760 761 mStripsSubmesh[target_submesh] = (int)strip_count; 762 strip_count = 0; 763 736 764 target_submesh++; 737 765 } … … 739 767 dataRetrievalInterface->End(); 740 768 } 769 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.cpp
r1526 r1560 769 769 770 770 // Reserve memory for vert_info array. 771 vinfo.init(m.vertCount()* 10);771 vinfo.init(m.vertCount()*2); 772 772 773 773 if (simplif::will_use_vertex_constraint)
Note: See TracChangeset
for help on using the changeset viewer.