Changeset 826 for GTP/trunk/Lib/Geom
- Timestamp:
- 04/26/06 13:23:34 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared
- Files:
-
- 12 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 } -
GTP/trunk/Lib/Geom/shared/GeoTool
-
Property
svn:ignore
set to
build
-
Property
svn:ignore
set to
-
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshLoader.h
r774 r826 166 166 167 167 // Writes the strips list. 168 Mesh* GeoMeshLoader::BuildStripsGeoSubMesh(Mesh* geoMesh);168 SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh* geoSubMesh); 169 169 170 170 public: -
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshView.h
r820 r826 203 203 // Paint the mesh object. 204 204 void drawGeoMesh(int selectedMesh); 205 void drawTriangleList(int s electedMesh);206 void drawTriangleStrip( );205 void drawTriangleList(int submesh, bool selectedMesh); 206 void drawTriangleStrip(int submesh); 207 207 void drawLodStrip(); 208 208 void enableColorStrips(); … … 236 236 }; 237 237 238 ColorElement *mStripColors; 239 238 ColorElement **mStripColors; 239 int mStripColorsCount; 240 240 241 // Idetifier of Visualization List. 241 242 GLuint mIdVisualList; -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp
r774 r826 374 374 375 375 // Read a submesh operation. 376 void GeoMeshLoader::readSubMeshOperation(FILE *f, Mesh *geoMesh, int option) 376 void GeoMeshLoader::readSubMeshOperation( FILE *f, 377 Mesh *geoMesh, 378 int option) 377 379 { 378 380 unsigned short opType; … … 384 386 if (opType == 5) 385 387 { 386 geoMesh->m Type = GEO_TRIANGLE_STRIPS;388 geoMesh->mSubMesh[currentSubMesh].mType = GEO_TRIANGLE_STRIPS; 387 389 } 388 390 else 389 391 { 390 geoMesh->m Type = GEO_TRIANGLE_LIST;392 geoMesh->mSubMesh[currentSubMesh].mType = GEO_TRIANGLE_LIST; 391 393 } 392 394 } … … 545 547 546 548 cout<<"M_SUBMESH_OPERATION\n"; 549 547 550 readSubMeshOperation(f, geoMesh, option); 551 548 552 break; 549 553 case M_SUBMESH_BONE_ASSIGNMENT: … … 761 765 Allocate memory to the array of strips 762 766 */ 763 Mesh* GeoMeshLoader::BuildStripsGeoSubMesh(Mesh* geoMesh)767 SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh* geoSubMesh) 764 768 { 765 769 bool head_found; … … 768 772 int tailIndex; 769 773 size_t tail; 770 SubMesh *geoSubMesh; 771 772 // For each submesh. 773 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 774 { 775 // Gets the actual submesh. 776 geoSubMesh = &geoMesh->mSubMesh[submesh]; 777 778 head_found = false; 779 tail_found = false; 780 geoSubMesh->mStripCount = 1; 781 782 // Foreachone of the indices. 783 // Obtains the number of triangle strips. 784 for (int i = 0; i < (geoSubMesh->mIndexCount - 1); i++) 785 { 786 if (geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i+1]) 787 { 788 if (head_found) 789 { 790 tail_found = true; 774 775 776 head_found = false; 777 tail_found = false; 778 geoSubMesh->mStripCount = 1; 779 780 // Foreachone of the indices. 781 // Obtains the number of triangle strips. 782 for (int i = 0; i < (geoSubMesh->mIndexCount - 1); i++) 783 { 784 if (geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i+1]) 785 { 786 if (head_found) 787 { 788 tail_found = true; 789 } 790 else 791 { 792 head_found = true; 793 } 794 795 // Jump one index. 796 i++; 797 } 798 else 799 { 800 // Increments the number of triangle strips. 801 if (tail_found) 802 { 803 geoSubMesh->mStripCount++; 804 } 805 806 head_found = false; 807 tail_found = false; 808 } 809 } 810 811 geoSubMesh->mStrip = (Index**) malloc( sizeof(Index*) 812 * 813 geoSubMesh->mStripCount); 814 815 // Number of strips. Initially there is one triangle strip. 816 strip_count = 1; 817 818 head_found = false; 819 tail_found = false; 820 821 // Initialize the fist triangle strip. 822 geoSubMesh->mStrip[0] = &geoSubMesh->mIndex[0]; 823 824 // Foreachone of the indices. 825 // Assigns the beginning of the triangle strips. 826 for(int i = 0;i < (geoSubMesh->mIndexCount - 1); i++) 827 { 828 if(geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i+1]) 829 { 830 if(head_found) 831 { 832 if (!tail_found) 833 { 834 tailIndex = i; 791 835 } 792 else 793 { 794 head_found = true; 795 } 796 797 // Jump one index. 798 i++; 836 837 tail_found = true; 799 838 } 800 839 else 801 840 { 802 // Increments the number of triangle strips. 803 if (tail_found) 804 { 805 geoSubMesh->mStripCount++; 806 } 807 808 head_found = false; 809 tail_found = false; 810 } 811 } 812 813 geoSubMesh->mStrip = (Index**) malloc( sizeof(Index*) 814 * 815 geoSubMesh->mStripCount); 816 817 // Number of strips. Initially there is one triangle strip. 818 strip_count = 1; 819 820 head_found = false; 821 tail_found = false; 822 823 // Initialize the fist triangle strip. 824 geoSubMesh->mStrip[0] = &geoSubMesh->mIndex[0]; 825 826 // Foreachone of the indices. 827 // Assigns the beginning of the triangle strips. 828 for(int i = 0;i < (geoSubMesh->mIndexCount - 1); i++) 829 { 830 if(geoSubMesh->mIndex[i] == geoSubMesh->mIndex[i+1]) 831 { 832 if(head_found) 833 { 834 if (!tail_found) 835 { 836 tailIndex = i; 837 } 838 839 tail_found = true; 840 } 841 else 842 { 843 head_found = true; 844 } 845 846 // Jump one index. 847 i++; 848 } 849 else 850 { 851 // Increments the number of triangle strips. 852 if(tail_found) 853 { 854 geoSubMesh->mStrip[strip_count++] = &geoSubMesh->mIndex[tailIndex]; 855 } 856 857 head_found = false; 858 tail_found = false; 859 } 860 } 861 } 862 863 return geoMesh; 841 head_found = true; 842 } 843 844 // Jump one index. 845 i++; 846 } 847 else 848 { 849 // Increments the number of triangle strips. 850 if(tail_found) 851 { 852 geoSubMesh->mStrip[strip_count++] = &geoSubMesh->mIndex[tailIndex]; 853 } 854 855 head_found = false; 856 tail_found = false; 857 } 858 } 859 860 return geoSubMesh; 864 861 } 865 862 … … 873 870 FILE *salida; 874 871 FILE *pFile; 872 SubMesh *geosubmesh; 875 873 876 874 // Initialize the current submesh; … … 971 969 fclose(pFile); 972 970 973 if (geoMesh->mType == Geometry::GEO_TRIANGLE_STRIPS) 974 { 975 // Fill the strips list. 976 geoMesh = BuildStripsGeoSubMesh(geoMesh); 971 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 972 { 973 // Gets the actual submesh. 974 geosubmesh = &geoMesh->mSubMesh[submesh]; 975 976 if (geosubmesh->mType == Geometry::GEO_TRIANGLE_STRIPS) 977 { 978 // Fill the strips list. 979 geosubmesh = BuildStripsGeoSubMesh(geosubmesh); 980 } 977 981 } 978 982 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp
r774 r826 288 288 289 289 // If the mesh is in triangle strips. 290 if ( mGeoMesh->mType == GEO_TRIANGLE_STRIPS)290 if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 291 291 { 292 292 opType = 5; -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshView.cpp
r774 r826 225 225 void GeoMeshView::setStripColors() 226 226 { 227 int total_strips; 228 229 total_strips = 0; 230 231 // Delete previous color strips. 227 SubMesh *geosubmesh; 228 229 // Free memory of the strip colors array. 230 for (int submesh = 0; submesh < mStripColorsCount; submesh++) 231 { 232 delete []mStripColors[submesh]; 233 } 234 232 235 delete []mStripColors; 236 237 // Initialize the Colors array. 238 mStripColors = new ColorElement*[geoMesh->mSubMeshCount]; 233 239 234 240 // Count the total number of strips y the submeshes. 235 for (int i = 0; i < geoMesh->mSubMeshCount; i++) 236 { 237 total_strips = total_strips + geoMesh->mSubMesh[i].mStripCount; 238 } 239 240 // Initialize the Colors array. 241 mStripColors = new ColorElement[total_strips]; 241 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 242 { 243 // Gets the actual submesh. 244 geosubmesh = &geoMesh->mSubMesh[submesh]; 245 246 if (geosubmesh->mType == GEO_TRIANGLE_STRIPS) 247 { 248 mStripColors[submesh] = new ColorElement[geosubmesh->mStripCount]; 249 } 250 else 251 { 252 mStripColors[submesh] = NULL; 253 } 254 } 255 242 256 243 257 // Sets random colors to each strip. 244 for (int i = 0; i < total_strips; i++) 245 { 246 mStripColors[i].r = rand()/((float)RAND_MAX); 247 mStripColors[i].g = rand()/((float)RAND_MAX); 248 mStripColors[i].b = rand()/((float)RAND_MAX); 249 } 258 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 259 { 260 // Gets the actual submesh. 261 geosubmesh = &geoMesh->mSubMesh[submesh]; 262 263 if (geosubmesh->mType == GEO_TRIANGLE_STRIPS) 264 { 265 for (int strip = 0; strip < geosubmesh->mStripCount; strip++) 266 { 267 mStripColors[submesh][strip].r = rand()/((float)RAND_MAX); 268 mStripColors[submesh][strip].g = rand()/((float)RAND_MAX); 269 mStripColors[submesh][strip].b = rand()/((float)RAND_MAX); 270 } 271 } 272 } 273 274 // Sets the submesh count. 275 mStripColorsCount = geoMesh->mSubMeshCount; 250 276 } 251 277 … … 371 397 : fltk::GlWindow(x,y,w,h,l) 372 398 { 373 mStripColors = NULL; 374 mSharedPosArray = NULL; 375 mSharedNorArray = NULL; 376 mPosArray = NULL; 377 mNorArray = NULL; 378 mIndexArray = NULL; 379 vAng = 0.0; 380 hAng = 0.0; 381 size = 0.0; 382 mSizeY = 0; 383 xshift = 0.0; 384 yshift = 0.0; 385 geoMesh = 0; 386 mRotate = true; 387 mPan = false; 388 mLodStrip = false; 389 mIdVisualList = 0; 390 mSubMeshCount = 0; 399 mStripColors = NULL; 400 mSharedPosArray = NULL; 401 mSharedNorArray = NULL; 402 mPosArray = NULL; 403 mNorArray = NULL; 404 mIndexArray = NULL; 405 vAng = 0.0; 406 hAng = 0.0; 407 size = 0.0; 408 mSizeY = 0; 409 xshift = 0.0; 410 yshift = 0.0; 411 geoMesh = 0; 412 mRotate = true; 413 mPan = false; 414 mLodStrip = false; 415 mIdVisualList = 0; 416 mSubMeshCount = 0; 417 mStripColorsCount = 0; 391 418 392 419 // Initialize the model view. … … 522 549 523 550 }// End for each submesh. 524 551 552 mSubMeshCount = geoMesh->mSubMeshCount; 525 553 } 526 554 … … 549 577 void GeoMeshView::drawGeoMesh(int selectedMesh) 550 578 { 579 SubMesh *geosubmesh; 580 bool submesh_selected; 581 551 582 if (geoMesh) 552 583 { … … 555 586 drawLodStrip(); 556 587 } 588 else 589 { 590 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 591 { 592 // Gets the actual submesh. 593 geosubmesh = &geoMesh->mSubMesh[submesh]; 594 595 if (geosubmesh->mType == GEO_TRIANGLE_LIST) 596 { 597 if (selectedMesh == submesh) 598 { 599 submesh_selected = true; 600 } 601 else 602 { 603 submesh_selected = false; 604 } 605 606 // Draw the actual submesh in triangle list. 607 drawTriangleList(submesh,submesh_selected); 608 } 609 else 610 { 611 // Draw the actual submesh in triangle strip. 612 drawTriangleStrip(submesh); 613 } 614 } 615 } 616 /* 557 617 // Choose the render operation. 558 618 else if (geoMesh->mType == GEO_TRIANGLE_LIST) … … 566 626 drawTriangleStrip(); 567 627 } 628 */ 568 629 } 569 630 }// End drawGeoMesh. … … 572 633 // Paint eah strip separately. 573 634 //--------------------------------------------------------------------------- 574 void GeoMeshView::drawTriangleStrip( )635 void GeoMeshView::drawTriangleStrip(int submesh) 575 636 { 576 637 SubMesh *geosubmesh; … … 586 647 color_index = 0; 587 648 588 // For each submesh. 589 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 590 { 591 // Gets the actual submesh. 592 geosubmesh = &geoMesh->mSubMesh[submesh]; 593 594 // For each one of the strips. 595 for (int strip = 0; strip < geosubmesh->mStripCount; strip++) 596 { 597 // Paint the current strip. 598 glBegin(GL_TRIANGLE_STRIP); 599 600 // First index of the strip. 601 indexBegin = geosubmesh->mStrip[strip]; 602 603 // If the strips is not the first. 604 //if (strip != 0) 605 //{ 606 // indexBegin++; 607 //} 608 609 // If is the final strip 610 if (strip == (geosubmesh->mStripCount - 1)) 611 { 612 // The end of the index array. 613 indexEnd = &geosubmesh->mIndex[geosubmesh->mIndexCount]; 614 } 615 else 616 { 617 // The beginning of the next strip. 618 indexEnd = geosubmesh->mStrip[strip + 1]; 619 620 // Remove degenerated 621 //indexEnd--; 622 } 623 624 int i; 625 i = 0; 626 627 if (getColorStrips()) 628 { 629 // Gets the color of the strip. 630 r = mStripColors[color_index].r; 631 g = mStripColors[color_index].g; 632 b = mStripColors[color_index].b; 633 634 // Change to the next color. 635 color_index++; 636 637 // Paint a new color. 638 glColor3f(r,g,b); 639 } 640 641 // For each index of the strip. 642 for (index = indexBegin; index < indexEnd; index++) 643 { 644 position = indexBegin[i]; 645 646 // Gets the vertex normal. 647 vector3 = geosubmesh->mVertexBuffer->mNormal[position]; 648 649 x = vector3[0]; 650 y = vector3[1]; 651 z = vector3[2]; 652 653 // Sets the vertex normal. 654 glNormal3f(x,y,z); 655 656 // Gets the vertex coordinates. 657 vector3 = geosubmesh->mVertexBuffer->mPosition[position]; 658 659 x = vector3[0]; 660 y = vector3[1]; 661 z = vector3[2]; 662 663 664 // Sets the vertex position. 665 glVertex3f(x,y,z); 666 667 // Increments i. 668 i++; 669 } 670 671 glEnd(); 672 673 } 674 } 675 649 // Gets the actual submesh. 650 geosubmesh = &geoMesh->mSubMesh[submesh]; 651 652 // For each one of the strips. 653 for (int strip = 0; strip < geosubmesh->mStripCount; strip++) 654 { 655 // Paint the current strip. 656 glBegin(GL_TRIANGLE_STRIP); 657 658 // First index of the strip. 659 indexBegin = geosubmesh->mStrip[strip]; 660 661 // If the strips is not the first. 662 //if (strip != 0) 663 //{ 664 // indexBegin++; 665 //} 666 667 // If is the final strip 668 if (strip == (geosubmesh->mStripCount - 1)) 669 { 670 // The end of the index array. 671 indexEnd = &geosubmesh->mIndex[geosubmesh->mIndexCount]; 672 } 673 else 674 { 675 // The beginning of the next strip. 676 indexEnd = geosubmesh->mStrip[strip + 1]; 677 678 // Remove degenerated 679 //indexEnd--; 680 } 681 682 int i; 683 i = 0; 684 685 if (getColorStrips()) 686 { 687 // Gets the color of the strip. 688 r = mStripColors[submesh][color_index].r; 689 g = mStripColors[submesh][color_index].g; 690 b = mStripColors[submesh][color_index].b; 691 692 // Change to the next color. 693 color_index++; 694 695 // Paint a new color. 696 glColor3f(r,g,b); 697 } 698 699 // For each index of the strip. 700 for (index = indexBegin; index < indexEnd; index++) 701 { 702 position = indexBegin[i]; 703 704 // Gets the vertex normal. 705 vector3 = geosubmesh->mVertexBuffer->mNormal[position]; 706 707 x = vector3[0]; 708 y = vector3[1]; 709 z = vector3[2]; 710 711 // Sets the vertex normal. 712 glNormal3f(x,y,z); 713 714 // Gets the vertex coordinates. 715 vector3 = geosubmesh->mVertexBuffer->mPosition[position]; 716 717 x = vector3[0]; 718 y = vector3[1]; 719 z = vector3[2]; 720 721 722 // Sets the vertex position. 723 glVertex3f(x,y,z); 724 725 // Increments i. 726 i++; 727 } 728 729 glEnd(); 730 731 } 732 676 733 }//End drawTriangleStrip. 677 734 … … 679 736 // Paint the array of idices. 680 737 //--------------------------------------------------------------------------- 681 void GeoMeshView::drawTriangleList(int selectedMesh) 738 void GeoMeshView::drawTriangleList( int submesh, 739 bool selectedSubMesh) 682 740 { 683 741 SubMesh *geosubmesh; … … 693 751 // Vertex offset. 694 752 vrt_offset = 0; 695 696 // For each submesh. 697 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 698 { 699 // Gets the actual submesh. 700 geosubmesh = &geoMesh->mSubMesh[submesh]; 701 702 // If a mesh is selected. 703 if (selectedMesh >= 0) 704 { 705 // If is a tree. 706 if (leavesSubmesh >= 0) 707 { 708 glColor3d(1.0, 0.5, 0.5); 709 GLfloat color_blanco[] = {1.0f,0.5f,0.5f,1.0f}; 710 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco); 711 712 // For each index of the strip. 713 if (submesh == leavesSubmesh) 714 { 715 glColor3d(0.0,1.0,0.0); 716 GLfloat color_rojo[] = {0.0f,1.0f,0.0f,1.0f}; 717 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_rojo); 718 } 719 } 720 // If is NOT a tree. 721 else 722 { 723 // Set white color to the object. 724 glColor3d(1.0, 1.0, 1.0); 725 GLfloat color_blanco[] = {1.0f,1.0f,1.0f,1.0f}; 726 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco); 727 } 728 729 // For each index of the strip. 730 if (submesh == selectedMesh) 731 { 732 glColor3d(1.0,0.0,0.0); 733 GLfloat color_rojo[] = {1.0f,0.0f,0.0f,1.0f}; 734 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_rojo); 735 } 736 } 737 else 738 { 739 // If is a tree. 740 if (leavesSubmesh >= 0) 741 { 742 glColor3d(1.0, 0.5, 0.5); 743 GLfloat color_blanco[] = {1.0f,0.5f,0.5f,1.0f}; 744 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_blanco); 745 746 // For each index of the strip. 747 if (submesh == leavesSubmesh) 748 { 749 glColor3d(0.0,1.0,0.0); 750 GLfloat color_rojo[] = {0.0f,1.0f,0.0f,1.0f}; 751 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,color_rojo); 752 } 753 } 754 } 755 756 // Enable arrays. 757 glEnableClientState(GL_VERTEX_ARRAY); 758 glEnableClientState(GL_NORMAL_ARRAY); 759 760 // If the submesh is shared vertex. 761 if (geosubmesh->mSharedVertexBuffer) 762 { 763 glVertexPointer(3, GL_FLOAT, 0, mSharedPosArray); 764 glNormalPointer(GL_FLOAT, 0, mSharedNorArray); 765 } 766 else 767 { 768 glVertexPointer(3, GL_FLOAT, 0, mPosArray[submesh]); 769 glNormalPointer(GL_FLOAT, 0, mNorArray[submesh]); 770 } 771 772 glDrawElements( GL_TRIANGLES, 773 geosubmesh->mIndexCount, 774 GL_UNSIGNED_INT, 775 mIndexArray[submesh]); 776 } 753 754 // Gets the actual submesh. 755 geosubmesh = &geoMesh->mSubMesh[submesh]; 756 757 // If a mesh is selected. 758 if (selectedSubMesh) 759 { 760 glColor3d(1.0,0.0,0.0); 761 GLfloat red[] = {1.0f,0.0f,0.0f,1.0f}; 762 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,red); 763 } 764 // If is a tree. 765 else if (leavesSubmesh >= 0) 766 { 767 glColor3d(1.0, 0.5, 0.5); 768 GLfloat brown[] = {1.0f,0.5f,0.5f,1.0f}; 769 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,brown); 770 771 // For each index of the strip. 772 if (submesh == leavesSubmesh) 773 { 774 glColor3d(0.0,1.0,0.0); 775 GLfloat green[] = {0.0f,1.0f,0.0f,1.0f}; 776 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,green); 777 } 778 } 779 // If is NOT a tree. 780 else 781 { 782 // Set white color to the object. 783 glColor3d(1.0, 1.0, 1.0); 784 GLfloat white[] = {1.0f,1.0f,1.0f,1.0f}; 785 glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,white); 786 } 787 788 789 // Enable arrays. 790 glEnableClientState(GL_VERTEX_ARRAY); 791 glEnableClientState(GL_NORMAL_ARRAY); 792 793 // If the submesh is shared vertex. 794 if (geosubmesh->mSharedVertexBuffer) 795 { 796 glVertexPointer(3, GL_FLOAT, 0, mSharedPosArray); 797 glNormalPointer(GL_FLOAT, 0, mSharedNorArray); 798 } 799 else 800 { 801 glVertexPointer(3, GL_FLOAT, 0, mPosArray[submesh]); 802 glNormalPointer(GL_FLOAT, 0, mNorArray[submesh]); 803 } 804 805 glDrawElements( GL_TRIANGLES, 806 geosubmesh->mIndexCount, 807 GL_UNSIGNED_INT, 808 mIndexArray[submesh]); 777 809 778 810 }//End drawTriangleList … … 791 823 int current_strip; 792 824 793 color_index = 0;794 795 825 // Initialize current strip. 796 826 current_strip = 0; 797 827 798 828 // For each submesh. 799 829 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 800 830 { 831 832 color_index = 0; 833 801 834 // Gets the actual submesh. 802 835 geosubmesh = &geoMesh->mSubMesh[submesh]; … … 807 840 // Paint the current strip. 808 841 glBegin(GL_TRIANGLE_STRIP); 809 842 810 843 if (getColorStrips()) 811 844 { 812 845 // Gets the color of the strip. 813 r = mStripColors[ color_index].r;814 g = mStripColors[ color_index].g;815 b = mStripColors[ color_index].b;816 846 r = mStripColors[submesh][color_index].r; 847 g = mStripColors[submesh][color_index].g; 848 b = mStripColors[submesh][color_index].b; 849 817 850 // Change to the next color. 818 851 color_index++; 819 852 820 853 // Paint a new color. 821 854 glColor3f(r,g,b); … … 833 866 y = vector3[1]; 834 867 z = vector3[2]; 835 868 836 869 // Sets the vertex normal. 837 870 glNormal3f(x,y,z); 838 871 839 872 // Gets the vertex coordinates. 840 873 vector3 = geosubmesh->mVertexBuffer->mPosition[position]; 841 874 842 875 x = vector3[0]; 843 876 y = vector3[1]; … … 847 880 glVertex3f(x,y,z); 848 881 } 849 882 850 883 // Increments current strip. 851 884 current_strip++; -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r813 r826 1431 1431 sprintf(cadena2, "Number of indexes: %d",mGeoMesh->mSubMesh[i].mIndexCount); 1432 1432 fltk::Item *numberIndex = new fltk::Item(cadena2); 1433 if (mGeoMesh->m Type==Geometry::GEO_TRIANGLE_LIST)1433 if (mGeoMesh->mSubMesh[i].mType==Geometry::GEO_TRIANGLE_LIST) 1434 1434 { 1435 fltk::Item *type = new fltk::Item("Triangle list");1435 fltk::Item *type = new fltk::Item("Triangle List"); 1436 1436 } 1437 1437 else 1438 1438 { 1439 fltk::Item *type = new fltk::Item("Triangle strips");1439 fltk::Item *type = new fltk::Item("Triangle Strips"); 1440 1440 } 1441 1441 … … 1777 1777 geoStripifier->SetProgressFunc(progress_function); 1778 1778 1779 // Sets the leaves submesh if exists. 1780 geoStripifier->SetSubMeshLeaves(idMeshLeaves); 1781 1779 1782 if (geoStripifier->Stripify()) 1780 1783 { … … 1996 1999 1997 2000 // if the mesh is stripified. 1998 if (mGeoMesh->mType == GEO_TRIANGLE_STRIPS) 1999 { 2000 geoMeshView->setStripColors(); 2001 } 2001 geoMeshView->setStripColors(); 2002 2002 2003 2003 // Refresh geometry attributes. … … 2325 2325 } 2326 2326 2327 //{2328 //fltk::Item* o;2329 //o = menuSelectLeaves = new fltk::Item("Select leaves");2330 //o->callback((fltk::Callback*)cb_menuSelectLeaves);2331 //}2327 { 2328 fltk::Item* o; 2329 o = menuSelectLeaves = new fltk::Item("Select leaves"); 2330 o->callback((fltk::Callback*)cb_menuSelectLeaves); 2331 } 2332 2332 2333 2333 o->end(); … … 2414 2414 } 2415 2415 2416 //{2417 //fltk::Item* o;2418 //o = menuSimplifyLeavesCollapse = new fltk::Item("Leaves Simplification");2419 //o->callback((fltk::Callback*)cb_menuSimplifyLeavesCollapse);2420 //}2416 { 2417 fltk::Item* o; 2418 o = menuSimplifyLeavesCollapse = new fltk::Item("Leaves Simplification"); 2419 o->callback((fltk::Callback*)cb_menuSimplifyLeavesCollapse); 2420 } 2421 2421 2422 2422 o->end();
Note: See TracChangeset
for help on using the changeset viewer.