| 361 | } |
| 362 | |
| 363 | void AMFImporter::Postprocess_BuildMeshSet(const AMFMesh &pNodeElement, const std::vector<aiVector3D> &pVertexCoordinateArray, |
| 364 | const std::vector<AMFColor *> &pVertexColorArray, const AMFColor *pObjectColor, MeshArray &pMeshList, aiNode &pSceneNode) { |
| 365 | std::list<unsigned int> mesh_idx; |
| 366 | |
| 367 | // all data stored in "volume", search for it. |
| 368 | for (const AMFNodeElementBase *ne_child : pNodeElement.Child) { |
| 369 | const AMFColor *ne_volume_color = nullptr; |
| 370 | const SPP_Material *cur_mat = nullptr; |
| 371 | |
| 372 | if (ne_child->Type == AMFNodeElementBase::ENET_Volume) { |
| 373 | /******************* Get faces *******************/ |
| 374 | const AMFVolume *ne_volume = reinterpret_cast<const AMFVolume *>(ne_child); |
| 375 | |
| 376 | std::list<SComplexFace> complex_faces_list; // List of the faces of the volume. |
| 377 | std::list<std::list<SComplexFace>> complex_faces_toplist; // List of the face list for every mesh. |
| 378 | |
| 379 | // check if volume use material |
| 380 | if (!ne_volume->MaterialID.empty()) { |
| 381 | if (!Find_ConvertedMaterial(ne_volume->MaterialID, &cur_mat)) { |
| 382 | Throw_ID_NotFound(ne_volume->MaterialID); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | // inside "volume" collect all data and place to arrays or create new objects |
| 387 | for (const AMFNodeElementBase *ne_volume_child : ne_volume->Child) { |
| 388 | // color for volume |
| 389 | if (ne_volume_child->Type == AMFNodeElementBase::ENET_Color) { |
| 390 | ne_volume_color = reinterpret_cast<const AMFColor *>(ne_volume_child); |
| 391 | } else if (ne_volume_child->Type == AMFNodeElementBase::ENET_Triangle) // triangles, triangles colors |
| 392 | { |
| 393 | const AMFTriangle &tri_al = *reinterpret_cast<const AMFTriangle *>(ne_volume_child); |
| 394 | |
| 395 | SComplexFace complex_face; |
| 396 | |
| 397 | // initialize pointers |
| 398 | complex_face.Color = nullptr; |
| 399 | complex_face.TexMap = nullptr; |
| 400 | // get data from triangle children: color, texture coordinates. |
| 401 | if (tri_al.Child.size()) { |
| 402 | for (const AMFNodeElementBase *ne_triangle_child : tri_al.Child) { |
| 403 | if (ne_triangle_child->Type == AMFNodeElementBase::ENET_Color) |
| 404 | complex_face.Color = reinterpret_cast<const AMFColor *>(ne_triangle_child); |
| 405 | else if (ne_triangle_child->Type == AMFNodeElementBase::ENET_TexMap) |
| 406 | complex_face.TexMap = reinterpret_cast<const AMFTexMap *>(ne_triangle_child); |
| 407 | } |
| 408 | } // if(tri_al.Child.size()) |
| 409 | |
| 410 | // create new face and store it. |
| 411 | complex_face.Face.mNumIndices = 3; |
| 412 | complex_face.Face.mIndices = new unsigned int[3]; |
| 413 | complex_face.Face.mIndices[0] = static_cast<unsigned int>(tri_al.V[0]); |
| 414 | complex_face.Face.mIndices[1] = static_cast<unsigned int>(tri_al.V[1]); |
| 415 | complex_face.Face.mIndices[2] = static_cast<unsigned int>(tri_al.V[2]); |
| 416 | complex_faces_list.push_back(complex_face); |
| 417 | } |
| 418 | } // for(const CAMFImporter_NodeElement* ne_volume_child: ne_volume->Child) |
| 419 | |
| 420 | /**** Split faces list: one list per mesh ****/ |