def getObjectWorldOrientation(node): if(node is None): return None jointRot = getJointWorldOrientation(node) if isJoint(node) else om.MEulerRotation() rot = cmds.xform(node, query=True, translation=False, rotation=True, absolute=True) rotOrder = mayaMathUtil.nodeRotOrderToEulerRotOrder(cmds.xform(node, query=True, rotateOrder=True, absolute=True)) objRot = om.MEulerRotation(math.radians(rot[0]), math.radians(rot[1]), math.radians(rot[2]), rotOrder) return objRot * jointRot
def getJointWorldOrientation(joint): if(joint is None): return None #small hack to create a duplicate joint so we don't mess with the original to get its world orientation #TODO: turns out I might not need to do this? Since world orientation is object world transformed by joint orientation. Investigate later... dupJoint = cmds.duplicate(joint, upstreamNodes=False, inputConnections=False, parentOnly=True) if(getObjectParent(dupJoint) is not None): cmds.parent(dupJoint, world=True) jointRot = cmds.joint(dupJoint, query=True, position=False, orientation=True) jointRotOrder = mayaMathUtil.nodeRotOrderToEulerRotOrder(cmds.joint(dupJoint, query=True, rotationOrder=True, absolute=True)) cmds.delete(dupJoint) return om.MEulerRotation(math.radians(jointRot[0]), math.radians(jointRot[1]), math.radians(jointRot[2]), jointRotOrder)