Overview of custom transforms


The Maya API provides a proxy class that allows for the creation and manipulation of custom transform nodes. Custom transforms are an advanced Maya API topic. Standard transform nodes in Maya are very important since all shape and geometry nodes must have transform nodes above them in the Directed Acyclic Graph (DAG). However, custom transforms give you a finer level of control over transform nodes in Maya.

Maya transform nodes (including custom transforms) derive from the Maya DAG node and is used to group and transform other DAG nodes. A transform node may have any number of DAG nodes below it. If a DAG node is not a transform node, then it must be the child of a transform node.

Transform nodes, like all other Maya nodes, contain input and output attributes. The most important input attributes are translate, rotate and scale and the transformation matrix is the most important output attribute.

To implement a custom transform, you should have a good understanding of the following classes:

To implement a custom transform, one must derive a new class from the MPxTransform API class. The MPxTransform class works in conjunction with the MPxTransformationMatrix class. It is possible to use a derived version of MPxTransform and use the supplied MPxTransformationMatrix to implement a new custom transform. Both the MPxTransform and MPxTransformationMatrix classes contain virtual methods that are overridden to provide new transform functionality. Note that the virtual methods provided in both of these classes provide reasonable default behavior for the standard Maya transform.

When viewing both of these classes together, it is important to note the parallels that exist in the available methods. For example, there is MPxTransform::scaleTo() and MPxTransformationMatrix::scaleTo(). There is a distinction between a DG node and a transformation matrix in the division of these classes. The node method MPxTransform::scaleTo() calls MPxTransformationMatrix::scaleTo() to perform the operation and returns the result. The MPxTransform::scaleTo() takes the result and stores it on the node. Adding new attributes to a custom transform requires a similar approach.