vrdVRDevice¶
-
class
vrdVRDevice
¶
(Inherits vrdObject
)
Represents a VR device like a controller or a tracker. This can be created before the actual device is connected with the system. When a device connects, VRED will map the physical device to the already created object. This allows to define mappings in advance.
Please note: You get two different vrdVRDevice objects when you call both vrDeviceService.getVRDevice(name); and vrDeviceService.getVRDeviceBySerialNumber(serialNumber) before you connect the real hardware device. It’s not possible to verify that they belong to the same physical device before the hardware is available.
When the hardware is connected those device nodes will internally resolve to the correct physical device but they will still be two separate object instances and therefore you should not compare those nodes using the “==” operator.
It is safer to use either vrdVRDevice.getName() or vrdVRDevice.getSerialNumber() to compare them (depending on if you used name or serial number to get the node).
Summary¶
- Functions:
- addVirtualButton(button, physicalButton)
- disableRay()
- enableRay(axis)
- getButtonState(button) → vrdButtonState
- getName() → string
- getNode() → vrdNode
- getSerialNumber() → string
- getTrackingMatrix() → QMatrix4x4
- getVisualizationMode() → integer
- getVisualizationNode() → vrdNode
- getWristOrientationAngle() → float
- isVisible() → bool
- pick() → vrdRayIntersection
- removeVirtualButton(button, physicalButton)
- removeVirtualButton(virtualButton, physicalButton)
- setButtonPressed(state, button)
- setButtonTouched(state, button)
- setTrackingMatrix(matrix)
- setVisible(visible)
- setVisualizationMode(mode)
- signal() → Q_SLOTvrdVRDeviceSignal
- vibrate(milliseconds, axisId)
Functions¶
-
vrdVRDevice.
addVirtualButton
(button, physicalButton)¶ Adds a virtual button to the controller that maps a position of a button to a new signal.
Note: This is currently not available in OpenXR mode.
Parameters: - button (vrdVirtualTouchpadButton) – The virtual button.
- physicalButton (string) – Name of the physical button the virtual one is related to.
-
vrdVRDevice.
disableRay
()¶ Disables the currently activated pointing ray.
-
vrdVRDevice.
enableRay
(axis)¶ Enables a pointing ray out of the controller.
Parameters: axis (string) – The axis of the pointing ray. Possible values are “x”, “y”, “z” for the respective axes of the controller’s coordinate system, “custom” for the axis of the “Pointer” interaction, “teleportaxis” for the axis of the “Teleport” interaction, “controllerhandle” for the axis through the controller handle, as well as “leftfinger” and “rightfinger” for axes through the left and right index fingers of the hand visualization, respectively.
-
vrdVRDevice.
getButtonState
(button)¶ Gets the state of the current button.
Parameters: button (string) – The name of the button. Returns: The state of the current button. This might be invalid, if the name of the button is unknown to the VR device. Return type: vrdButtonState
-
vrdVRDevice.
getName
()¶ Gets the name of the device
Returns: The name of the device. Will be empty if the device is invalid. Return type: string
-
vrdVRDevice.
getNode
()¶ Gets a node under the origin of the VR device. This node is not part of the scenegraph. If some geometry should be attached to the device, a constraint (see vrConstraintService.createParentConstraint(targetNodes, constrainedNode, maintainOffset)) should be used. Example: vr/attachToController.py.
Returns: The node at the origin of the VR device. Return type: vrdNode
-
vrdVRDevice.
getSerialNumber
()¶ Gets the serial number of the device.
Note: In OpenXR mode this is only available for Vive trackers due to API limitations.
Returns: The serial number. This may be empty if the device has been created by name and the physical device is not connected, yet. Return type: string
-
vrdVRDevice.
getTrackingMatrix
()¶ Returns: The current tracking matrix Return type: QMatrix4x4
-
vrdVRDevice.
getVisualizationMode
()¶ Gets the current visualization mode.
Returns: Id of the mode 0 = controller, 1 = hand, 2 = controller and hand, 3 = Uninitialized Return type: integer
-
vrdVRDevice.
getVisualizationNode
()¶ Gets the root node of the controller visualization. If the controller is currently not visible or not detected by the tracking system, this function will return an empty node.
Returns: The root node of the VR device. Return type: vrdNode
-
vrdVRDevice.
getWristOrientationAngle
()¶ Returns the angle of the wrist orientation. This is 0 if the wrist is in rest position. This is the same angle that is also used to determine the orientation for VRED’s built-in teleport.
Note: This is currently not available in OpenXR mode.
Returns: Angle of the wrist in degree. Return type: float
-
vrdVRDevice.
isVisible
()¶ Gets the visibility of the device.
Returns: True = visible, False = invisible Return type: bool
-
vrdVRDevice.
pick
()¶ Tries to pick the object in the scene at the intersection point of the pointing ray with the scene.
Returns: The data of the intersection. Return type: vrdRayIntersection
-
vrdVRDevice.
removeVirtualButton
(button, physicalButton)¶ Removes a virtual button that is related to a physical button.
Note: This is currently not available in OpenXR mode.
Parameters: - button (vrdVirtualTouchpadButton) – The virtual button.
- physicalButton (string) – The name of the physical button the virtual button is related to.
-
vrdVRDevice.
removeVirtualButton
(virtualButton, physicalButton)¶ Removes a virtual button that is related to a physical button.
Note: This is currently not available in OpenXR mode.
Parameters: - virtualButton (string) – The name of the virtual button.
- physicalButton (string) – The name of the physical button the virtual button is related to.
-
vrdVRDevice.
setButtonPressed
(state, button)¶ Simulate a button press.
Note: This is currently not available in OpenXR mode.
Parameters: - state (bool) – True = pressed, False = released
- button (string) – “menu”, “grip”, “touchpad” or “trigger”
-
vrdVRDevice.
setButtonTouched
(state, button)¶ Simulate a button press. Currently not available in OpenXR mode.
Note: This is currently not available in OpenXR mode.
Parameters: - state (bool) – True = touched, False = untouched
- button (string) – “menu”, “grip”, “touchpad” or “trigger”
-
vrdVRDevice.
setTrackingMatrix
(matrix)¶ Simulate a tracking position change.
Note: This is currently not available in OpenXR mode.
Parameters: matrix (QMatrix4x4) – The tracking matrix
-
vrdVRDevice.
setVisible
(visible)¶ Sets the VR device visible or invisible.
Parameters: visible (bool) – True for visible, False for invisible.
-
vrdVRDevice.
setVisualizationMode
(mode)¶ Sets the visualization mode.
Parameters: mode (integer) – Id of the mode 0 = controller, 1 = hand, 2 = controller and hand
-
vrdVRDevice.
signal
()¶ Gets the signal that can be triggered.
Returns: The signal object. Return type: Q_SLOTvrdVRDeviceSignal
-
vrdVRDevice.
vibrate
(milliseconds, axisId)¶ Triggers the vibration functionality of the device if available.
Parameters: - milliseconds (integer) – The duration of the vibration in milliseconds.
- axisId (integer) – The axis of the controller that will vibrate. Note: This parameter will be ignored in OpenXR. Oculus Touch, HTC Vive and Windows MR controllers will ignore this parameter or assume it to be 0 in OpenVR.