The steamvr module adds support for the SteamVR HMDs and input devices (e.g. HTC Vive). The following sample code will setup the main window to render to the SteamVR HMD and link the HMD sensor to the main viewpoint.
A full sample script can be found at \examples\devices\steamvrExample.py
In order to use the steamvr module you must first install and run SteamVR through the Steam application. Once SteamVR is installed, it allows you to calibrate the system and verify all devices are connected and tracked.
The steamvr.HMD class provides an interface for setting up the SteamVR HMD within Vizard and applying it to a window for rendering. The steamvr.HMD class constructor accepts the following optional keyword arguments:
Argument |
Description |
window=viz.MainWindow |
The window to apply the HMD render settings to. |
The steamvr.HMD object contains the following methods:
Method |
Description |
<hmd>.getSensor() |
Get the position/orientation sensor object associated with the HMD. |
<hmd>.setIPD(ipd) |
Set the IPD (interpupilary distance) of the HMD. |
<hmd>.getIPD() |
Get the IPD of the HMD. |
<hmd>.setHiddenAreaMeshVisible(mode) | Set the visibility of the hidden area mesh. The hidden area mesh is used to mask out portions of the screen that won't be visible to the user in the HMD due to distortion correction. It can help increase performance in certain cases. It is visible by default. |
<hmd>.getHiddenAreaMeshVisible() | Get the visibility of the hidden area mesh. |
<hmd>.setMonoMirror(mode) | Set whether window mirror is in mono. mode can be True, False, or viz.TOGGLE. |
<hmd>.getMonoMirror() | Get whether window mirror is in mono. |
<hmd>.remove() |
Remove the HMD object and resources. |
A list of all available SteamVR controller objects can be accessed using the steamvr.getControllerList() command. Controller objects support the standard extension sensor interface for providing position and button values. They also provide the following methods to access additional data:
Method |
Description |
<controller>.getTrigger() |
Get the trigger button value, which ranges from 0 to 1. |
<controller>.getTrackpad() | Get the [x,y] touch position on the trackpad. Values range from -1 to 1. |
<controller>.getThumbstick() | Get the [x,y] position of the thumbstick for Windows Mixed Reality controllers. Values range from -1 to 1. |
<controller>.getGrip() | Get the grip button value for HP Reverb G2 controllers. Value ranges from 0 to 1. |
<controller>.setVibration(duration, amplitude=1) |
Set the vibration on the controller for the specified duration (seconds). The optional amplitude parameter controls the strength of the vibration (0-1). If duration or amplitude are less than or equal to 0, then the vibration will be disabled. |
<controller>.addModel() | Create a model representation of the controller. The returned node object is not linked to the controller position/orientation. |
The controllers support the following button IDs:
Button ID |
steamvr.BUTTON_MENU |
steamvr.BUTTON_GRIP |
steamvr.BUTTON_TRIGGER |
steamvr.BUTTON_TRACKPAD |
steamvr.BUTTON_TRACKPAD_TOUCH |
steamvr.BUTTON_COSMOS_BUMPER |
steamvr.BUTTON_COSMOS_A steamvr.BUTTON_COSMOS_X |
steamvr.BUTTON_COSMOS_B steamvr.BUTTON_COSMOS_Y |
steamvr.BUTTON_REVERB_A steamvr.BUTTON_REVERB_X |
steamvr.BUTTON_REVERB_B steamvr.BUTTON_REVERB_Y |
steamvr.BUTTON_REVERB_THUMBSTICK |
The steamvr module also supports generic SteamVR tracker objects. A list of all available tracker objects can be accessed using the steamvr.getTrackerList() command. Tracker objects support the standard extension sensor interface for providing position/orientation values.