Translator of a custom node

First, we will create a very basic Maya Plugin that defines a custom node:



And compile it. Assuming windows, open a Visual Studio command prompt and execute the following commands:


cl /c myPlugin.cpp /EHsc /MD /DNT_PLUGIN /DREQUIRE_IOSTREAM /I%MAYA_PATH%\include

link /dll myPlugin.obj /LIBPATH:%MAYA_PATH%\lib OpenGl32.lib glu32.lib Foundation.lib OpenMaya.lib OpenMayaRender.lib OpenMayaUI.lib OpenMayaAnim.lib OpenMayaFX.lib /export:initializePlugin /export:uninitializePlugin /OUT:myPlugin.mll


Load the generated myPlugin.mll in Maya, and you will be ready to create mySimpleNode node instances. Type the following in the Script Editor, in MEL:
createNode mySimpleNode


A translator for this node will be very easy, but this time, we will inherit the translator from a CDagTranslator instead from a CNodeTranslator as it will allow us to use methods specic for DAG nodes, like exporting the transformation matrix.




And we will define the methods to export an Arnold sphere, get the matrix from the node, and export the node attribute to the sphere radius.




And we load the extension with:




A last thing we may want to do is to have that custom Maya node in the extension, so the plugin is not required to be loaded.
First, we simplify our custom Maya node plugin removing the initializePlugin and uninitializePlugin methods:



We do not need to modify the translator, but in the initializeExtension method we make these changes:



Now when the extension is loaded with MtoA, our custom node and its translator will be correctly registered.

  • No labels