View Full Version : Joint rotation and orientation

12 December 2011, 08:59 AM
Hi. Help me please.

I have cube and joint. Joint have orientation (Ox, Oy, Oz) i get it use MFnIkJoint::getOrientation(). And i have er = MEulerRotation(x,y,z).
If i will rotate cube and joint on "er" (er=MEulerRotation(x,y,z)), joint will have shift in rotation, and orientation of cube and of a joint will not match.
What i need to do with "er", to fix this mismatch.

This small example. Create cube and joint, set any joint orientation to joint. Set any rotation to cube. Then select cube and joint and run script:

import maya.OpenMaya as om
import maya.OpenMayaAnim as oma

list = []
slist = om.MSelectionList()

CubedPath = om.MDagPath()
JntdPath = om.MDagPath()

slist.getDagPath( 0, CubedPath )
slist.getDagPath( 1, JntdPath )

#cube and joint MFnTransform
cubeTr = om.MFnTransform(CubedPath)
jntTr = om.MFnTransform(JntdPath)

# get cube Euler rotation
cubeER = om.MEulerRotation()

# get joint orientation as Euler rotation
jntFn = oma.MFnIkJoint(JntdPath)
jntOrientER = om.MEulerRotation()

# what need to do with cubeER for rotate joint as cube
jntTr.setRotation( ??? )

Thanks ))

12 December 2011, 06:21 PM
Kind of a guess, but this seems to work:

jntTr.setRotation( cubeER*jntOrientER.inverse() )


12 December 2011, 05:54 AM
Stev, thank you very, very mutch.
Works fine!! You very help me!
Thanks )

CGTalk Moderation
12 December 2011, 05:54 AM
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.