Mirror hierarchy in local space

Started by
14 comments, last by JohnnyCode 8 years, 7 months ago

Hi,

I'm searching a way to mirror an hierarchy stored in local space.

Each transformation is relative to its parent and is stored as translation, rotation using quaternion and scaling.

The goal is to mirror a skeleton but it's the same thing as mirror an hierarchy of node.

The goal is to transform the translation and rotation to have the mirror correctly.

The mirror table is generated to know what transformation has to be swapped.

What doesn't work is to invert sign of translation and quaternion like that :


translation.x = -translation.x;
quaternion.x = -quaternion.x;
quaternion.w = -quaternion.w;

The scaling has to stay intact because the hierarchy can be blended with another after the mirror process.

Thanks for the help

Advertisement

Are you trying to invert it completely (i.e. x=-x, y=-y, z=-x)? You should be able to achieve this just by inverting the transform of the root bone and leaving all other local transforms intact. You can't do it with only translation/rotation, though, since those always preserve the orientation; setting scaling to -1 is the only way to achieve this. What do you mean by blending with another orientation, what do you expect from blending a mirrored transform with a regular one? You'll probably just get a zero as a result (i.e. the whole model collapses into one point).

It's part of a blend tree animation but mirror transform is surely the same problem when you have a hierarchy of actor.

On the blend tree the animation node output a pose and this pose can be blended with another poses until get the final pose.

You can't do it with only translation/rotation

It's absolutly possible but it's a very advanced topic of animation system.

I say it's possible because other already have the feature, not a lot because it's not an easy topic but some system has the feature like Morpheme or Havok Animation.

Umm what do you mean by mirror, anyway? If you're talking about a transformation like x=-x, it can't be expressed by quaternions.

You can see a screenshot of the result of the mirroring here :

https://udn.epicgames.com/Three/rsrc/Three/AnimationMirroring/SkeletalMeshMirrorExample.jpg

The only limitation is the symmetrical hierarchy needed. I already have the mirror table generated correctly to know the mirror node (same node if no mirror node found).

To compute the mirror, it's possible to use the full hierarchy of the pose in local space, each parent is known, each bind pose in local space is known.

Formula to mirror a vector V with a normal N : V - 2.0 * Dot(V, N) * N

Well as I said, if you can only change translation and rotation, there is no way to get a mirror, its mathematically impossible. All rotation matrices have determinant = 1, whereas mirror has -1. You can *only* achieve it with scaling - set scaling to -1 and figure out which rotation you need to get the correct mirror plane.

Alternatively, if you can specify the transformation matrix directly, you can just do that instead. You only need to do it to the root node, since the child nodes should correctly inherit the transform.

Using the naive/bad method of inversing translation.x, quaternion.x and quaternion.w (which is the same result as using (1,0,0) as normal).

I got simple animation mirrored correctly if the parent transformation is identity and 2 nodes are its children.

For a complex skeleton using the naive/bad method only some part of the hierarchy is correctly mirrored, here the result :

Without mirror : http://zupimages.net/up/15/34/pgb9.png

With mirror : http://zupimages.net/up/15/34/utwc.png

Looks like mirror axis problem.

The foot is badly oriented and the pelvis too and other parts.

Here the result of the skeleton :

Without mirror : http://zupimages.net/up/15/34/31so.png

With mirror : http://zupimages.net/up/15/34/un1a.png

The translation is correctly mirrored, only the quaternion is badly mirrored apparently.

You flipped the bone positions, but you didn't invert the actual model. So you're wearing the left shoe on what is now the right foot, basically.

Yeah it's what called Animation Mirroring, invert the hierarchy using a mirror table to know if two bone needs to be swapped.

The translation is flipped but the orientation is also flipped.

Oh so you're basically applying the transform intended for the left foot bone to the right foot bone instead? That makes more sense, sorry for misunderstanding. The screenshots look as if you just flipped the bones though, without swapping the transforms. Can you verify that the left foot bone is still on the left?

I tried it with my model and it worked perfectly fine, swapping transforms between all 'left' and 'right' bones and inverting X/W values.

This topic is closed to new replies.

Advertisement