You can use either the Oculus Rift or OpenVR HMD display mode with the Oculus Rift. For Oculus Rift Mode, see the information below.
The information below covers only the Oculus Rift display mode. For OpenVR, see Python for HTC Vive.
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.
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:
setOculusRiftTrackingOriginType(1).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)
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.
To set the tracking system origin at eye level (Seated mode), the tracking origin type must be set to 0 in VRED. Use setOculusRiftTrackingOriginType(0).
This resets the tracking origin to the current HMD pose (position and yaw orientation).
Use resetOculusRiftOrientation() to reset the view, while wearing the headset in your preferred position.
To set the tracking system origin at floor height (Standing mode/Room Scale), use setOculusRiftTrackingOriginType(1).
This resets the tracking origin to the position on the floor below the HMD and changes the yaw orientation component of the tracking origin to the current yaw of the HMD.
In Standing mode, you can also use resetOculusRiftOrientation() to recalibrate the tracking origin.
For information on Tracking values, see the Oculus Developer documentation.
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.
In Oculus Rift mode, you can adjust the tracking values using setOculusRiftTrackingOrigin. This works the same as the equivalent OpenVR function.
For setting floor level in OpenVR mode, see How to Set Floor Level.
In OpenVR mode, since the following information is the same for the HTC Vive, see the links below:
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.