The core if problem is the build of LocalAnimatedMatrix from Animatedrotation, Animatedposition, Animatedscale - while theese values may not be filled!
For example the value Animatedposition is not filled for example if there are no PositionKeys (!PositionKeys.size()).
The fix of this issue is usage of position, rotation or scale from LocalMatrix
I've not found this fixed in current trunk so I guess it's not solved yet.
my snippet is not ideal I'm sure, but it solved the issue (however I wasn't solving scale coz my animation does not have scale keys)
Code: Select all
void CSkinnedMesh::buildAll_LocalAnimatedMatrices()
{
for (u32 i=0; i<AllJoints.size(); ++i)
{
SJoint *joint = AllJoints[i];
//Could be faster:
if (joint->UseAnimationFrom &&
(joint->UseAnimationFrom->PositionKeys.size() ||
joint->UseAnimationFrom->ScaleKeys.size() ||
joint->UseAnimationFrom->RotationKeys.size() ))
{
joint->GlobalSkinningSpace=false;
joint->LocalAnimatedMatrix.makeIdentity();
if (joint->UseAnimationFrom->PositionKeys.size())
joint->LocalAnimatedMatrix.setTranslation(joint->Animatedposition);
else
joint->LocalAnimatedMatrix.setTranslation(joint->LocalMatrix.getTranslation());
if (joint->UseAnimationFrom->RotationKeys.size())
joint->LocalAnimatedMatrix = joint->LocalAnimatedMatrix * joint->Animatedrotation.getMatrix();
else
{
core::quaternion rot (joint->LocalMatrix);
joint->LocalAnimatedMatrix = joint->LocalAnimatedMatrix * rot.getMatrix();
}
}
else
{
joint->LocalAnimatedMatrix=joint->LocalMatrix;
}
}
}