![]()
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,rotateandscaleand the transformationmatrixis the most important output attribute.To implement a custom transform, you should have a good understanding of the following classes:
MFnTransformandMTransformationMatrixMMatrixMPxNodeand how it operates in the Dependency Graph (DG)To implement a custom transform, one must derive a new class from the
MPxTransformAPI class. TheMPxTransformclass works in conjunction with theMPxTransformationMatrixclass. It is possible to use a derived version ofMPxTransformand use the suppliedMPxTransformationMatrixto implement a new custom transform. Both theMPxTransformandMPxTransformationMatrixclasses 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()andMPxTransformationMatrix::scaleTo(). There is a distinction between a DG node and a transformation matrix in the division of these classes. The node methodMPxTransform::scaleTo()callsMPxTransformationMatrix::scaleTo()to perform the operation and returns the result. TheMPxTransform::scaleTo()takes the result and stores it on the node. Adding new attributes to a custom transform requires a similar approach.