I have a problem with bones rotation.
What I'm trying to do is rotate character's bone (torso) regardless of parent bone rotation. However when I rotate bone's local matrix, it rotates it locally (as in along parent's facing direction). Let me show you my code:
Code: Select all
for (int i = 0; i < bones.size(); i++) {
AnimationBone* animationBone = bones.at(i);
IBoneSceneNode* bone = animationBone->meshBone;
if (animationBone->rotation != Util::VECTOR3DFZERO) {
if (bone != NULL) {
CMatrix4<f32> trans = CMatrix4<f32>(bone->getRelativeTransformation());
CMatrix4<f32> rot; rot.setRotationDegrees(animationBone->rotation);
CMatrix4<f32> _invParentTrans; bone->getParent()->getAbsoluteTransformation().getInverse(_invParentTrans);
trans *= _invParentTrans;
trans *= rot;
trans *= bone->getParent()->getAbsoluteTransformation();
bone->setRotation(trans.getRotationDegrees());
};
};
};
From what I understand I implemented skinning in global space. Irrlicht however uses local space.
Is there a way to rotate a bone in world space without actually changing its skinning space? Because it kinda scrambles the whole model around.