Transform node matrix attributes


What is the exact difference between worldMatrix and Matrix attributes? What about xformMatrix?

If the final matrix is the matrix attribute then what does the worldMatrix do?

Thanks for your patience :slight_smile:

I think you have that backwards: matrix is the local transformation and worldmatrix is the concatenated one.

local? does is mean parentMatrix? then what about parentMatrix?

local means relative to its direct parent.
world means relative to world (aka relative to the sum of every parents).

well, there’s no matrix named “local” in the list of attrs. if by local we mean parentMatrix, then what would be the difference between matrix and parentMatrix attrs?

The matrix “Matrix” is the local one

what is “parentMatrix”?

I guess all you need is in the node documentation:

  • matrix: Local transformation matrix for the dagNode.
  • worldMatrix: The worldMatrix instanced attribute is the 4x4 transformation matrix that transforms the object to world-space. There is a world-space matrix for each unique path to the object. Eg. ‘ball.worldMatrix[0]’ identifies the world-space transformation matrix for the first instance of the object ‘ball’. Each world-space transformation matrix is the result of post multiplying the ‘matrix’ attribute by corresponding ‘parentMatrix’ instanced attribute (i.e. worldMatrix[i] == matrix x parentMatrix[i]). Thus, the worldMatrix is the concatenation of the ‘matrix’ attribute of all the dagNodes along the path from the node up to the root of the dag hierarchy.
  • parentMatrix: The parentMatrix instanced attribute represents the world-space transformation matrix for the parents of this dagNode. If the dagNode is a transform node and its inheritTransform attribute is false, then the parentMatrix is identity.

I went over it before creating the topic but somehow i get it better now. thanks

I’ll ask my question here. How to set matrix attributes e.g worldInverseMatrix. In pymel there is a handy command object.setMatrix(matrix) . I understand that this is wrapped cmds.xform(). Is there a way to set this attributes using general rule?

cmds.setAttr("object.attribute", value)

If its a complex attribute you’ll need to specify type. In PyMel:

pymel.core.general.setAttr(attr, *args, **kwargs)

1 Like

The matrix attributes on transform nodes are actually “output” attributes. They get set by the node essentially “computing” a combination of their translates/rotates/scales (and pivot points, jointOrients, and whatever else Im not thinking of). You cant “set” those attributes directly the same way you can “set” a translate or rotate value.

1 Like

Thanks for explanation.

There’s an implementation of get/set world or local positions in which just uses cmds.xform with the ws flag to set transforms in world space rather than (the default) parent space. It’s not “setting attributes” but it does make it easy to pretend you’re setting attrbutes, it’s similar to the way PyMel does it under the hood