| 668 | } |
| 669 | |
| 670 | void AMFImporter::Postprocess_BuildConstellation(AMFConstellation &pConstellation, NodeArray &nodeArray) const { |
| 671 | aiNode *con_node; |
| 672 | std::list<aiNode *> ch_node; |
| 673 | |
| 674 | // We will build next hierarchy: |
| 675 | // aiNode as parent (<constellation>) for set of nodes as a children |
| 676 | // |- aiNode for transformation (<instance> -> <delta...>, <r...>) - aiNode for pointing to object ("objectid") |
| 677 | // ... |
| 678 | // \_ aiNode for transformation (<instance> -> <delta...>, <r...>) - aiNode for pointing to object ("objectid") |
| 679 | con_node = new aiNode; |
| 680 | con_node->mName = pConstellation.ID; |
| 681 | // Walk through children and search for instances of another objects, constellations. |
| 682 | for (const AMFNodeElementBase *ne : pConstellation.Child) { |
| 683 | aiMatrix4x4 tmat; |
| 684 | aiNode *t_node; |
| 685 | aiNode *found_node; |
| 686 | |
| 687 | if (ne->Type == AMFNodeElementBase::ENET_Metadata) continue; |
| 688 | if (ne->Type != AMFNodeElementBase::ENET_Instance) throw DeadlyImportError("Only <instance> nodes can be in <constellation>."); |
| 689 | |
| 690 | // create alias for convenience |
| 691 | AMFInstance &als = *((AMFInstance *)ne); |
| 692 | // find referenced object |
| 693 | if (!Find_ConvertedNode(als.ObjectID, nodeArray, &found_node)) Throw_ID_NotFound(als.ObjectID); |
| 694 | |
| 695 | // create node for applying transformation |
| 696 | t_node = new aiNode; |
| 697 | t_node->mParent = con_node; |
| 698 | // apply transformation |
| 699 | aiMatrix4x4::Translation(als.Delta, tmat), t_node->mTransformation *= tmat; |
| 700 | aiMatrix4x4::RotationX(als.Rotation.x, tmat), t_node->mTransformation *= tmat; |
| 701 | aiMatrix4x4::RotationY(als.Rotation.y, tmat), t_node->mTransformation *= tmat; |
| 702 | aiMatrix4x4::RotationZ(als.Rotation.z, tmat), t_node->mTransformation *= tmat; |
| 703 | // create array for one child node |
| 704 | t_node->mNumChildren = 1; |
| 705 | t_node->mChildren = new aiNode *[t_node->mNumChildren]; |
| 706 | SceneCombiner::Copy(&t_node->mChildren[0], found_node); |
| 707 | t_node->mChildren[0]->mParent = t_node; |
| 708 | ch_node.push_back(t_node); |
| 709 | } // for(const CAMFImporter_NodeElement* ne: pConstellation.Child) |
| 710 | |
| 711 | // copy found aiNode's as children |
| 712 | if (ch_node.empty()) throw DeadlyImportError("<constellation> must have at least one <instance>."); |
| 713 | |
| 714 | size_t ch_idx = 0; |
| 715 | |
| 716 | con_node->mNumChildren = static_cast<unsigned int>(ch_node.size()); |
| 717 | con_node->mChildren = new aiNode *[con_node->mNumChildren]; |
| 718 | for (aiNode *node : ch_node) |
| 719 | con_node->mChildren[ch_idx++] = node; |
| 720 | |
| 721 | // and place "root" of <constellation> node to node list |
| 722 | nodeArray.push_back(con_node); |
| 723 | } |
| 724 | |
| 725 | void AMFImporter::Postprocess_BuildScene(aiScene *pScene) { |
| 726 | NodeArray nodeArray; |
nothing calls this directly
no test coverage detected