Errr.  I hope I'm replying to my own email correctly.  If not I apologize.   It turns out P.E.B.K.A.C.  Sadly as I wrote my previous email I continued to say to myself, "this must be column major and my code isn't handling that right".  I guess between transposing() to and from maya, as well as my options for asList(),  different order of operations, and on top of re-familiarizing myself with Maya I just did it wrong...a lot of different ways.  I think one time I forgot to transpose back, another time I forgot to switch my order of operation, and who knows the 12+ other times :)

def cgkit_matrix( xform_list ):
    takes a 16 element list (assumed to be the result of a xform query) and returns a cgkit.cgtypes.mat4 in proper form
    matrix = cgkit.cgtypes.mat4( xform_list )
    matrix = matrix.transpose( )

    return matrix

def maya_xform_list( matrix ):
    converts a cgkit.cgtypes.mat4 into a row list that can be used with mays.cmds.xform.
    The original matrix is left unaltered.
    #create a copy of the original matrix
    matrix = cgkit.cgtypes.mat4( matrix )
    matrix = matrix.transpose( )

    return matrix.toList( rowmajor = True )

Cool lib b.t.w.

On Fri, Apr 1, 2011 at 4:10 PM, Nathaniel Albright <> wrote:
Hello to whoever may see this (if I'm even doing this right.  this is my first time using a mailing list),

I'm attempting to use cgkit with Maya for some app specific transform manipulation as well as for animation exporting/importing. However, after a number of hours (more than I'd care to admit) I've only had limit success.  Most of this confusion has come from the way cgkit and Maya represent their matrices.  Since any queries in maya for an object's xform result in a list of elements in row order, and cgkit requests the data in row order I wouldn't expect the issues I'm currently having.

For example, if I pass cgkit the maya_list and then immediately call decompose() translation is returned.  Initially this left me to believe cgkit must be columnMajor ( especially since the toList() returns the results as columns by default ).  As such I did a transpose() on the matrix before the decompose() and as expected I then had my proper transform values.

Unfortunately I've since determined that this isn't the proper answer to my issue.  While the transpose worked well for getting what I need out of decompose, it created incorrect results for manipulating the data and then setting the results back into Maya.   I've only successfully been able to manipulate my cgkit objects and plot the data back into Maya when I DON'T do any transpose....I'm using toList( rowmajor = True ).  However as mentioned then the decompose() function isn't correct.

I could ramble with all the ways I've been confused, however I think I just need some clarification.   From what I can gather in the document the translation value is embedded as the forth element of the three axises.  for example:
a_list = [  v1.x, v1.y, v1.z, t.x,    v2.x, v2.y, v2.z, t.y,    v3.x, v3.y, v3.z, t.z,    v4.x, v4.y, v4.z, t.w,   ]
is this correct?

I was expecting it to be:
b_list = [  v1.x, v1.y, v1.z, v1.w,    v2.x, v2.y, v2.z, v2.w,    v3.x, v3.y, v3.z, v3.w,    t.x, t.y, t.z, t.w, ]
as such, I wrote a transpose_translation()  which as the name suggests swaps out the last row and column so that a mat4 initialized with a b_list results in the expected a_list form.  Unfortunately with this method I'm back to square one, where the decompose works, but any math operations result in correct answers.  It seems as if when the transform is in the last row everything math wise works, but cgkit is expecting it in the last column...where my math operations don't work.

Does anyone have any tips on what I'm doing wrong or gotten things to work between Maya and the cgkit?

Thanks in advance,