MCPcopy Create free account
hub / github.com/assimp/assimp / Postprocess_BuildScene

Method Postprocess_BuildScene

code/AssetLib/AMF/AMFImporter_Postprocess.cpp:725–888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725void AMFImporter::Postprocess_BuildScene(aiScene *pScene) {
726 NodeArray nodeArray;
727 MeshArray mesh_list;
728 AMFMetaDataArray meta_list;
729
730 //
731 // Because for AMF "material" is just complex colors mixing so aiMaterial will not be used.
732 // For building aiScene we are must to do few steps:
733 // at first creating root node for aiScene.
734 pScene->mRootNode = new aiNode;
735 pScene->mRootNode->mParent = nullptr;
736 pScene->mFlags |= AI_SCENE_FLAGS_ALLOW_SHARED;
737 // search for root(<amf>) element
738 AMFNodeElementBase *root_el = nullptr;
739
740 for (AMFNodeElementBase *ne : mNodeElement_List) {
741 if (ne->Type != AMFNodeElementBase::ENET_Root) {
742 continue;
743 }
744
745 root_el = ne;
746 break;
747 } // for(const CAMFImporter_NodeElement* ne: mNodeElement_List)
748
749 // Check if root element are found.
750 if (root_el == nullptr) {
751 throw DeadlyImportError("Root(<amf>) element not found.");
752 }
753
754 // after that walk through children of root and collect data. Five types of nodes can be placed at top level - in <amf>: <object>, <material>, <texture>,
755 // <constellation> and <metadata>. But at first we must read <material> and <texture> because they will be used in <object>. <metadata> can be read
756 // at any moment.
757 //
758 // 1. <material>
759 // 2. <texture> will be converted later when processing triangles list. \sa Postprocess_BuildMeshSet
760 for (const AMFNodeElementBase *root_child : root_el->Child) {
761 if (root_child->Type == AMFNodeElementBase::ENET_Material) {
762 Postprocess_BuildMaterial(*((AMFMaterial *)root_child));
763 }
764 }
765
766 // After "appearance" nodes we must read <object> because it will be used in <constellation> -> <instance>.
767 //
768 // 3. <object>
769 for (const AMFNodeElementBase *root_child : root_el->Child) {
770 if (root_child->Type == AMFNodeElementBase::ENET_Object) {
771 aiNode *tnode = nullptr;
772
773 // for <object> mesh and node must be built: object ID assigned to aiNode name and will be used in future for <instance>
774 Postprocess_BuildNodeAndObject(*((AMFObject *)root_child), mesh_list, &tnode);
775 if (tnode != nullptr) {
776 nodeArray.push_back(tnode);
777 }
778 }
779 } // for(const CAMFImporter_NodeElement* root_child: root_el->Child)
780
781 // And finally read rest of nodes.
782 //

Callers

nothing calls this directly

Calls 9

DeadlyImportErrorFunction · 0.85
eraseMethod · 0.80
push_backMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
FindNodeMethod · 0.45
emptyMethod · 0.45
AddPropertyMethod · 0.45

Tested by

no test coverage detected