# Frozen transforms and matrix multiplication..

 12 December 2011 eek Fixer   portfolio Charles Looker Snr Technical Artist Electronic Arts Vancouver, Canada Frozen transforms and matrix multiplication.. 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. __________________ Disclaimer: My opinions are not those of my employer. share quote
 12 December 2011 Robert Bateman Lord of the posts   Robert Bateman Software Engineer United Kingdom Originally Posted by eek: When you freeze an objects transform how are transforms applied to it? They aren't. The transformation is applied to the geometry, and the transform values are zerod. It's not quite as simple as that though, since there are various unpleasant edge cases surrounding instanced transforms & shapes, and negated scale. share quote
 12 December 2011 theflash trying to visualize 'i'   Maulik Kataria Geeky Artist Bergen, Norway When you freeze the transform, in addition to geometry pivots change as well. __________________ [ myRiggingBLOG ] [ myAnimBLOG ] [ myWebsite ] "Life is animation and we are our own animators." -i share quote
 12 December 2011 Robert Bateman Lord of the posts   Robert Bateman Software Engineer United Kingdom Originally Posted by theflash: When you freeze the transform, in addition to geometry pivots change as well. That is simply not true. The only values that change on a transform/joint node are: scale, translate, rotate, and joint orient values. Scale and rotational pivots are entirely unaffected. share quote
 12 December 2011 sciLoop Expert   portfolio Burkhard Rammner bioinformatition med.uni.goettingen/sciloop Hamburg, Germany You should rather not apply the freezeTransform. You loose the object to world transformation data. As Rob stated, when you do that, all values which transform the vertices from its initial object space ( the values in the transform node ) are added to these vertex positions in the shape node and their new true positions are then true worldSpace positions ( in case the transform did not have an additional transform above it ). Its better to simply duplicate the transform and parent it under the new transform. This way, you also get zeroed out transform values for your transform. Last edited by sciLoop : 12 December 2011 at 08:27 PM. share quote
 12 December 2011 theflash trying to visualize 'i'   Maulik Kataria Geeky Artist Bergen, Norway Originally Posted by Robert Bateman: That is simply not true. The only values that change on a transform/joint node are: scale, translate, rotate, and joint orient values. Scale and rotational pivots are entirely unaffected. I see. But then why does freezing transform changes the rotate pivot point in the code below? ``````circle -c 0 0 0 -nr 0 1 0 -sw 360 -r 1 -d 3 -ut 0 -tol 0.01 -s 8 -ch 1; objectMoveCommand; move -r -ls -wd 0 14.283177 0 ; move -r -ls -wd 3.11461 0 0 ; xform -q -rp; // Result: 0 0 0 // FreezeTransformations; makeIdentity -apply true -t 1 -r 1 -s 1 -n 0; xform -q -rp; // Result: 3.11461 14.283177 0 // `````` __________________ [ myRiggingBLOG ] [ myAnimBLOG ] [ myWebsite ] "Life is animation and we are our own animators." -i share quote
 12 December 2011 theflash trying to visualize 'i'   Maulik Kataria Geeky Artist Bergen, Norway Originally Posted by sciLoop: You should rather not apply the freezeTransform. You loose the object to world transformation data. As Rob stated, when you do that, all values which transform the vertices from its initial object space ( the values in the transform node ) are added to these vertex positions in the shape node and their new true positions are then true worldSpace positions ( in case the transform did not have an additional transform above it ). Its better to simply duplicate the transform and parent it under the new transform. This way, you also get zeroed out transform values for your transform. If the transform node does not have any geometric shape as children then you loose the rotation values but translation can still be queried through rotate pivot. For a transform without shape pivot acts like position, just like how joint behaves if you change the pivot location it actually moves the joint. __________________ [ myRiggingBLOG ] [ myAnimBLOG ] [ myWebsite ] "Life is animation and we are our own animators." -i share quote
 12 December 2011 CGTalk Moderation Expert Thread automatically closed This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum. __________________ CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.