Joint animation: what's wrong with this?

Due to a lack of clues, I’m here again with this annoying (very much indeed) problem, begging help again to our panda gurus

Let’s suppose to have a bone-animated model like this:

for simplicity suppose to animate Bone.001 along the z axis , just like this:

Sadly what I got with my exporter is the correct joint Bone001 axis rotation along the z axis but of the bone structure origin instead of the joint origin such as:

So my question is: what’s wrong with this code? His structure looks good to me and the behaviour, wrong rotation origin apart, is close to be correct so is there some good soul that is able to tellme what the heck is wrong with it?

Sorry it took me a while to get a chance to take a look at this.

In Panda joints, as in the scene graph, when you set a rotation, it always rotates about the origin of the joint: the local (0, 0, 0) point. In many animation packages, however, it is possible to specify an explicit rotate pivot, which is different from the (0, 0, 0) point.

Your joint Bone.001 does not have any translation offset from its parent, so its local (0, 0, 0) point is the same as that of its parent, and thus when you rotate Bone.001, it rotates around the parent’s origin.

It might be that you intended to include a translation offset for Bone.001. Or, maybe the offset is indeed supposed to be (0, 0, 0), but you intended to specify an explicit rotate pivot, so that it rotate around some point other than (0, 0, 0). In order to implement a rotate pivot, you have to build a matrix for the joint animation, of the form:

joint = LMatrix4f::translate_mat(-pivot) * rotate_mat * LMatrix4f::translate_mat(pivot).

A matrix of this form translates the pivot to the origin, performs the rotation, and then translates the pivot back. When you compose matrices like this, you end up with one matrix that performs the overall resulting transform. You can therefore perform this matrix compose for each frame, and add the resulting matrix to the animation table for each frame; the result will be the appropriate animation.


dunno if is true also for you Americans, but here wa say ‘better late than never’ :slight_smile:

so, to put it simple, this means that I got to add a {xyz} for each animation frame even if the bone is just rotating?

Right. And this same translation should be in the rest matrix, as well as in the per-frame data.


Yeah, Americans say that too.

If that’s too much to do by hand, it should be easy enough to write a Python script to do it for you. Or better yet, add the correction code to the exporter script.

Which exporter are you using anyway?

This problem is related to my own python Blender exporter - I’m stuck here from before holidays… :open_mouth: