Node copying completed, wip to write into file

This commit is contained in:
Xiao Qi 2022-11-11 18:20:46 +08:00
parent f673036e4e
commit 310765f4f6
2 changed files with 22 additions and 8 deletions

View File

@ -35,7 +35,7 @@ namespace SH_COMP
if (std::strcmp(node.mName.C_Str(), "Armature") == 0)
{
BuildArmature(&node, root);
BuildArmature(node, root);
}
else
{
@ -243,14 +243,28 @@ namespace SH_COMP
void MeshCompiler::BuildArmature(aiNode const& baseNode, RigNode*& root) noexcept
{
std::queue<aiNode const*> nodes;
nodes.push(&baseNode);
RigNode* start = new RigNode();
root = new RigNode();
RigNode* parent = nullptr;
auto current = root;
CopyNode(baseNode, start);
//TODO Use CopyNode de recursive copy
root = start->children[0];
}
void MeshCompiler::CopyNode(aiNode const& source, RigNode* parent) noexcept
{
RigNode* current = new RigNode();
current->name = source.mName.C_Str();
std::memcpy(&current->transform, &source.mTransformation, sizeof(float) * 16);
for (auto i {0}; i < source.mNumChildren; ++i)
{
CopyNode(*source.mChildren[i], current);
}
if (parent)
{
parent->children.push_back(current);
}
}
void MeshCompiler::LoadAndCompile(AssetPath path) noexcept

View File

@ -42,7 +42,7 @@ namespace SH_COMP
static void CompileMeshBinary(AssetPath path, MeshAsset const& asset) noexcept;
static void BuildArmature(aiNode const& node, RigNode*& root) noexcept;
static void CopyNode(aiNode const& source, RigNode*& parent) noexcept;
static void CopyNode(aiNode const& source, RigNode* parent) noexcept;
public:
static void LoadAndCompile(AssetPath path) noexcept;
};