Changeset 826 for GTP/trunk/Lib/Geom/shared/GTGeometry
- Timestamp:
- 04/26/06 13:23:34 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoMeshStripifier.h
r774 r826 53 53 Mesh * GetMesh (); 54 54 55 // Sets what is the mesh that stores the leaves 56 void setSubMeshLeaves(Geometry::Index); 57 55 58 protected: 56 59 … … 60 63 // Mesh object. 61 64 Geometry::Mesh *mGeoMesh; 65 66 // Index of the submesh leaves. 67 Geometry::Index mSubMeshLeaves; 68 62 69 }; 63 70 … … 88 95 // Set the progress bar function. 89 96 void SetProgressFunc(Geometry::TIPOFUNC upb); 97 98 // Sets what is the submesh that stores the leaves 99 void SetSubMeshLeaves(size_t submesh); 90 100 }; 91 101 -
GTP/trunk/Lib/Geom/shared/GTGeometry/include/GeoSubMesh.h
r774 r826 46 46 size_t mStripCount; ///< number of Strips 47 47 48 MeshType mType; ///< Type of mesh 49 48 50 //OSCAR 49 51 std::vector <VertexBoneAssignment> mBones; -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMesh.cpp
r774 r826 33 33 mSubMesh[i].mVertexBuffer->mVertexCount = objmesh.mSubMesh[i].mVertexBuffer->mVertexCount; 34 34 mSubMesh[i].mVertexBuffer->mVertexInfo = objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo; 35 mSubMesh[i].mType = objmesh.mSubMesh[i].mType; 35 36 36 37 // De momento con esto se parte de un geomesh con vértices compartidos y se obtiene un geomesh sin vértices … … 143 144 mSubMesh[i].mVertexBuffer->mVertexCount = objmesh.mSubMesh[i].mVertexBuffer->mVertexCount; 144 145 mSubMesh[i].mVertexBuffer->mVertexInfo = objmesh.mSubMesh[i].mVertexBuffer->mVertexInfo; 146 mSubMesh[i].mType = objmesh.mSubMesh[i].mType; 145 147 146 148 if (objmesh.mSubMesh[i].mSharedVertexBuffer && !copiados) -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshStripifier.cpp
r774 r826 40 40 // Sets the actual progress bar function. 41 41 mUPB = NULL; 42 43 // Initialize the leaves submesh index. 44 mSubMeshLeaves = -1; 42 45 } 43 46 … … 75 78 float increment; 76 79 float update; 77 80 78 81 // For each submesh. 79 82 for (int submesh = 0; submesh < mGeoMesh->mSubMeshCount; submesh++) 80 83 { 81 // Gets the submesh. 82 geosubmesh = &mGeoMesh->mSubMesh[submesh]; 83 84 // Free index vector. 85 Indices.clear(); 86 87 // Progress bar increment. 88 increment = 20 / mGeoMesh->mSubMeshCount; 89 increment = increment / geosubmesh->mIndexCount; 90 update = 0.0; 91 92 // For each index. 93 for (int index = 0; index < geosubmesh->mIndexCount; index++) 84 // If is not the Leaveas submesh. 85 if (submesh != mSubMeshLeaves) 94 86 { 95 // Update progress bar. 96 if (mUPB) 87 88 // Gets the submesh. 89 geosubmesh = &mGeoMesh->mSubMesh[submesh]; 90 91 // Free index vector. 92 Indices.clear(); 93 94 // Progress bar increment. 95 increment = 20 / mGeoMesh->mSubMeshCount; 96 increment = increment / geosubmesh->mIndexCount; 97 update = 0.0; 98 99 // For each index. 100 for (int index = 0; index < geosubmesh->mIndexCount; index++) 97 101 { 98 update = update + increment; 99 100 if (update > 0.9) 101 { 102 mUPB(1.0); 103 104 update = 0; 105 } 102 // Update progress bar. 103 if (mUPB) 104 { 105 update = update + increment; 106 107 if (update > 0.9) 108 { 109 mUPB(1.0); 110 111 update = 0; 112 } 113 } 114 115 // Add an index. 116 Indices.push_back(geosubmesh->mIndex[index]); 106 117 } 107 108 // Add an index. 109 Indices.push_back(geosubmesh->mIndex[index]); 110 } 111 112 // we want to time the tri_stripper object destruction as well. 113 tri_stripper TriStripper(Indices); 114 115 // Sets the progress bar function for stripper algorithm. 116 TriStripper.SetProgressFunc(mUPB,60/mGeoMesh->mSubMeshCount); 117 118 TriStripper.SetMinStripSize(2); 119 TriStripper.SetCacheSize(32); 120 //TriStripper.SetBackwardSearch(false); 121 122 TriStripper.Strip(&PrimitivesVector); 123 124 // Free submesh indices. 125 delete [] geosubmesh->mIndex; 126 127 // Initialize index count. 128 geosubmesh->mIndexCount = 0; 129 130 // Initialize strip count. 131 strip_count = 0; 132 133 // For each strip or triangle list. 134 for (size_t i = 0; i < PrimitivesVector.size(); ++i) 135 { 136 if (PrimitivesVector[i].Type == TRIANGLE_STRIP) 118 119 // we want to time the tri_stripper object destruction as well. 120 tri_stripper TriStripper(Indices); 121 122 // Sets the progress bar function for stripper algorithm. 123 TriStripper.SetProgressFunc(mUPB,60/mGeoMesh->mSubMeshCount); 124 125 TriStripper.SetMinStripSize(2); 126 TriStripper.SetCacheSize(32); 127 //TriStripper.SetBackwardSearch(false); 128 129 TriStripper.Strip(&PrimitivesVector); 130 131 // Free submesh indices. 132 delete [] geosubmesh->mIndex; 133 134 // Initialize index count. 135 geosubmesh->mIndexCount = 0; 136 137 // Initialize strip count. 138 strip_count = 0; 139 140 // For each strip or triangle list. 141 for (size_t i = 0; i < PrimitivesVector.size(); ++i) 137 142 { 138 strip_count++; 139 geosubmesh->mIndexCount += PrimitivesVector[i].Indices.size(); 140 141 // Degenerate triangles. 142 geosubmesh->mIndexCount += 2; 143 if (PrimitivesVector[i].Type == TRIANGLE_STRIP) 144 { 145 strip_count++; 146 geosubmesh->mIndexCount += PrimitivesVector[i].Indices.size(); 147 148 // Degenerate triangles. 149 geosubmesh->mIndexCount += 2; 150 } 151 else 152 { 153 strip_count += PrimitivesVector[i].Indices.size()/3; 154 155 geosubmesh->mIndexCount += PrimitivesVector[i].Indices.size(); 156 157 // Degenerate triangles. 158 geosubmesh->mIndexCount += 2*(PrimitivesVector[i].Indices.size()/3); 159 } 160 143 161 } 144 else 162 163 // Reserve memory for strips list. 164 geosubmesh->mStrip = new Index*[strip_count]; 165 geosubmesh->mStripCount = strip_count; 166 167 // Adjust the index count. 168 geosubmesh->mIndexCount -= 2; 169 170 // Reserve memory for indices. 171 geosubmesh->mIndex = new Index[geosubmesh->mIndexCount]; 172 173 // Initialize index count. 174 index_count = 0; 175 176 // For each strip. 177 for (size_t strip = 0; strip < PrimitivesVector.size(); strip++) 145 178 { 146 strip_count += PrimitivesVector[i].Indices.size()/3; 147 148 geosubmesh->mIndexCount += PrimitivesVector[i].Indices.size(); 149 150 // Degenerate triangles. 151 geosubmesh->mIndexCount += 2*(PrimitivesVector[i].Indices.size()/3); 152 } 153 154 } 155 156 // Reserve memory for strips list. 157 geosubmesh->mStrip = new Index*[strip_count]; 158 geosubmesh->mStripCount = strip_count; 159 160 // Adjust the index count. 161 geosubmesh->mIndexCount -= 2; 162 163 // Reserve memory for indices. 164 geosubmesh->mIndex = new Index[geosubmesh->mIndexCount]; 165 166 // Initialize index count. 167 index_count = 0; 168 169 // For each strip. 170 for (size_t strip = 0; strip < PrimitivesVector.size(); strip++) 171 { 172 if (PrimitivesVector[strip].Type == TRIANGLE_STRIP) 173 { 174 // Asigns the beginning of the strip. 175 geosubmesh->mStrip[strip] = &geosubmesh->mIndex[index_count]; 176 177 // If is not the first strip. 178 if (strip != 0) 179 { 180 geosubmesh->mIndex[index_count++] = PrimitivesVector[strip].Indices[0]; 181 } 182 183 // Fill up the index array. 184 for ( size_t index = 0; 179 if (PrimitivesVector[strip].Type == TRIANGLE_STRIP) 180 { 181 // Asigns the beginning of the strip. 182 geosubmesh->mStrip[strip] = &geosubmesh->mIndex[index_count]; 183 184 // If is not the first strip. 185 if (strip != 0) 186 { 187 geosubmesh->mIndex[index_count++] = PrimitivesVector[strip].Indices[0]; 188 } 189 190 // Fill up the index array. 191 for ( size_t index = 0; 185 192 index < PrimitivesVector[strip].Indices.size(); 186 193 index++) 187 {188 geosubmesh->mIndex[index + index_count] = PrimitivesVector[strip].Indices[index];189 }190 191 // Adds the current strip size to index count.192 index_count += PrimitivesVector[strip].Indices.size();193 194 if ((strip + 1) != strip_count)195 {196 // Degenerate triangle.197 geosubmesh->mIndex[index_count++] = geosubmesh->mIndex[index_count - 1];198 }199 }200 else201 {202 // For each index.203 for ( size_t itri = 0;194 { 195 geosubmesh->mIndex[index + index_count] = PrimitivesVector[strip].Indices[index]; 196 } 197 198 // Adds the current strip size to index count. 199 index_count += PrimitivesVector[strip].Indices.size(); 200 201 if ((strip + 1) != strip_count) 202 { 203 // Degenerate triangle. 204 geosubmesh->mIndex[index_count++] = geosubmesh->mIndex[index_count - 1]; 205 } 206 } 207 else 208 { 209 // For each index. 210 for ( size_t itri = 0; 204 211 itri < PrimitivesVector[strip].Indices.size() / 3; 205 212 itri ++) 206 {213 { 207 214 // Asigns the beginning of the strip. 208 215 geosubmesh->mStrip[strip + itri] = &geosubmesh->mIndex[index_count]; 209 216 210 217 // Degenerate triangle. 211 218 geosubmesh->mIndex[index_count++] = PrimitivesVector[strip].Indices[itri*3+0]; 212 219 213 220 // Triangle indeces. … … 221 228 geosubmesh->mIndex[index_count++] = geosubmesh->mIndex[index_count - 1]; 222 229 } 223 } 224 230 } 231 232 } 225 233 } 234 235 // Sets the actual submesh type to triangle strips. 236 geosubmesh->mType = GEO_TRIANGLE_STRIPS; 237 226 238 } 227 239 } … … 232 244 mUPB(100); 233 245 } 234 235 // Sets the mesh type to triangle strips. 236 mGeoMesh->mType = GEO_TRIANGLE_STRIPS; 246 237 247 238 248 // All wright. … … 251 261 } 252 262 263 // Sets what is the submesh that stores the leaves. 264 void CustomStripifier::SetSubMeshLeaves(size_t submesh) 265 { 266 mSubMeshLeaves = submesh; 267 } 268 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoSubMesh.cpp
r774 r826 4 4 5 5 SubMesh::SubMesh(): 6 mIndex(0), mVertexBuffer(0), mIndexCount(0),mSharedVertexBuffer(false), mStrip(0), mStripCount(0) 6 mIndex(0), mVertexBuffer(0), mIndexCount(0),mSharedVertexBuffer(false), mStrip(0), mStripCount(0), mType(GEO_TRIANGLE_LIST) 7 7 { 8 8 }
Note: See TracChangeset
for help on using the changeset viewer.