PDA

View Full Version : Joint rotation and orientation

 berry3D12-01-2011, 07:59 AMHi. 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() om.MGlobal.getActiveSelectionList(slist) slist.getSelectionStrings(list) 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() cubeTr.getRotation(cubeER) # get joint orientation as Euler rotation jntFn = oma.MFnIkJoint(JntdPath) jntOrientER = om.MEulerRotation() jntFn.getOrientation(jntOrientER) # what need to do with cubeER for rotate joint as cube jntTr.setRotation( ??? ) Thanks ))
_stev_
12-01-2011, 05:21 PM
Kind of a guess, but this seems to work:

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

Stev

berry3D
12-06-2011, 04:54 AM
Stev, thank you very, very mutch.
Works fine!! You very help me!
Thanks )

CGTalk Moderation
12-06-2011, 04: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.