This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Unigine::Plugins::OpenVR Class

Header: #include <plugins/Unigine/OpenVR/UnigineOpenVR.h>
Warning
The plugin is deprecated. VR functionality is available out of the box since 2.18 for all supported graphics APIs except OpenGL.

This set of functions is available when the OpenVRplugin is loaded.

The source code of OpenVR can be found here.

The full set of Vive devices is described here.

See also#

A UnigineScript API sample <UnigineSDK>/data/samples/plugins/VIVE_00

OpenVR Class

枚举

CONTROLLER_ROLE#

Name说明/描 述
CONTROLLER_ROLE_INVALID = 0Invalid value for controller type.
CONTROLLER_ROLE_LEFT_HAND = 1Tracked device is associated with the left hand.
CONTROLLER_ROLE_RIGHT_HAND = 2Tracked device is associated with the right hand.
CONTROLLER_ROLE_OPT_OUT = 3Tracked device is opting out of left/right hand.
CONTROLLER_ROLE_TREADMILL = 4Tracked device is a treadmill.
CONTROLLER_ROLE_MAX = 5Indicates the maximum number of controller roles.

BUTTON#

Name说明/描 述
BUTTON_SYSTEM = 0The system button. These events are not visible to applications and are used internally to bring up the Steam Overlay or the Steam Client.
BUTTON_APPLICATIONMENU = 1The application menu button.
BUTTON_GRIP = 2The grip button.
BUTTON_DPAD_LEFT = 3The sensor panel left button.
BUTTON_DPAD_UP = 4The sensor panel up button.
BUTTON_DPAD_RIGHT = 5The sensor panel right button.
BUTTON_DPAD_DOWN = 6The sensor panel down button.
BUTTON_A = 7The button reserved for manual controllers.
BUTTON_AXIS0 = 32The axis reserved for manual controllers.
BUTTON_AXIS1 = 33The axis reserved for manual controllers.
BUTTON_AXIS2 = 34The axis reserved for manual controllers.
BUTTON_AXIS3 = 35The axis reserved for manual controllers.
BUTTON_AXIS4 = 36The axis reserved for manual controllers.
BUTTON_STEAMVR_TOUCHPAD = 32The touchpad on the SteamVR controller. It is the same as BUTTON_AXIS0.
BUTTON_STEAMVR_TRIGGER = 33The trigger on the SteamVR controller. It is the same as BUTTON_AXIS1.
BUTTON_DASHBOARD_BACK = 2The back to dashboard button.
BUTTON_MAX = 64This is not an actual button. It just indicates the maximum number of buttons in the system.

AXIS#

Name说明/描 述
AXIS_NONE = 0No axis is identified on the controller.
AXIS_TRACKPAD = 1An axis of a trackpad type.
AXIS_JOYSTICK = 2An axis of a joystick type.
AXIS_TRIGGER = 3An axis of a trigger type.

DEVICE#

Name说明/描 述
DEVICE_INVALID = 0A tracked device with an invalid index.
DEVICE_HMD = 1A tracked head-mounted display.
DEVICE_CONTROLLER = 2A tracked controller.
DEVICE_GENERIC_TRACKER = 3A tracked tracker device (Vive Tracker).
DEVICE_TRACKING = 4A tracked camera and base stations that serve as tracking reference points.

VIEWPORT#

Name说明/描 述
VIEWPORT_BLACK_SCREEN = 0No image (black screen).
VIEWPORT_MONO = 1Mono image.
VIEWPORT_STEREO = 2Stereo image (left and right eye).

TRACKING_SPACE#

Name说明/描 述
TRACKING_SPACE_SEATED = 0Poses are provided relative to the seated zero pose.
TRACKING_SPACE_STANDING = 1Poses are provided relative to the safe bounds specified by the user.
TRACKING_SPACE_RAW = 2Poses are provided in the coordinate system defined by the tracker driver.

Members


Math::vec2 getControllerAxis ( int device_num, int axis_num ) #

Returns the coordinates of the specified controller axis along the X and Y axes.

Arguments

  • int device_num - Device ID.
  • int axis_num - Axis number.

Return value

X and Y in the range of [-1;1] ([0;1] for a trigger).

bool getControllerButtonPressed ( int device_num, OpenVR::BUTTON button ) #

Returns the value indicating if the specified button is pressed.

Arguments

Return value

true if the button is pressed; otherwise - false.

bool getControllerButtonTouched ( int device_num, OpenVR::BUTTON button ) #

Returns the value indicating if the specified button is touched.

Arguments

Return value

true if the button is pressed; otherwise - false.

int getControllerPacketNum ( int device_num ) #

Returns the number of the controller packet.

Arguments

  • int device_num - Device ID.

Return value

Number of the controller packet.

void setControllerVibration ( int device_num, unsigned short duration ) #

Sets the vibration of the given duration and amplitude.

Arguments

  • int device_num - Device ID.
  • unsigned short duration - Duration of the vibration.

Math::vec3 getDeviceAngularVelocity ( int device_num ) #

Returns a device angular velocity, in radians per second.

Arguments

  • int device_num - Device ID.

Return value

Angular velocity.

bool isDeviceConnected ( int device_num ) #

Returns a value indicating if the device connected to the slot.

Arguments

  • int device_num - Device ID.

Return value

true - connected; false - not connected.

Math::mat4 getDeviceTransform ( int device_num ) #

Returns a single pose for a tracked device.

Arguments

  • int device_num - Device ID.

Return value

Identity matrix.

OpenVR::DEVICE getDeviceType ( int device_num ) #

Returns the device type.

Arguments

  • int device_num - Device ID.

Return value

Device type, one of the DEVICE variables.

Math::vec3 getDeviceVelocity ( int device_num ) #

Returns a device velocity in tracker space, in meters per second.

Arguments

  • int device_num - Device ID.

Return value

Velocity.

void setHeadPositionLock ( bool lock ) #

Locks the head position.

Arguments

  • bool lock - true to lock the head position.

bool isHeadPositionLock ( ) const#

Returns the value indicating if the head position is locked.

Return value

true if the head position is locked; otherwise - false.

void setHeadRotationLock ( bool lock ) #

Locks the head rotation.

Arguments

  • bool lock - true to lock the head rotation.

bool isHeadRotationLock ( ) const#

Returns the value indicating if the head rotation is locked.

Return value

true if the head rotation is locked; otherwise - false.

bool isPoseValid ( int device_num ) #

Returns a value indicating if the device pose is valid.

Arguments

  • int device_num - Device ID.

Return value

true - valid; false - invalid.

int getTrackingResult ( int device_num ) #

Returns the value indicating the tracking result:
  • Uninitialized
  • Calibrating in progress
  • Calibrating out of range
  • Running correctly
  • Running out of range

Arguments

  • int device_num - Device ID.

Return value

Tracking result.

OpenVR::VIEWPORT getViewportMode ( ) const#

Returns a value indicating the current viewport mode, that determines the type of image to be displayed in the viewport.

Return value

Current viewport mode. One of the VIEWPORT variables.

void setViewportMode ( OpenVR::VIEWPORT mode ) #

Sets the viewport mode, that determines the type of image to be displayed in the viewport.

Arguments

int getMaxTrackedDeviceCount ( ) const#

Returns the maximum value of tracked devices.

Return value

The maximum value of tracked devices.

int getControllerStateAxisCount ( ) const#

Returns a number of axes.

Return value

Number of axes.

OpenVR::AXIS getDeviceAxisType ( int device_num, int axis_num ) #

Returns the value that identifies what type of axis is on the indicated controller.

Arguments

  • int device_num - Device ID.
  • int axis_num - Axis number.

Return value

Axis of a corresponding type. One of the AXIS variables.

String getDeviceManufacturerName ( int device ) #

Returns the manufacturer name of the specified device.

Arguments

  • int device - Device ID.

Return value

Manufacturer name.

String getDeviceModelNumber ( int device ) #

Returns the model of the specified device.

Arguments

  • int device - Device ID.

Return value

Model.

OpenVR::CONTROLLER_ROLE getControllerRole ( int device_num ) #

Returns a specific role associated with a tracked device.

Arguments

  • int device_num - Device ID.

Return value

Role associated with a tracked device. One of the CONTROLLER_ROLE variables.

void render ( const Ptr<Player> & player, const Math::ivec2 & size, bool render_window ) #

Calls OpenVR rendering logic.

Arguments

  • const Ptr<Player> & player - The player camera.
  • const Math::ivec2 & size - The window size, in pixels.
  • bool render_window - true to enable rendering of a copy to the current render target window; false — to disable it.

void fadeToColor ( float time, const Math::vec4 & color, bool background = false ) #

Fades the view on the head-mounted display to the specified color.

Arguments

  • float time - Time in seconds that the fade will take.
  • const Math::vec4 & color - Fade color.
  • bool background -

Math::vec4 getCurrentFadeColor ( bool background = false ) #

Returns the current fade color.

Arguments

  • bool background -

Return value

Fade color.

void fadeToGrid ( float time, bool grid ) #

Fades the grid in or out.

Arguments

  • float time - Time in seconds that the fade will take.
  • bool grid - true to fade the grid in, false to fade the grid out.

float getCurrentGridAlpha ( ) #

Returns the current alpha value of the grid.

Return value

Grid alpha value.

void setTrackingSpace ( OpenVR::TRACKING_SPACE space ) #

Sets a zero pose for the tracking origin.

Arguments

OpenVR::TRACKING_SPACE getTrackingSpace ( ) const#

Returns the current zero pose of the tracking origin.

Return value

Zero pose of the tracking origin.

void resetZeroPose ( OpenVR::TRACKING_SPACE space ) #

Sets the zero pose of the given tracker coordinate system to the current tracker position.

Arguments

Last update: 2023-11-16
Build: ()