Create a custom rig
 
 
 

There are two ways you can add a custom rig camera to a scene.

Method 1

Writing a MEL or Python script procedure

  1. Create your custom rig by writing a MEL/Python Script.
    Tip

    It is best to create a rig using Python scripting.

  2. Describe the hierarchy of your camera rig and define the relationship of the your center, left and right cameras.

    All your rig nodes must be parented under one camera, directly or through any number of transforms. This camera serves as the root of your rig, and as the center camera. It is not possible to use instancing inside the rig structure.

    The creation procedure should take no arguments, and must return an array of three strings. The first is the root node of the rig, and the second and third are the left and right cameras, respectively.

See StereoRig Manager in the Commands documentation for examples: stereoRigManager

Registering your custom rig

  1. Select Stereo > Editors > Custom Stereo Rig

    The Custom Stereo Rig Editor window appears.

  2. In the Register a new rig section, select a name for your custom rig. Select the language that you used to create your custom rig, either Python or MEL. Enter the Python or MEL procedure that you want to use to create your custom rig, for example:

    maya.app.stereo.stereoCameraComplexRig.createRig.

  3. In the Camera Set Callback section, assign a callback if you are using a multi-camera rig.

    Each custom rig can assign a callback that is called whenever that rig is attached to a camera set. A camera set holds onto the layers of a multi-camera rig, and contains slots that hold information pertinent to each layer. After a rig has been created and assigned to a layer of the multi-rig, this callback is executed to let the custom rig know that this has happened and allow for any custom actions to occur. This occurs for each layer in the multi-rig.

    After all mult-rigs have been created, one final callback is sent to the same method to indicate that Maya has finished creating the multi-rig. The syntax of the callback contains the following flags:

    Per-layer: <nameOfCallback> -cameraSet <multiRigName> <rigNodeName>

    Final callback: <nameOfCallbak> -cameraSet <multiRigName> -allDone 1

    For more information about multi-camera rigs, see Create a multi-camera rig and Multi-Camera Rig Tool.

  4. Click Add New Rig.

    You can now access your custom rig in by selecting Panels > Stereo > New Stereo Camera (<Your custom rig>).

    Note

    You can also register your custom rig by using the stereoRigManager command. Refer to the stereoRigManager commands documentation for examples on how to register a custom rig, query the default rig, or delete a rig using this command.

Source code examples

Maya ships with a default stereo rig enabled. The source code is available in the python module: …\Python\Lib\site-packages\maya\app\stereo. Within this directory, you can also find the following code examples:

…\scripts\others\stereoCameraSimpleRig.mel creates the simplest rig, where a camera is used for both the right and center eye. A left camera is parented underneath.

These scripts are used in the stereoRigManager example.

Method 2

Making an existing rig Maya compliant

If you have an existing rig, or if you need to create a rig outside of Maya, you can make an existing rig compliant with Maya’s requirements. However, all cameras must be parented under a common transform, called the rig root.

Call this Python code:

import maya.cmds as cmds
from maya.app.stereo import stereoCameraRig
# Make sure the stereo plug-in is loaded
cmds.loadPlugin("stereoCamera", quiet=True)
stereoCameraRig.makeStereoCameraRig(rigRoot, rigTypeName, leftCam, rightCam)

where rigRoot, leftCam and rightCam are the names of the root transform, and the left and right camera pair. rigNameType is a user defined string used to identify the rig type.

Change the default left and right camera pair

If you have a rig with multiple left and right camera pairs, you can change the default left and right pair, used for interactive display.

Call this Python code:

import maya.cmds as cmds
from maya.app.stereo import stereoCameraRig
# Make sure the stereo plug-in is loaded
cmds.loadPlugin("stereoCamera", quiet=True)
stereoCameraRig.setStereoPair(rigRoot, leftCam, rightCam)