View Full Version : How to compute mirrored joint orientation?
Xeash 07-13-2009, 06:50 PM I have this problem in Maya, but I know that is non-software dependent.
As I know any major software(I'm talking about Max,Maya,XSI) have tool to mirror bones(or joints). These tools get in input bones rotation/joint orientaion and compute output rotation/orientation for mirrored bone/joint. I wonder how I can make the same computation? i.e. how I can convert input orientation to output orientation? I'm interested in mathematics and source code(any software will do) behind these tools.
Big thanks
|
|
mirrorTm=scaleMatrix [-1,1,1]
flipTm=scaleMatrix [1,1,-1]
pivotTm=$box03.transform
mirroredTm=($point01.transform*inverse pivotTm*mirrorTm)*pivotTm
finalTm=flipTm*mirroredTm
$point02.transform=finalTm
This is Max script but you can do the same in Maya using nodes and the method is the same.
mirrorTm is the axis that you want to mirror around.
flipTm is the axis that will be fliped so that you don't end up with a left handed matrix.
pivotTm is the center point that you want to mirror across in the case of rigging a character it would be the world matrix or identity matix.
To calculate the mirroredTm you need to get into the space of the pivot and then multiply it by the mirrorTm then final it in the space of the pivot.
Next you need to remove the inverted scale to get back to a right handed matrix so you multiply the mirroredTm by the flipTm and you have the result.
Xeash
07-15-2009, 10:22 PM
Thanks a lot. Already made it in Maya.
Its seems, I need to research transforms' matrices more)
I'm writing a tool which needed callbacks of mirrorJoint tool for getting mirrored angles very often in a loop, but this makes maya crash. So computing angles directly really solved my problem.
Thanks again
P.S. If you don't mind can you advice some info's source about transformation matrices?
Its better if it is non-"what is it" stuff but something more practical...
Well the most practical source I thing that you can find was done by Borislav Petrov AKA Bobo, Bobo is one of the top Max Script gods and does fantastic DVD's that are sold at http://cg-academy.net. There is a DVD from him there called the Matrix Explained and although it is done in Max it is really just all about vector math and how to use it in 3D. Along the way you might even pick up some Max knowledge that can't hurt either.
Polimeno
07-21-2009, 03:54 AM
flipTm is the axis that will be fliped so that you don't end up with a left handed matrix.
ok Paul,
the scale returns [100,100,100]... but i have a question :
source = $[1]
target = $[2]
TM1 = source.transform
mirrorTM = matrix3 [ -TM1.row1.x , TM1.row1.y, TM1.row1.z ] [ -TM1.row2.x, TM1.row2.y, TM1.row2.z ] [ -TM1.row3.x, TM1.row3.y, TM1.row3.z ] [ -TM1.row4.x, TM1.row4.y, TM1.row4.z ]
target.transform = mirrorTM
the result based on world X_axis in this case, returns [-100,-100,-100] (transform type-in) for scale values.
but what is the REAL problem ?
even if it is the last hierarchy node/object (e.g. an extra point to mirror an entire system or a Maya´s GRP/null in the same siituation) will we end up with problems ?
by the way, what kind of problems are we talking about ? quats/euler/position values etc ?
thanks in advance
If you mirror a group node, just a point helper in Max, you end up with the same problem as objects in a hierarchy inherit their parents matrix, unlink any one of those objects and it will report the same scaling that the part had.
Problems can come in many forms. First off you can't orientationaly align a right and left handed matrix.
(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])!=(matrix3 [-1,0,0] [0,1,0] [0,0,1] [0,0,0])
These two matrix values can't be aligned in any way without un-unmirroring the the x vector in the second matrix.
Problems can occur else where in a complex rig as objects are linked to the mirrored matrix that are not mirrored them selves. Also nodes like skin use the matrix of the bone for calculating vertex positions, this can become messed up when a node is unlinked from a mirrored matrix and linked to a non mirrored matrix.
Games generally never want to have right and left handed matrix values and exporters will often egnor the scale and export without it. This is why people have problems when the build a character rig, realize that it is to small for the game and just scale it and once exported to the game it is still to small.
I can go on and on with issues that I have seen over the years, a lot of it is just scene management, I figure nothing should be mirrored in any scene and if it is then I know there is a problem with it.
CGTalk Moderation
07-21-2009, 02:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.