berry3D
12-01-2011, 07: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()
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 ))
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 ))
