Author Topic: Which matrix is the best to rotate a bone?  (Read 4948 times)

Offline Tangomajom

  • byte
  • *
  • Posts: 11
    • View Profile
Which matrix is the best to rotate a bone?
« on: April 19, 2016, 10:18:48 am »

Maybe this sounds a bit stupid, but I can't find out by myself.
So I would like to apply an Euler rotation based animation to my imported rigged model. The animation in the Collada file is played correctly, but I would like to create the same animation programatically.

My idea is to create a quaternion from the original rotation of the bone, and then I'll use the Quaternion.rotateX/Y/Z methods, and then this modified quaternion will go to the JointChannel.
The only question is that how can I reach the current rotation matrix of the bone, to create the good quaternion from it.

I tried to use the SkeletonHelper.getBoneDirection(animatedJoint).getRotationMatrix(), and also the animatedObject.get(0).getSkeletonPose().getLocal(animatedJoint.getIndex()).getTranslation().getRotationMatrix(), and they inverts as well, but none of them produced the expected result.

Please give an advise.

Thanks in advance,

Offline raft

  • Moderator
  • quad
  • *****
  • Posts: 1993
    • View Profile
Re: Which matrix is the best to rotate a bone?
« Reply #1 on: April 19, 2016, 10:26:37 am »
to get the rotation quat:

Code: [Select]
new Quaternion(SkeletonPose.getLocal(<index>))
and for sure that means, SkeletonPose.getLocal(<index>) actually contains the rotation information.