Changeset 1578 for GTP/trunk/Lib
- Timestamp:
- 10/06/06 17:10:18 (18 years ago)
- Location:
- GTP/trunk/Lib/Geom/shared/GTGeometry/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoLodStripsConstructor.cpp
r1552 r1578 522 522 523 523 this->GenerarModeloCompleto(upb); 524 525 // Sort submesh bones.526 this->sortBones();527 524 } 528 525 … … 974 971 void LodStripsConstructor::sortBones() 975 972 { 976 bool shared_found;977 int n;978 int o;979 int p;980 VertexBoneAssignment assign;981 SubMesh *submesh;982 SubMesh *copysubmesh;983 973 VertexBuffer *mesh_vb; 984 974 VertexBuffer *copy_vb; … … 987 977 std::vector<VertexBoneAssignment> *copy_bones; 988 978 989 // Initialize shared vertex flag. 990 shared_found = false; 991 992 // For each submesh. 993 for (size_t i = 0; i < mGeoMesh->mSubMeshCount; i++) 994 { 995 submesh = &mGeoMesh->mSubMesh[i]; 996 copysubmesh = &mInitialMesh->mSubMesh[i]; 997 998 // If submesh has shared vertex. 999 if (submesh->mSharedVertexBuffer) 1000 { 1001 if (shared_found) 1002 { 1003 continue; 1004 } 1005 1006 shared_found = true; 1007 1008 // Vertex buffers. 1009 mesh_vb = mGeoMesh->mVertexBuffer; 1010 copy_vb = mInitialMesh->mVertexBuffer; 1011 1012 // Bones. 1013 mesh_bones = &mGeoMesh->mBones; 1014 copy_bones = &mInitialMesh->mBones; 1015 } 1016 else 1017 { 1018 // Vertex buffers. 1019 mesh_vb = submesh->mVertexBuffer; 1020 copy_vb = copysubmesh->mVertexBuffer; 1021 1022 // Bones. 1023 mesh_bones = &submesh->mBones; 1024 copy_bones = ©submesh->mBones; 1025 } 979 // After simplifying, the object always is shared vertex 980 // so, the bones must be placed in the GeoMesh 981 mesh_bones = &mGeoMesh->mBones; 982 mesh_vb = mGeoMesh->mVertexBuffer; 983 984 // we assume the original mesh is shared vertex 985 // because before the simplification process 986 // the mesh becomes converted to shared vertex 987 // so, the original bones must be searched in the 988 // Mesh, not in every submesh 989 990 mesh_bones->clear(); 991 992 // Vertex buffers. 993 copy_vb = mInitialMesh->mVertexBuffer; 994 995 // Bones. 996 copy_bones = &mInitialMesh->mBones; 997 998 // If there are submesh bones. 999 for (int b = 0; b < copy_bones->size(); b++) 1000 { 1001 VertexBoneAssignment assign; 1002 1003 int n = (*copy_bones)[b].vertexIndex; 1004 1005 // Initialize o. 1026 1006 1027 i f (!mesh_bones->empty())1028 {1029 assign.boneIndex = 0;1030 assign.weight = 1;1031 1032 for (size_t m = copy_vb->mVertexCount;1033 m < mesh_vb->mVertexCount;1034 m++)1035 {1036 assign. vertexIndex = (unsigned int)m;1007 int o=0; 1008 for (o=0; o<mesh_vb->mVertexCount; o++) 1009 { 1010 if (mesh_vb->mPosition[o].x == copy_vb->mPosition[n].x && 1011 mesh_vb->mPosition[o].y == copy_vb->mPosition[n].y && 1012 mesh_vb->mPosition[o].z == copy_vb->mPosition[n].z) 1013 { 1014 assign.vertexIndex = o; 1015 assign.boneIndex = (*copy_bones)[b].boneIndex; 1016 assign.weight = 1.0f; 1037 1017 mesh_bones->push_back(assign); 1038 } 1039 1040 // Change bones. 1041 for (size_t m = 0; m < mesh_bones->size(); m++) 1042 { 1043 n = (*mesh_bones)[m].vertexIndex; 1044 o = 0; 1045 1046 while (!( (mesh_vb->mPosition[n].x == copy_vb->mPosition[o].x) && 1047 (mesh_vb->mPosition[n].y == copy_vb->mPosition[o].y) && 1048 (mesh_vb->mPosition[n].z == copy_vb->mPosition[o].z))) 1049 { 1050 o++; 1051 } 1052 1053 p = 0; 1054 1055 while ((*copy_bones)[p].vertexIndex != o) 1056 p++; 1057 1058 // Same bone for 'm' and 'p'. 1059 (*mesh_bones)[m].boneIndex = (*copy_bones)[p].boneIndex; 1060 } 1061 1062 // Look for repeated bones. 1063 for (size_t m = 0; m < mesh_vb->mVertexCount; m++) 1064 { 1065 for (size_t n = m + 1; n < mesh_vb->mVertexCount; n++) 1066 { 1067 if ((mesh_vb->mPosition[m].x == mesh_vb->mPosition[n].x) 1068 && 1069 (mesh_vb->mPosition[m].y == mesh_vb->mPosition[n].y) 1070 && 1071 (mesh_vb->mPosition[m].z == mesh_vb->mPosition[n].z)) 1072 { 1073 o = 0; 1074 1075 while ((*mesh_bones)[o].vertexIndex != m) 1076 { 1077 o++; 1078 } 1079 1080 p = 0; 1081 1082 while ((*mesh_bones)[p].vertexIndex != n) 1083 { 1084 p++; 1085 } 1086 1087 if ((*mesh_bones)[o].boneIndex != (*mesh_bones)[p].boneIndex) 1088 { 1089 printf("-->Error en los vertices %d y %d\n",m,n); 1090 } 1091 } 1092 } 1093 } 1018 } 1094 1019 } 1095 1020 } … … 1286 1211 } 1287 1212 } 1213 1214 // Sort submesh bones. 1215 this->sortBones(); 1288 1216 } 1289 1217 -
GTP/trunk/Lib/Geom/shared/GTGeometry/src/GeoMeshSimplifier.cpp
r1526 r1578 71 71 void MeshSimplifier::sortBones() 72 72 { 73 bool shared_found;74 int n;75 int o;76 int p;77 VertexBoneAssignment assign;78 73 VertexBuffer *mesh_vb; 79 74 VertexBuffer *copy_vb; 80 SubMesh *geosubmesh;81 SubMesh *copysubmesh;82 75 83 76 std::vector<VertexBoneAssignment> *mesh_bones; 84 77 std::vector<VertexBoneAssignment> *copy_bones; 85 86 // Initialize shared flag. 87 shared_found = false; 88 89 // For each submesh. 90 for (size_t i = 0; i < mGeoMesh->mSubMeshCount; i++) 91 { 92 geosubmesh = &mGeoMesh->mSubMesh[i]; 93 copysubmesh = &mInitialMesh->mSubMesh[i]; 94 95 // If submesh has shared vertex. 96 if (geosubmesh->mSharedVertexBuffer) 97 { 98 if (shared_found) 78 79 // After simplifying, the object always is shared vertex 80 // so, the bones must be placed in the GeoMesh 81 mesh_bones = &mGeoMesh->mBones; 82 mesh_vb = mGeoMesh->mVertexBuffer; 83 84 // we assume the original mesh is shared vertex 85 // because before the simplification process 86 // the mesh becomes converted to shared vertex 87 // so, the original bones must be searched in the 88 // Mesh, not in every submesh 89 90 mesh_bones->clear(); 91 92 // Vertex buffers. 93 copy_vb = mInitialMesh->mVertexBuffer; 94 95 // Bones. 96 copy_bones = &mInitialMesh->mBones; 97 98 // If there are submesh bones. 99 for (int b = 0; b < copy_bones->size(); b++) 100 { 101 VertexBoneAssignment assign; 102 103 int n = (*copy_bones)[b].vertexIndex; 104 105 // Initialize o. 106 107 int o=0; 108 for (o=0; o<mesh_vb->mVertexCount; o++) 109 { 110 if (mesh_vb->mPosition[o].x == copy_vb->mPosition[n].x && 111 mesh_vb->mPosition[o].y == copy_vb->mPosition[n].y && 112 mesh_vb->mPosition[o].z == copy_vb->mPosition[n].z) 99 113 { 100 continue; 101 } 102 103 shared_found = true; 104 105 // Vertex buffers. 106 mesh_vb = mGeoMesh->mVertexBuffer; 107 copy_vb = mInitialMesh->mVertexBuffer; 108 109 // Bones. 110 mesh_bones = &mGeoMesh->mBones; 111 copy_bones = &mInitialMesh->mBones; 112 } 113 else 114 { 115 // Vertex buffers. 116 mesh_vb = geosubmesh->mVertexBuffer; 117 copy_vb = copysubmesh->mVertexBuffer; 118 119 // Bones. 120 mesh_bones = &geosubmesh->mBones; 121 copy_bones = ©submesh->mBones; 122 } 123 124 // If there is submesh bones. 125 if (!mesh_bones->empty()) 126 { 127 assign.boneIndex = 0; 128 assign.weight = 1; 129 130 mesh_bones->clear(); 131 132 for (size_t m = 0; m < mesh_vb->mVertexCount; m++) 133 { 134 assign.vertexIndex = (int)m; 135 114 assign.vertexIndex = o; 115 assign.boneIndex = (*copy_bones)[b].boneIndex; 116 assign.weight = 1.0f; 136 117 mesh_bones->push_back(assign); 137 } 138 139 // Change bones. 140 for (size_t m = 0; m < mesh_bones->size(); m++) 141 { 142 n = (*mesh_bones)[m].vertexIndex; 143 144 // Initialize o. 145 o = 0; 146 147 while (!( 148 (mesh_vb->mPosition[n].x == copy_vb->mPosition[o].x) 149 && 150 (mesh_vb->mPosition[n].y == copy_vb->mPosition[o].y) 151 && 152 (mesh_vb->mPosition[n].z == copy_vb->mPosition[o].z) 153 )) 154 { 155 o++; 156 } 157 158 // Initialize p. 159 p = 0; 160 161 while ((*copy_bones)[p].vertexIndex != o) 162 { 163 p++; 164 } 165 166 // Same bone for 'm' and 'p'. 167 (*mesh_bones)[m].boneIndex = (*copy_bones)[p].boneIndex; 168 } 169 } 170 } 171 118 } 119 } 120 } 172 121 } 173 122 … … 207 156 mGeoMesh = m_qslim->GetMesh(); 208 157 158 // if the initial mesh had shared vertex, 159 // convert the mesh to shared vertex 160 for (int i=0; i<mInitialMesh->mSubMeshCount; i++) 161 { 162 if (mInitialMesh->mSubMesh[i].mSharedVertexBuffer) 163 { 164 Mesh *sharedMesh = mGeoMesh->toSharedVertex(); 165 delete mGeoMesh; 166 mGeoMesh = sharedMesh; 167 break; 168 } 169 } 170 209 171 // Sort bones. 210 172 sortBones(); … … 226 188 mGeoMesh = m_qslim->GetMesh(); 227 189 190 // if the initial mesh had shared vertex, 191 // convert the mesh to shared vertex 192 for (int i=0; i<mInitialMesh->mSubMeshCount; i++) 193 { 194 if (mInitialMesh->mSubMesh[i].mSharedVertexBuffer) 195 { 196 Mesh *sharedMesh = mGeoMesh->toSharedVertex(); 197 delete mGeoMesh; 198 mGeoMesh = sharedMesh; 199 break; 200 } 201 } 202 228 203 // Sort bones. 229 204 sortBones();
Note: See TracChangeset
for help on using the changeset viewer.