Open focusright opened 3 months ago
The repo where I am working on this is located here
FWIW, all the tutorials source can be found https://github.com/walbourn/directxtk-tutorials
I looked at the tutorial source and found the culprit, the line
m_model->CopyBoneTransformsTo(nbones, m_animBones.get());
needs to remain right after the lines where the bone arrays are made:
m_drawBones = ModelBone::MakeArray(nbones);
m_animBones = ModelBone::MakeArray(nbones);
m_model->CopyBoneTransformsTo(nbones, m_animBones.get());
uint32_t index = 0;
for (const auto& it : m_model->bones)
{
if (_wcsicmp(it.name.c_str(), L"tank_geo") == 0)
{
// Need to recenter the model.
m_animBones[index] = XMMatrixIdentity();
}
++index;
}
In this section of the wiki
https://github.com/microsoft/DirectXTK12/wiki/Animating-using-model-bones#modifying-model-bones
the last sentence is "(after you have loaded the model and created the bone arrays):"
which made my code like this:
m_drawBones = ModelBone::MakeArray(nbones);
m_animBones = ModelBone::MakeArray(nbones);
uint32_t index = 0;
for (const auto& it : m_model->bones)
{
if (_wcsicmp(it.name.c_str(), L"tank_geo") == 0)
{
// Need to recenter the model.
m_animBones[index] = XMMatrixIdentity();
}
++index;
}
m_model->CopyBoneTransformsTo(nbones, m_animBones.get());
Hopefully this will help someone else who tries to follow the tutorial like I did.
In this wiki documentation
https://github.com/microsoft/DirectXTK12/wiki/Animating-using-model-bones#modifying-model-bones
The result does not match the screenshot provided. The problem can be addressed either in the model or the CreateLookAt() function in Game::CreateWindowSizeDependentResources(). Since I don't have the original source file of the model I fixed it in the code with
The main fix being in changing the Vector3 parameters in the CreateLookAt() function.