eek

12-10-2011, 06:19 PM

When you freeze an objects transform how are transforms applied to it?

I have two objects 'a' and 'b' at positionally [0,10,0], and I freeze the transform of 'b' back to [0,0,0] essentially freezing its world offset. To get 'b's transform relative to 'a' i'd first get the xform of the two: (using python btw)

import maya.cmds as cmds

import maya.OpenMaya as OpenMaya

mUtil = OpenMaya.MScriptUtil()

# first get the world transforms

p0 = cmds.xform('a', q=True, ws=True, m=True)

p1 = cmds.xform('b', q=True, ws=True, m=True)

# create empty matrices

m0 = OpenMaya.MMatrix()

m1 = OpenMaya.MMatrix()

# create the pointers

mUtil.createMatrixFromList(p0, m0)

mUtil.createMatrixFromList(p1, m1)

# get the inverse

m2 = (m1 * m0.inverse())

# multiply the inverse to get the original position

m3 = (m2 * m0)

Now applying this in a form of a matrix list using an xform does'nt seem to work:

mList = [

m3(0,0), m3(0,1), m3(0,2), m3(0,3),

m3(1,0), m3(1,1), m3(1,2), m3(1,3),

m3(2,0), m3(2,1), m3(2,2), m3(2,3),

m3(3,0), m3(3,1), m3(3,2), m3(3,3)

]

cmds.xform('b', ws=True, m=mList)

Where as applying it via transform property seems to work:

cmds.xform('b', ws=True, t=[m3(3,0), m3(3,1), m3(3,2)]

I could be wrong as i'm just starting to get the hang of the internal math of frozen transforms.

I have two objects 'a' and 'b' at positionally [0,10,0], and I freeze the transform of 'b' back to [0,0,0] essentially freezing its world offset. To get 'b's transform relative to 'a' i'd first get the xform of the two: (using python btw)

import maya.cmds as cmds

import maya.OpenMaya as OpenMaya

mUtil = OpenMaya.MScriptUtil()

# first get the world transforms

p0 = cmds.xform('a', q=True, ws=True, m=True)

p1 = cmds.xform('b', q=True, ws=True, m=True)

# create empty matrices

m0 = OpenMaya.MMatrix()

m1 = OpenMaya.MMatrix()

# create the pointers

mUtil.createMatrixFromList(p0, m0)

mUtil.createMatrixFromList(p1, m1)

# get the inverse

m2 = (m1 * m0.inverse())

# multiply the inverse to get the original position

m3 = (m2 * m0)

Now applying this in a form of a matrix list using an xform does'nt seem to work:

mList = [

m3(0,0), m3(0,1), m3(0,2), m3(0,3),

m3(1,0), m3(1,1), m3(1,2), m3(1,3),

m3(2,0), m3(2,1), m3(2,2), m3(2,3),

m3(3,0), m3(3,1), m3(3,2), m3(3,3)

]

cmds.xform('b', ws=True, m=mList)

Where as applying it via transform property seems to work:

cmds.xform('b', ws=True, t=[m3(3,0), m3(3,1), m3(3,2)]

I could be wrong as i'm just starting to get the hang of the internal math of frozen transforms.