Changeset 891 for GTP/trunk/Lib/Geom/shared/GeoTool
- Timestamp:
- 05/04/06 12:56:05 (19 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GeoTool
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GeoTool/include/GeoMeshLoader.h
r826 r891 166 166 167 167 // Writes the strips list. 168 SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh* geoSubMesh); 168 SubMesh* GeoMeshLoader::BuildStripsGeoSubMesh(SubMesh *geoSubMesh); 169 170 // Remove degenerate triangles of a submesh given. 171 SubMesh * removeDegenerateTriangles(SubMesh *geoSubMesh); 169 172 170 173 public: -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshLoader.cpp
r826 r891 858 858 } 859 859 860 // Remove degenerate triangles of a submesh given. 861 geoSubMesh = removeDegenerateTriangles(geoSubMesh); 862 863 return geoSubMesh; 864 } 865 866 // Remove degenerate triangles of a submesh given. 867 SubMesh * GeoMeshLoader::removeDegenerateTriangles(SubMesh *geoSubMesh) 868 { 869 Index *indices; 870 Index *index; 871 Index *indexBegin; 872 Index *indexEnd; 873 Index *new_strip_starts; 874 size_t new_index_count; 875 size_t current_index; 876 877 // Stores the new starts of strips. 878 new_strip_starts = new Index[geoSubMesh->mStripCount]; 879 880 // Calculate the new index count. 881 new_index_count = geoSubMesh->mIndexCount 882 - 883 (2 * geoSubMesh->mStripCount) 884 + 885 2; 886 887 // Auxiliar index array. 888 indices = new Index[new_index_count]; 889 890 // Initialize the current index; 891 current_index = 0; 892 893 // For each one of the strips. 894 for (int strip = 0; strip < geoSubMesh->mStripCount; strip++) 895 { 896 // Stars of strip without degenerate triangles. 897 new_strip_starts[strip] = current_index; 898 899 // First index of the strip. 900 indexBegin = geoSubMesh->mStrip[strip]; 901 902 // If is the final strip 903 if (strip == (geoSubMesh->mStripCount - 1)) 904 { 905 // The end of the index array. 906 indexEnd = &geoSubMesh->mIndex[geoSubMesh->mIndexCount]; 907 } 908 else 909 { 910 // The beginning of the next strip. 911 indexEnd = geoSubMesh->mStrip[strip + 1]; 912 } 913 914 int i; 915 i = 0; 916 917 // If is not the first strip. 918 if (strip != 0) 919 { 920 indexBegin++; 921 } 922 923 // If is not the last strip. 924 if (strip != (geoSubMesh->mStripCount - 1)) 925 { 926 indexEnd--; 927 } 928 929 // For each index of the strip. 930 for (index = indexBegin; index < indexEnd; index++) 931 { 932 indices[current_index++] = indexBegin[i]; 933 934 // Increments i. 935 i++; 936 } 937 938 } 939 940 // Free Index memory. 941 delete []geoSubMesh->mIndex; 942 943 // Update index count. 944 geoSubMesh->mIndexCount = new_index_count; 945 946 geoSubMesh->mIndex = new Index[new_index_count]; 947 948 // Store new index array without degenerate triangles. 949 for (size_t i = 0; i < geoSubMesh->mIndexCount; i++) 950 { 951 geoSubMesh->mIndex[i] = indices[i]; 952 } 953 954 // Free auxiliar index array; 955 delete []indices; 956 957 // Update start of the strip. 958 for (int strip = 0; strip < geoSubMesh->mStripCount; strip++) 959 { 960 geoSubMesh->mStrip[strip] = &geoSubMesh->mIndex[new_strip_starts[strip]]; 961 } 962 963 // Free auxiliar strip starts. 964 delete []new_strip_starts; 965 860 966 return geoSubMesh; 861 967 } -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshSaver.cpp
r826 r891 194 194 unsigned long indexCount; 195 195 String materialName; 196 Index *index; 197 Index *indexBegin; 198 Index *indexEnd; 196 199 197 200 // Debug. … … 219 222 indexCount = geoSubMesh->mIndexCount; 220 223 224 // If the submesh is in triangle strips. 225 if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 226 { 227 indexCount += 2 * geoSubMesh->mStripCount - 2; 228 } 229 221 230 writeInts(indexCount, 1); 222 231 … … 229 238 << endl; 230 239 231 // Write the index array. 232 for (int i = 0; i < geoSubMesh->mIndexCount; i++) 233 { 234 writeInts(geoSubMesh->mIndex[i], 1); 240 // If the submesh is in triangle strips. 241 if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 242 { 243 // Debug. 244 cout << "Write triangle strips" 245 << endl; 246 247 // For each one of the strips. 248 for (int strip = 0; strip < geoSubMesh->mStripCount; strip++) 249 { 250 // First index of the strip. 251 indexBegin = geoSubMesh->mStrip[strip]; 252 253 // If is the final strip 254 if (strip == (geoSubMesh->mStripCount - 1)) 255 { 256 // The end of the index array. 257 indexEnd = &geoSubMesh->mIndex[geoSubMesh->mIndexCount]; 258 } 259 else 260 { 261 // The beginning of the next strip. 262 indexEnd = geoSubMesh->mStrip[strip + 1]; 263 } 264 265 int i; 266 i = 0; 267 268 if (strip != 0) 269 { 270 writeInts(indexBegin[i], 1); 271 } 272 273 // For each index of the strip. 274 for (index = indexBegin; index < indexEnd; index++) 275 { 276 writeInts(indexBegin[i], 1); 277 278 // Increments i. 279 i++; 280 } 281 282 if (strip != (geoSubMesh->mStripCount - 1)) 283 { 284 writeInts(indexBegin[i - 1], 1); 285 } 286 287 } 288 } 289 // If the submesh is in triangle list. 290 else 291 { 292 // Write the index array. 293 for (int i = 0; i < geoSubMesh->mIndexCount; i++) 294 { 295 writeInts(geoSubMesh->mIndex[i], 1); 296 } 235 297 } 236 298 -
GTP/trunk/Lib/Geom/shared/GeoTool/src/GeoMeshViewUI.cpp
r842 r891 17 17 // Loads a mesh file. 18 18 openMeshFile(); 19 20 // Debug.21 cout << "Vertex Count SubMesh 0: "22 << mGeoMesh->mSubMesh[0].mVertexBuffer->mVertexCount23 << endl;24 //----------------------------------------------------------25 19 26 20 // Deactive Lod strip visualization. … … 854 848 inline void GeoMeshViewUI::cb_mButtonProcess_i(fltk::Button*, void*) 855 849 { 850 bool error; 856 851 Mesh *mesh_aux; 857 852 … … 860 855 mProcessBar->position(0); 861 856 857 // Initialize error flag. 858 error = false; 859 862 860 // If there is a mesh object. 863 861 if (mGeoMesh != NULL) … … 877 875 case EDGE_COLLAPSE: 878 876 877 // Check submeshes for triangles strips. 878 for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) 879 { 880 // If current submesh is in triangle strips. 881 if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) 882 { 883 error = true; 884 } 885 } 886 879 887 // if the mesh is stripified. 880 if ( mGeoMesh->mType == GEO_TRIANGLE_STRIPS)888 if (error) 881 889 { 882 890 fltk::alert("Can't simplify a mesh in triagle strips."); … … 903 911 case LODSTRIPS_AUTO: 904 912 913 // Check submeshes for triangles strips. 914 for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) 915 { 916 // If current submesh is in triangle strips. 917 if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) 918 { 919 error = true; 920 } 921 } 922 905 923 // if the mesh is stripified. 906 if ( mGeoMesh->mType == GEO_TRIANGLE_STRIPS)924 if (error) 907 925 { 908 926 fltk::alert("Can't simplify a mesh in triagle strips."); … … 1617 1635 geoSubMesh = &geoMesh->mSubMesh[submesh]; 1618 1636 1619 switch (geo Mesh->mType)1637 switch (geoSubMesh->mType) 1620 1638 { 1621 1639 case GEO_TRIANGLE_LIST: … … 1643 1661 strip_count = 0; 1644 1662 1645 if (geoMesh->mType == GEO_TRIANGLE_STRIPS) 1646 { 1647 // For each submesh. 1648 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 1663 // For each submesh. 1664 for (int submesh = 0; submesh < geoMesh->mSubMeshCount; submesh++) 1665 { 1666 // Gets the actual submesh. 1667 geoSubMesh = &geoMesh->mSubMesh[submesh]; 1668 1669 if (geoSubMesh->mType == GEO_TRIANGLE_STRIPS) 1649 1670 { 1650 // Gets the actual submesh.1651 geoSubMesh = &geoMesh->mSubMesh[submesh];1652 1653 1671 strip_count += geoSubMesh->mStripCount; 1654 1672 } 1655 1673 } 1674 1656 1675 return strip_count; 1657 1676 } … … 1699 1718 simplificacionState = QSLIM; 1700 1719 1701 mMeshSimplifier = new ImageBasedSimplifier(mGeoMesh, progress_function);1720 mMeshSimplifier = new GeometryBasedSimplifier(mGeoMesh, progress_function); 1702 1721 1703 1722 mMeshSimplifier->setMeshLeaves(idMeshLeaves); … … 1765 1784 void GeoMeshViewUI::simplifyLeavesCollapse() 1766 1785 { 1767 uint32 vi; 1768 1786 bool error; 1787 uint32 vi; 1788 1789 // Initialize error flag. 1790 error = false; 1791 1792 // Check submeshes for triangles strips. 1793 for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) 1794 { 1795 // If current submesh is in triangle strips. 1796 if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) 1797 { 1798 error = true; 1799 } 1800 } 1801 1769 1802 // if the mesh is stripified. 1770 if ( mGeoMesh->mType == GEO_TRIANGLE_STRIPS)1803 if (error) 1771 1804 { 1772 1805 fltk::alert("Can't simplify a tree in triagle strips."); … … 1842 1875 void GeoMeshViewUI::stripify() 1843 1876 { 1877 bool error; 1844 1878 char char_value[10]; 1845 1879 CustomStripifier *geoStripifier; 1846 1880 1881 // Initialize error flag. 1882 error = false; 1883 1884 // Check submeshes for triangles strips. 1885 for (int i = 0; i < mGeoMesh->mSubMeshCount; i++) 1886 { 1887 // If current submesh is in triangle strips. 1888 if (mGeoMesh->mSubMesh[i].mType == GEO_TRIANGLE_STRIPS) 1889 { 1890 error = true; 1891 } 1892 } 1893 1847 1894 // if the mesh is stripified. 1848 if ( mGeoMesh->mType == GEO_TRIANGLE_STRIPS)1895 if (error) 1849 1896 { 1850 1897 fltk::alert("The mesh is already in strips.");
Note: See TracChangeset
for help on using the changeset viewer.