Changeset 826 for GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp
- Timestamp:
- 04/26/06 13:23:34 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GeoTool
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool
-
Property
svn:ignore
set to
build
-
Property
svn:ignore
set to
-
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
Note: See TracChangeset
for help on using the changeset viewer.