(The Pictures are at bottom)
I am currently using assimp in my DX11 engine to load models, but I am facing difficulty in concatenating two models together.
I am recreating Super Mario Odyssey for my study, and I used the Toolbox Extractor to extract .dae files from mariobody, handL, handR, and head.szs files. Then, I used assimp to read these .dae files.
When I load each model separately, they appear correctly. However, I encounter issues when trying to attach the hands and head to the body.
When connecting the models, I accumulate the matrices from the root node to the connecting node, and if there is a parent model, I link the model accordingly.
void Model::recursiveProcessBoneMatrix(aiMatrix4x4 matrix, const std::wstring& nodeName)
{
const ModelNode* modelNode = FindNode(nodeName);
aiMatrix4x4 transform = modelNode->mTransformation;
if (mParentModel)
{
// Code written to search for nodes with the same name in the model.
ModelNode* parentModelNode = mParentModel->FindNode(nodeName);
if (parentModelNode)
{
/*
Set my hierarchy information based on the parent's corresponding node hierarchy.
Although the model is forced to move to the position of that node,
it causes rotation issues.
*/
Bone* bone = mParentModel->FindBone(nodeName);
if (bone != nullptr)
{
bone = mParentModel->GetBone(bone->mIndex);
matrix = bone->mLocalMatrix;
}
}
}
matrix = matrix * transform;
if (mBoneMap.find(nodeName) != mBoneMap.end())
{
Bone* bone = &mBoneMap.find(nodeName)->second;
aiMatrix4x4 glovalInvers = FindNode(L"Scene")->GetTransformation();
// bone->mOffsetMatrix - vectex to bonespace (like world, view, projection transform)
//matrix - transformed martrix from root
bone->mFinalMatrix = glovalInvers.Inverse() * matrix * bone->mOffsetMatrix;
bone->mLocalMatrix = matrix;
mBones[bone->mIndex].mFinalMatrix = bone->mFinalMatrix;
mBones[bone->mIndex].mLocalMatrix = matrix;
}
for (size_t i = 0; i < modelNode->mChilds.size(); ++i)
{
recursiveProcessBoneMatrix(matrix, modelNode->mChilds[i]->mName);
}
}
Based on the fact that it opens correctly in Blender and the extractor, I don't think there's anything wrong with the .dae file.
However, I also suspect that there might be issues with the model itself. So, I will attach the model files to the corresponding Google Drive just in case. google drive
If you need any other code, feel free to let me know at any time.

