The ‘world node’ solution is probably the most common thing I’ve seen too. The spatial transformation part is easy, it’s just a matrix multiply – but if you have to worry about things like tangent space windings or animated hierarchies it gets irritating really quickly because of the negative scale. So, people default to the cheapo ‘move me into the world’ solution instead.
These two funcs give you max-to-maya and maya-to-max matrices as API matrices, if it helps:
def APIMatrix ( valList ):
mat = OpenMaya.MMatrix()
OpenMaya.MScriptUtil.createMatrixFromList( valList, mat )
return mat
def maya_to_max( scale=1 ):
'''
Returns the maya to max transform an OpenMaya.mMatrix (with the supplied scale factor to handle unit conversion)
'''
x = [1, 0, 0, 0]
y = [0, 0, 1, 0]
z = [0, -1, 0, 0]
w = [0, 0, 0, 0]
m2m = APIMatrix( x + y + z + w )
m2m *= scale
return m2m
def max_to_maya( scale=1 ):
'''
Returns the maya to max transform an OpenMaya.mMatrix (with the supplied scale factor to handle unit conversion)
'''
x = [ 1.0, 0.0, 0.0, 0.0 ]
y = [ 0.0, 0.0, -1.0, 0.0 ]
z = [ 0.0, 1.0, 0.0, 0.0 ]
w = [ 0.0, 0.0, 0.0, 1.0 ]
m2m = APIMatrix( x + y + z + w )
m2m *= scale
return m2m
If you don’t care about hierarchy, tangent spaces, etc. you can just iterate over the worldspace vertices and vert normals of your mesh, turning them into MPoints and multiplying them agains the matrix for the direction you’re going. Worldspace matrices can be done the same way. Other stuff, though, like hierarchies, tanget frames, etc… not so easy.