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

Method BuildHierarchy

code/AssetLib/Collada/ColladaLoader.cpp:233–278  ·  view source on GitHub ↗

------------------------------------------------------------------------------------------------ Recursively constructs a scene node for the given parser node and returns it.

Source from the content-addressed store, hash-verified

231// ------------------------------------------------------------------------------------------------
232// Recursively constructs a scene node for the given parser node and returns it.
233aiNode *ColladaLoader::BuildHierarchy(const ColladaParser &pParser, const Collada::Node *pNode) {
234 // create a node for it
235 auto *node = new aiNode();
236
237 // find a name for the new node. It's more complicated than you might think
238 node->mName.Set(FindNameForNode(pNode));
239 // if we're not using the unique IDs, hold onto them for reference and export
240 if (useColladaName) {
241 if (!pNode->mID.empty()) {
242 AddNodeMetaData(node, AI_METADATA_COLLADA_ID, aiString(pNode->mID));
243 }
244 if (!pNode->mSID.empty()) {
245 AddNodeMetaData(node, AI_METADATA_COLLADA_SID, aiString(pNode->mSID));
246 }
247 }
248
249 // calculate the transformation matrix for it
250 node->mTransformation = pParser.CalculateResultTransform(pNode->mTransforms);
251
252 // now resolve node instances
253 std::vector<const Node*> instances;
254 ResolveNodeInstances(pParser, pNode, instances);
255
256 // add children. first the *real* ones
257 node->mNumChildren = static_cast<unsigned int>(pNode->mChildren.size() + instances.size());
258 if (node->mNumChildren != 0) {
259 node->mChildren = new aiNode * [node->mNumChildren];
260 }
261
262 for (size_t a = 0; a < pNode->mChildren.size(); ++a) {
263 node->mChildren[a] = BuildHierarchy(pParser, pNode->mChildren[a]);
264 node->mChildren[a]->mParent = node;
265 }
266
267 // ... and finally the resolved node instances
268 for (size_t a = 0; a < instances.size(); ++a) {
269 node->mChildren[pNode->mChildren.size() + a] = BuildHierarchy(pParser, instances[a]);
270 node->mChildren[pNode->mChildren.size() + a]->mParent = node;
271 }
272
273 BuildMeshesForNode(pParser, pNode, node);
274 BuildCamerasForNode(pParser, pNode, node);
275 BuildLightsForNode(pParser, pNode, node);
276
277 return node;
278}
279
280// ------------------------------------------------------------------------------------------------
281// Resolve node instances

Callers

nothing calls this directly

Calls 6

AddNodeMetaDataFunction · 0.85
aiStringClass · 0.50
SetMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected