Porting Extensions to MtoA 1.4.0

In MtoA 1.4.0 (not released yet)  the amount of files has decreased significantly, and only contains what is necessary to build extensions. Files like CMayaScene, CArnoldSession, CRenderSession are no longer part of the API. CSessionOptions is still present, and contains global informations about the scene. Many internal methods have also been removed or modified from Node Translator’s public API. Please contact us at support@solidangle.com in case of problems with already existing extensions.

Here are the most important changes to port an extension to MtoA 1.4.0 :

  • void Export(AtNode*)  : there used to be 2 functions Export() and Update() but most translators didn’t do any difference between both. Now only Export is needed. If some changes are only meant to be done at first export and not the following IPR updates, then one can invoke IsExported() that returns true once a translator has been exported for the first time.

  • void ExportMotion(AtNode *)  : there used to be ExportMotion() and UpdateMotion(), now only remains ExportMotion. If some changes are only meant to be done at first export and not the following IPR updates, then one can invoke  IsExported() to determine that.

The argument “step” has disappeared as it is a global option that used to be transmitted  over lots of different functions. At any time one can get the current step by calling GetMotionStep(). The total amount of motion steps can be get by GetNumMotionSteps().

In other words

ExportMotion(node, step);

can be exactly replaced by


int step = GetMotionStep();

The argument step has also disappeared from ExportMatrix(AtNode *node, int step)

now becoming ExportMatrix(AtNode *node)

  • Important changes in Motion Blur : The order of motion steps export has changed, since MtoA 1.4.0 will always export the current frame first. As a consequence, when arrays are allocated during Export() for animated data, they shouldn’t be filled with the index 0 but with GetMotionStep instead.

    For example


AtArray *array = AiArrayAllocate(“my_animated_data”, GetNumMotionSteps());

AiArraySetFlt(array, 0, 1.f);

Should be replaced by


AtArray *array = AiArrayAllocate(“my_animated_data”, GetNumMotionSteps());

AiArraySetFlt(array, GetMotionStep(), 1.f);

Tests about step > 0 to know if we’re exporting the current frame or motion steps is no longer valid and should be replaced by calls to the function IsExportingMotion()

  • When a connected node has to be exported, the function ExportNode has been replaced by ExportConnectedNode(const MPlug &outputPlug)

  • A word about AddArnoldNode : While it already existed, some MtoA extensions were not using it. In order to keep track of the nodes being generated, make sure they’ll deleted properly, etc… one should always use this function instead of creating AiNode() manually.

  • RequiresShaderExport() . Several shape translators did the following test before exporting shaders :

if (( CMayaScene::GetRenderSession()->RenderOptions()->outputAssMask() & AI_NODE_SHADER) ||

CMayaScene::GetRenderSession()->RenderOptions()->forceTranslateShadingEngines() )

Now that CMayaScene and CRenderSession are no longer in the public API, this can now be replaced by

If (RequiresShaderExport())

  • ManageUpdateCallback has been renamed RegisterUpdateCallback

Some new virtual methods have been added, for example :

  • virtual void Init() 

    Called at node initialization (don’t forget to invoke parent function)

  • To customize what happens during IPR updates :

    virtual NodeChanged(MObject &object, MPlug &plug)

Is called whenever an attribute “dirtiness” signal is sent by maya for a given plug.

You can use it to behave differently based on the attribute that is being changed.

If you don’t call the parent function, no update will occur. You can also set different update modes by calling SetUpdateMode().



  • No labels