Hi,
Could you elaborate on the rotation order bug in the decompose matrix node?
I quickly googled (ie didnt notice anything sepcial on the first two result
pages...)
Because I used to use it a lot before, and never noticed/encountered any
bug. Some luck?
Nicolas


2012/4/10 [email protected] <[email protected]>

> Hey There!
> I m just fixing one of the limitations of our animation exporter
> (~Maya). At the moment animation is recorded fine and keyframe data is
> happily sorted into dictionaries and put back. The problem is
> currently the top node (the character control under which all others
> are kept) was being stored as values from a decomposeMatrix node.
>
> This was fine till someone noticed the XYZ rotation order bug with
> this plugin. I would prefer to record the position of this top node as
> WS Matrix for each frame (heavy I know).
>
> From this we are able to reapply animation easily to other rigs
> regardless where it is in DAG, as the WS matrix is in WS. From this I
> can get the keyframe values on the fly in the scenes themselves.
>
> Now I ve got as far as being able to find the difference in
> Translation between 2 matrices using this code but Rotation is just
> screwing my brain.
>
> Is my method even possible or will I have to use XForm to set the node
> in space then key these values? This will almost certainly take a
> looong time.
>
> Here s the code, get your laughing masks ready !
>
>
> import math
> import maya.cmds as mc
> import maya.OpenMaya as om
>
>
> # returns matrix in ws of an object, to be used at every frame to
> store data
> def get_matrix_transforms(object):
>    matrix = mc.getAttr(object+".worldMatrix")
>    return matrix
>
> def set_trans_to_matrix(source,dest):
>    # set matrix function from source matrix.
>    xform_source = get_matrix_transforms(source)
>    xform_dest = get_matrix_transforms(dest)
>    source_matrix = om.MMatrix()
>    dest_matrix = om.MMatrix()
>    om.MScriptUtil.createMatrixFromList(xform_source, source_matrix)
>    om.MScriptUtil.createMatrixFromList(xform_dest, dest_matrix)
>    #ws_source_quart = ws_source_trans.rotation()
>    # not sure which one to subtract
>    difference_world = source_matrix-dest_matrix
>    difference_world_trans =
> om.MTransformationMatrix(difference_world)
>
>    # Get scale translate and quart of these results
>    diff_trans =
> difference_world_trans.getTranslation(om.MSpace.kWorld)
>
>
>    diff_rot_quart = difference_world_trans.rotation()
>    diff_rot = diff_rot_quart.asEulerRotation()
>    angles = [(math.degrees(angle)) for angle in (diff_rot.x,
> diff_rot.y, diff_rot.z)]
>
>    print "the difference in translation is"
>    print diff_trans.x
>    print diff_trans.y
>    print diff_trans.z
>
>    print "the euler angle is..."
>    print angles
>
>
> set_trans_to_matrix('dest','source1')
>
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to