Skip to content

Maya DomeStereoCamera Rig

Andrew Hazelden edited this page Nov 26, 2016 · 11 revisions

Introduction

The DomeStereoCamera rig is used to create the left and right fulldome camera views for the "DomeAFL_FOV_Stereo" shader in Maya. It works by automatically assigning the mental ray lens shaders to the cameras, sets up the dome preview shape, and allows us to view a wide angle anaglyph preview of the scene in Maya's OpenGL hardware viewport.

The Panels Stereo menu shows the active camera rigs

If you look in the viewport's Panels > Stereo menu you will see the list of active stereo camera rigs available.

Exploring Camera Rigs in Maya

The "DomeAFL_FOV_Stereo" node is designed to work with a custom stereo rig in Maya called the DomeStereoCamera. When Maya starts up, the "userSetup.py" script loads the custom stereo rig file into Maya. Let's explore Maya's Custom Stereo Rig Editor window so we can get an idea about what is going on in a stereo rig.

Switch to the Rendering Menu set. Then open the Stereo > Editors menu and select the Custom Stereo Rig... menu item.

Custom Stereo Rig Menu Item

This will open up a new Custom Stereo Rig Editor window that will let us edit the settings for the active stereo rigs.

There are two components to a stereo rig: The Create Procedure and the Camera Set Callback attributes which are run from inside your camera rig script.

In the DomeStereoCamera rig these attributes are set to:

Create Procedure: domeStereoRig.createRig
Camera Set Callback: domeStereoRig.attachToCameraSet

The values that are specified in the Custom Stereo Rig Editor Create Procedure and the Camera Set Callback fields will be the name of the functions that are run in the the camera rig's python script. For the Domemaster3D shader, the camera rig script that is used is called "domeStereoRig.py".

When a new fulldome stereo rig camera is added to the Maya scene, the function createRig() will be run from inside the "domeStereoRig.py" script file. Here is a snapshot of the outliner after the new rig has been added to the scene:

Outliner View

Choosing a Default Stereo Rig

If you switch to the Rendering menu set, you will notice there is a Domemaster3D menu. Let's take a look at the active stereo rigs and see which script is set to be the default camera rig.

Open the Domemaster3D > Dome Cameras > Choose a Default Stereo Rig menu.

Domemaster3D Stereo Camera Rig Selector

This view lists the active stereo rigs in Maya. A regular copy of Maya comes with a rig called "StereoCamera", and the Domemaster3D shader adds a rig called "DomeStereoCamera".

Note: If you want to use the "DomeAFL_FOV_Stereo" node you need have the item "DomeStereoCamera" enabled in the "Choose a Default Stereo Rig" menu.

If you are working with other (non-fulldome) camera rigs in Maya, you can/should change the active rig in the "Choose a Default Stereo Rig" sub-menu to another rig like the "StereoCamera" rig. When you want to use the "DomeAFL_FOV_Stereo" node again, make sure to re-enable the "DomeStereoCamera" rig item in the Domemaster3D menu's "Choose a Default Stereo Rig" sub-menu.

Where is the DomeStereoCamera Rig located?

The DomeStereoCamera rig script is called "domeStereoRig.py" and it is located in the user account's Maya scripts folder:

Windows Script Path:

C:\Program Files\Domemaster3D\maya\common\scripts\domeStereoRig.py

macOS Script Path:

/Applications/Domemaster3D/maya/common/scripts/domeStereoRig.py

Linux Script Path:

/opt/Domemaster3D/maya/common/scripts/domeStereoRig.py

Stereo Camera Rig Development

The DomeStereoCamera rig will work fine for most users. If you need to customize your own modified rig, the development of the "domeStereoRig.py" rig script was based upon the example file called "stereoCameraDefaultRig.py".

The original file can be located at:

C:\Program Files\Autodesk\Maya2014\Python\Lib\site-packages\maya\app\stereo\stereoCameraDefaultRig.py

The following python code is used in the default Domemaster3D "userSetup.py" script to locate the active stereo camera rigs when Maya starts up:

#Find the name of the stereo camera rig
def findDomeRig():
  import maya.cmds as cmds

  rigs = cmds.stereoRigManager(listRigs=True)
  print ("Stereo Camera rigs:")
  for rig in rigs:
    defs = cmds.stereoRigManager(rigDefinition=rig)
    print 'Rig "'+ rig +'": (language '+defs[0]+') create callback: '+defs[1]
    #Check for
    if (rig == "DomeStereoCamera"):
      return 1
      
  return 0

The following python code is used in the default Domemaster3D "userSetup.py" script to load the custom DomeStereoCamera rig into the Maya Stereo Rig Manager:

#Check if a DomeStereoCamera rig exists in the scene  
def addNewDomeRig():
  import maya.mel as mel
  import maya.cmds as cmds
  import domeStereoRig as domeStereoRig
  
  if (findDomeRig() == 0):
print ("A DomeStereoCamera rig has been added to the stereoRigManager.")
# Register the DomeStereoCamera rig type
# add[rig, language, createProcedure]
# cameraSetFunc=[rig,callback] 
# Add the custom rig
cmds.evalDeferred("cmds.stereoRigManager(add=['DomeStereoCamera', 'Python', 'domeStereoRig.createRig'])")
# Add the custom callback set for Maya 2011+
mayaVersion = getMayaVersionDome()
if (mayaVersion >= 2011):
  cmds.evalDeferred("cmds.stereoRigManager(cameraSetFunc=['DomeStereoCamera','domeStereoRig.attachToCameraSet'] )")

#Make the new rig the default rig
cmds.evalDeferred("cmds.stereoRigManager(defaultRig='DomeStereoCamera')")
  else:
print ("A DomeStereoCamera rig already exists in the stereoRigManager.")
  #else:
   # Maya 2010 or older was detected
   #print ("The Domemaster3D stereo rig feature requires Maya 2011 and newer.")

To use the above code snippet, we had to start by importing the script for our custom stereo rig so Maya knows the name of the callback items. Since the stereo rig script is called "domeStereoRig.py" we used the following python import function:

import domeStereoRig as domeStereoRig

The python code that sets up the Stereo Rig Manager's Create Procedure is on this line:

cmds.stereoRigManager(cameraSetFunc=['DomeStereoCamera','domeStereoRig.attachToCameraSet'] )

And the Camera Set Callback value is set up using the code on this line:

cmds.stereoRigManager(cameraSetFunc=['DomeStereoCamera','domeStereoRig.attachToCameraSet'] )

Since the "userSetup.py" script is running as a startup item the code was wrapped in an cmds.evalDeferred() function so it will be run after the Maya startup phase is complete, the "stereoCamera.mll" plugin has loaded, and Maya is running in "idle mode".

To set our rig named DomeStereoCamera as the default stereo camera rig we use the following code:
cmds.stereoRigManager(defaultRig='DomeStereoCamera')

Other Maya Stereo Rig Manager Resources

To learn more about the Maya Stereo Rig Manager, check out the Maya online documentation.

Maya Stereo Rig Manager Docs

Clone this wiki locally