Python for Oculus Rift (Deprecated)

Get Python functions specific to use of the Oculus Rift with VRED

You can use either the Oculus Rift or OpenVR HMD display mode with the Oculus Rift. For Oculus Rift Mode, see the information below.

Oculus Rift Mode

The information below covers only the Oculus Rift display mode. For OpenVR, see Python for HTC Vive.

Standing Mode

If you are using the Oculus Rift HMD with the OpenVR HMD display mode, Standing mode is the default, so it won't need to be enabled. However, if you selected the Oculus Rift display mode, it is NOT the default, so you will need to enable Standing mode.

How to Enable Standing Mode in Oculus Rift Mode (Oculus Rift's Floor Level)

When the Oculus Rift is activated, it starts up with you in Seated mode. To enable Standing mode, which is recommended for room-scale scenarios and when the user stands, do the following:

  1. Ensure Oculus Rift mode is activated (View > Display > Oculus Rift).
  2. In the menu bar, select View > Terminal, then paste this Python function setOculusRiftTrackingOriginType(1).
  3. Put the headset back on, stand, and notice how the viewpoint has changed.
  4. Activate a camera viewpoint that puts the camera on the floor of the scene at a location where you want to be.

    With Python, activate a viewpoint with jumpViewPoint('Floor'), if your viewpoint is named Floor.

    Alternatively, directly set the transformation of the active camera with setFromAtUp. The default values for from, at, and up can be set like this: setFromAtUp(-1, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0)

Tracking Origin Type in Oculus Rift Mode

The default tracking type for the Oculus Rift is Seated mode, which is eye level. In Seated mode, the VRED camera should be positioned where the head of the user should be in the VR scene. This can be changed to Room Scale with a Python function.

For information on Tracking values, see the Oculus Developer documentation.

How to Move in the Scene or Set Position

To move to a desired position in the scene, we recommend setting the active camera translation, see Camera Transformation. Alternatively, use the Python function setOculusRiftTrackingOrigin(...).

When changing the camera translation, leave the tracking origin at (0, 0, 0). This makes it easier to setup and no conversion of values is needed. You can do this through the UI, with Python, or with viewpoints. The preferred viewing direction (yaw) can also be defined this way.

How to Set Floor Level in Oculus Rift Mode

In Oculus Rift mode, you can adjust the tracking values using setOculusRiftTrackingOrigin. This works the same as the equivalent OpenVR function.

Note:

For setting floor level in OpenVR mode, see How to Set Floor Level.

Note:

In OpenVR mode, since the following information is the same for the HTC Vive, see the links below:

Shortcuts for Activating Oculus Rift Mode and a Viewpoint

Paste the following Python function into the Terminal to create a shortcut that will activate Oculus Rift and set the viewpoint.

def activateOculus():

    setDisplayMode(VR_DISPLAY_OCULUS_RIFT)

    jumpViewPoint('VR_initial_view')



keyA = vrKey(Key_A)

keyA.connect(activateOculus)

Now, whenever you press the A key, it will activate Oculus mode and set the viewpoint.