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

Function ImportNode

code/AssetLib/glTF/glTFImporter.cpp:534–605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

532}
533
534aiNode *ImportNode(aiScene *pScene, Asset &r, std::vector<unsigned int> &meshOffsets, Ref<Node> &ptr) {
535 Node &node = *ptr;
536
537 aiNode *ainode = new aiNode(node.id);
538
539 if (!node.children.empty()) {
540 ainode->mNumChildren = static_cast<unsigned>(node.children.size());
541 ainode->mChildren = new aiNode *[ainode->mNumChildren];
542
543 for (unsigned int i = 0; i < ainode->mNumChildren; ++i) {
544 aiNode *child = ImportNode(pScene, r, meshOffsets, node.children[i]);
545 child->mParent = ainode;
546 ainode->mChildren[i] = child;
547 }
548 }
549
550 aiMatrix4x4 &matrix = ainode->mTransformation;
551 if (node.matrix.isPresent) {
552 CopyValue(node.matrix.value, matrix);
553 } else {
554 if (node.translation.isPresent) {
555 aiVector3D trans;
556 CopyValue(node.translation.value, trans);
557 aiMatrix4x4 t;
558 aiMatrix4x4::Translation(trans, t);
559 matrix = t * matrix;
560 }
561
562 if (node.scale.isPresent) {
563 aiVector3D scal(1.f);
564 CopyValue(node.scale.value, scal);
565 aiMatrix4x4 s;
566 aiMatrix4x4::Scaling(scal, s);
567 matrix = s * matrix;
568 }
569
570 if (node.rotation.isPresent) {
571 aiQuaternion rot;
572 CopyValue(node.rotation.value, rot);
573 matrix = aiMatrix4x4(rot.GetMatrix()) * matrix;
574 }
575 }
576
577 if (!node.meshes.empty()) {
578 int count = 0;
579 for (size_t i = 0; i < node.meshes.size(); ++i) {
580 const int idx = node.meshes[i].GetIndex();
581 count += meshOffsets[idx + 1] - meshOffsets[idx];
582 }
583
584 ainode->mNumMeshes = count;
585 ainode->mMeshes = new unsigned int[count];
586
587 int k = 0;
588 for (size_t i = 0; i < node.meshes.size(); ++i) {
589 const int idx = node.meshes[i].GetIndex();
590 for (unsigned int j = meshOffsets[idx]; j < meshOffsets[idx + 1]; ++j, ++k) {
591 ainode->mMeshes[k] = j;

Callers 3

ImportNodesMethod · 0.85
ImportNodeMethod · 0.85
ImportNodesMethod · 0.85

Calls 7

TranslationClass · 0.85
aiMatrix4x4Class · 0.85
GetMatrixMethod · 0.80
GetIndexMethod · 0.80
CopyValueFunction · 0.70
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected