Changeset 984 for GTP/trunk/Lib/Geom/shared/GTGeometry/src
- Timestamp:
- 05/24/06 11:49:33 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/SimplificationMethod.cpp
r983 r984 555 555 // Initilizations 556 556 //--------------------------------------------------------------------------- 557 void SimplificationMethod::simpl fmethod_init(void)557 void SimplificationMethod::simplifmethod_init(void) 558 558 { 559 559 int i; 560 560 561 // C onvertir la estructura geomesh a modelo qslim561 // Change mesh structure. 562 562 geomesh2simplifModel(); 563 563 … … 586 586 // Do the contractions till the required LOD (percentage option) 587 587 //--------------------------------------------------------------------------- 588 void SimplificationMethod::simpl fmethod_run(int finalfaces,TIPOFUNC upb)588 void SimplificationMethod::simplifmethod_run(int finalfaces,TIPOFUNC upb) 589 589 { 590 590 decimate_init(M0, qslim::pair_selection_tolerance); … … 629 629 // Do the contractions till the required LOD (number of vertices option) 630 630 //--------------------------------------------------------------------------- 631 void SimplificationMethod::simpl fmethod_runv(int numvertices,TIPOFUNC upb)631 void SimplificationMethod::simplifmethod_runv(int numvertices,TIPOFUNC upb) 632 632 { 633 633 decimate_init(M0, qslim::pair_selection_tolerance); … … 719 719 { 720 720 //If the model has texture information 721 /*if (objmesh->mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_TEXCOORDS)722 723 //For all the vertices of each submesh724 for (size_t j=0; j<objmesh->mSubMesh[i].mVertexBuffer->mVertexCount; j++)725 {726 _float3_ auxvert(objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].x,727 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].y,728 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].z);729 730 std::map<_float3_,int>::iterator mit = vertices_map.find(auxvert);731 if (mit==vertices_map.end())732 {733 //If the vertex is not in vertices_map, then is added734 simplifindex=M0.in_Vertex(qslim::Vec3(objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].x,735 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].y,736 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].z));737 M0.in_Normal(qslim::Vec3(objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].x,738 objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].y,739 objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].z));740 741 M0.in_TexCoord(qslim::Vec2(objmesh->mSubMesh[i].mVertexBuffer->mTexCoords[j].x,742 objmesh->mSubMesh[i].mVertexBuffer->mTexCoords[j].y));743 vertices_map[auxvert] = num_final_verts;744 num_final_verts ++;745 746 std::vector<int> v;747 submeshmap[simplifindex]=v;748 submeshmap[simplifindex].push_back((int)i); //Add the index of the mesh that contains the vertex749 std::vector<int> v2;750 vertexbuffermap[simplifindex]=v2;751 vertexbuffermap[simplifindex].push_back((int)j); //Add the index of vertex in the submesh752 753 // Debug754 num_final_verts2++;755 }756 else757 {758 //the vertex is already in vertices_map, so store the reference of the first one with the same space coodinates759 simplifindex = mit->second;760 submeshmap[simplifindex].push_back((int)i); //Submeshes that contains the vertex761 vertexbuffermap[simplifindex].push_back((int)j); //Indices of the vertex buffers that contains the vertex762 763 // Debug764 num_repeated_verts++;765 }766 }721 if (objmesh->mSubMesh[i].mVertexBuffer->mVertexInfo & VERTEX_TEXCOORDS) 722 { 723 //For all the vertices of each submesh 724 for (size_t j=0; j<objmesh->mSubMesh[i].mVertexBuffer->mVertexCount; j++) 725 { 726 _float3_ auxvert(objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].x, 727 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].y, 728 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].z); 729 730 std::map<_float3_,int>::iterator mit = vertices_map.find(auxvert); 731 if (mit==vertices_map.end()) 732 { 733 //If the vertex is not in vertices_map, then is added 734 simplifindex=M0.in_Vertex(qslim::Vec3(objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].x, 735 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].y, 736 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].z)); 737 M0.in_Normal(qslim::Vec3(objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].x, 738 objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].y, 739 objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].z)); 740 741 M0.in_TexCoord(qslim::Vec2(objmesh->mSubMesh[i].mVertexBuffer->mTexCoords[j].x, 742 objmesh->mSubMesh[i].mVertexBuffer->mTexCoords[j].y)); 743 vertices_map[auxvert] = num_final_verts; 744 num_final_verts ++; 745 746 std::vector<int> v; 747 submeshmap[simplifindex]=v; 748 submeshmap[simplifindex].push_back((int)i); //Add the index of the mesh that contains the vertex 749 std::vector<int> v2; 750 vertexbuffermap[simplifindex]=v2; 751 vertexbuffermap[simplifindex].push_back((int)j); //Add the index of vertex in the submesh 752 753 // Debug 754 num_final_verts2++; 755 } 756 else 757 { 758 //the vertex is already in vertices_map, so store the reference of the first one with the same space coodinates 759 simplifindex = mit->second; 760 submeshmap[simplifindex].push_back((int)i); //Submeshes that contains the vertex 761 vertexbuffermap[simplifindex].push_back((int)j); //Indices of the vertex buffers that contains the vertex 762 763 // Debug 764 num_repeated_verts++; 765 } 766 } 767 767 } 768 768 else //the model has not texture information 769 { */770 //For all the vertices of each submesh771 for (size_t j=0; j<objmesh->mSubMesh[i].mVertexBuffer->mVertexCount; j++)772 {773 _float3_ auxvert(objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].x,774 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].y,775 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].z);776 777 std::map<_float3_,int>::iterator mit = vertices_map.find(auxvert);778 if (mit==vertices_map.end())779 {780 //If the vertex is not in vertices_map, then is added781 simplifindex=M0.in_Vertex(qslim::Vec3(objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].x,782 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].y,783 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].z));784 M0.in_Normal(qslim::Vec3(objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].x,785 objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].y,786 objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].z));787 M0.in_TexCoord(qslim::Vec2(0.0,0.0));788 vertices_map[auxvert] = num_final_verts;789 num_final_verts ++;790 791 std::vector<int> v;792 submeshmap[simplifindex]=v;793 submeshmap[simplifindex].push_back((int)i); //Add the index of the mesh that contains the vertex794 std::vector<int> v2;795 vertexbuffermap[simplifindex]=v2;796 vertexbuffermap[simplifindex].push_back((int)j); //Add the index of vertex in the submesh797 }798 else799 {800 //the vertex is already in vertices_map, so store the reference of the first one with the same space coodinates801 simplifindex = mit->second;802 submeshmap[simplifindex].push_back((int)i); //Submeshes that contains the vertex803 vertexbuffermap[simplifindex].push_back((int)j); //Indices of the vertex buffers that contains the vertex804 }805 }806 /* }*/769 { 770 //For all the vertices of each submesh 771 for (size_t j=0; j<objmesh->mSubMesh[i].mVertexBuffer->mVertexCount; j++) 772 { 773 _float3_ auxvert(objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].x, 774 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].y, 775 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].z); 776 777 std::map<_float3_,int>::iterator mit = vertices_map.find(auxvert); 778 if (mit==vertices_map.end()) 779 { 780 //If the vertex is not in vertices_map, then is added 781 simplifindex=M0.in_Vertex(qslim::Vec3(objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].x, 782 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].y, 783 objmesh->mSubMesh[i].mVertexBuffer->mPosition[j].z)); 784 M0.in_Normal(qslim::Vec3(objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].x, 785 objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].y, 786 objmesh->mSubMesh[i].mVertexBuffer->mNormal[j].z)); 787 M0.in_TexCoord(qslim::Vec2(0.0,0.0)); 788 vertices_map[auxvert] = num_final_verts; 789 num_final_verts ++; 790 791 std::vector<int> v; 792 submeshmap[simplifindex]=v; 793 submeshmap[simplifindex].push_back((int)i); //Add the index of the mesh that contains the vertex 794 std::vector<int> v2; 795 vertexbuffermap[simplifindex]=v2; 796 vertexbuffermap[simplifindex].push_back((int)j); //Add the index of vertex in the submesh 797 } 798 else 799 { 800 //the vertex is already in vertices_map, so store the reference of the first one with the same space coodinates 801 simplifindex = mit->second; 802 submeshmap[simplifindex].push_back((int)i); //Submeshes that contains the vertex 803 vertexbuffermap[simplifindex].push_back((int)j); //Indices of the vertex buffers that contains the vertex 804 } 805 } 806 } 807 807 if (objmesh->mSubMesh[i].mSharedVertexBuffer) 808 808 { … … 936 936 TIPOFUNC upb) 937 937 { 938 simpl fmethod_init();938 simplifmethod_init(); 939 939 940 940 if (simpliftype == 0) 941 941 { 942 942 //Percentage option 943 simpl fmethod_run((int)(number_of_triangles*lod),upb);943 simplifmethod_run((int)(number_of_triangles*lod),upb); 944 944 } 945 945 else 946 946 { 947 947 //Number of vertices option 948 simpl fmethod_runv((int)lod,upb);948 simplifmethod_runv((int)lod,upb); 949 949 } 950 950 … … 956 956 957 957 MAPAINDIND *unique_verts_inds_by_geo = new MAPAINDIND[objmesh->mSubMeshCount]; 958 REPINDLIST *ver_inds_rep es_x_geo = new REPINDLIST[objmesh->mSubMeshCount];958 REPINDLIST *ver_inds_rep_by_geo = new REPINDLIST[objmesh->mSubMeshCount]; 959 959 960 960 // Index counter by submesh. … … 966 966 } 967 967 968 qslim::Vertex *auxvertex;969 968 970 969 // Construct the model. … … 974 973 { 975 974 qslim::Face *auxface = M0.face(i); 976 auxvertex = NULL;977 975 978 976 // Determine to which submesh pertains the triangle. … … 1003 1001 1004 1002 // Total number of indices by submesh. 1005 ver_inds_rep es_x_geo[igeo].push_back(auxface->vertex(0)->validID());1006 ver_inds_rep es_x_geo[igeo].push_back(auxface->vertex(1)->validID());1007 ver_inds_rep es_x_geo[igeo].push_back(auxface->vertex(2)->validID());1003 ver_inds_rep_by_geo[igeo].push_back(auxface->vertex(0)->validID()); 1004 ver_inds_rep_by_geo[igeo].push_back(auxface->vertex(1)->validID()); 1005 ver_inds_rep_by_geo[igeo].push_back(auxface->vertex(2)->validID()); 1008 1006 } 1009 1007 } … … 1069 1067 { 1070 1068 // Indices vectors. 1071 mGeoMesh->mSubMesh[i].mIndexCount = ver_inds_rep es_x_geo[i].size();1069 mGeoMesh->mSubMesh[i].mIndexCount = ver_inds_rep_by_geo[i].size(); 1072 1070 mGeoMesh->mSubMesh[i].mIndex = new Index[mGeoMesh-> 1073 1071 mSubMesh[i].mIndexCount]; … … 1077 1075 { 1078 1076 // Obtain the indices that point at VertexBuffer. 1079 mGeoMesh->mSubMesh[i].mIndex[j] = unique_verts_inds_by_geo[i].operator [](ver_inds_rep es_x_geo[i].operator [](j));1077 mGeoMesh->mSubMesh[i].mIndex[j] = unique_verts_inds_by_geo[i].operator [](ver_inds_rep_by_geo[i].operator [](j)); 1080 1078 } 1081 1079 … … 1172 1170 1173 1171 delete[] unique_verts_inds_by_geo; 1174 delete[] ver_inds_rep es_x_geo;1172 delete[] ver_inds_rep_by_geo; 1175 1173 delete[] inextvert; 1176 1174
Note: See TracChangeset
for help on using the changeset viewer.