-
Notifications
You must be signed in to change notification settings - Fork 43
Maya mOculus Compatibility
The VR-Plugin / mOculus for Maya plugin by Dominik Capodieci is a popular tool for exploring your Maya scenes in real-time stereo 3D on an Oculus Rift head mounted display.
This wiki page will explain how to use the mOculus plugin at the same time as the Domemaster3D lens shaders are active in Maya. The key to using the mOculus for Maya plugin is that the default stereo rig in Maya has to be set to "StereoCamera" when the Oculus Rift Viewport window is active.
Typically when the Domemaster3D shaders are installed, the stereo camera rig is set to use either the LatLongStereoCamera or DomemasterStereoCamera rig by the userSetup.py script. These Domemaster3D custom stereo camera rig files are used whenever a new panoramic 360° camera is added to the scene and they set up the mental ray / Vray / Arnold based panoramic lens shaders automatically when a new stereo camera is added to the scene.
You can check what stereo rig is active in Maya by switching to the rendering menu set, and opening up the Domemaster3D > Dome Cameras > Choose a Default Stereo Rig menu. The active stereo rig has the filled circular radio button active next to its name.
If you want to use mOculus for Maya, then you need to set the default stereo rig to StereoCamera.
You can do this by selecting the Domemaster3D > Dome Cameras > Choose a Default Stereo Rig > StereoCamera menu item. Unfortunately, this technique of using the "Choose a Default Stereo Rig" menu command is not persistent between each restart of Maya.
One way to get mOculus to select the default stereo rig each time it is run is to edit the mOculus shelf tool. We can add two lines of Python code to take care of the default stereo camera rig switching automatically.
Select the mOculus shelf tab. Then right click on the mOculus shelf tool item that has a the "eye" icon. In the popup menu select the Edit item to open up the Shelf Editor window.
In the Shelf Editor window, the mOculus tool is normally started using the following Python code snippet:
import mOculusRecordTool
reload(mOculusRecordTool)
mOculusRecordTool.UI()
We need to edit this mOculus code by adding the python command for changing the stereo camera rig to the top. Paste the following code into the Shelf Editor window and then close the Shelf Editor to save the changes:
import maya.cmds as cmds
cmds.evalDeferred("cmds.stereoRigManager(defaultRig='StereoCamera')")
import mOculusRecordTool
reload(mOculusRecordTool)
mOculusRecordTool.UI()
Now the mOculus for Maya plugin is ready to be used along side of the Domemaster3D shaders.
The Start mOculus button is typically used to open a new Oculus Rift Viewport window and to enable the real-time head tracking:
If you don't switch the default stereo camera rig to use the StereoCamera before running the mOculus tool, you will see an error message like this appear in the Script Editor window:
# Error: setAttr: The attribute 'DomeStereoCameraHCenterCamShape.zeroParallax' is locked or connected and cannot be modified.
# Traceback (most recent call last):
# File "C:\Users\Andrew\Documents\maya\2015-x64\scripts\mOculusRecordTool.py", line 48, in runOculus
# self.scenePrep.createOccCamera()
# File "C:\Users\Andrew\Documents\maya\2015-x64\scripts\mOculusRecordTool.py", line 90, in createOccCamera
# cmds.setAttr(self.ChosenCameraShape+key, value)
# RuntimeError: setAttr: The attribute 'DomeStereoCameraHCenterCamShape.zeroParallax' is locked or connected and cannot be modified. #
Once you switch the default stereo camera rig to StereoCamera this error goes away and mOculus will work along side of the Domemaster3D shaders.