提问人:user19632259 提问时间:8/4/2023 最后编辑:user19632259 更新时间:8/4/2023 访问量:41
加载了 Dx11 assimp 的 .dae 模型看起来很奇怪
The .dae model loaded with Dx11 assimp looks strange
问:
(图片在底部)
我目前正在 DX11 引擎中使用 assimp 来加载模型,但我在将两个模型连接在一起时遇到了困难。
我正在为我的研究重新创建超级马里奥奥德赛,我使用工具箱提取器从 mariobody、handL、handR 和 head.szs 文件中提取 .dae 文件。然后,我使用 assimp 读取这些 .dae 文件。
当我单独加载每个模型时,它们会正确显示。但是,当我尝试将手和头部连接到身体上时,我遇到了问题。
连接模型时,我将矩阵从根节点累积到连接节点,如果有父模型,则相应地链接模型。
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);
}
}
基于它在 Blender 和提取器中正确打开的事实,我认为 .dae 文件没有任何问题。
但是,我也怀疑模型本身可能存在问题。因此,我会将模型文件附加到相应的Google云端硬盘中,以防万一。Google云端硬盘
如果您需要任何其他代码,请随时告诉我。
答: 暂无答案
评论