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
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
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
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::InputVRController Class

Header: #include <UnigineInput.h>
Inherits from: InputVRDevice

The class manages VR controller input, serving as the primary interface for VR input.

Notice
Each instance of the InputVRController class will contain its own set of values sampled from the controller.

There are three types of VR controllers: left-hand, right-hand controllers, and a treadmill. To get the type of the VR controller, you can use the getControllerType() function.

The class provides access to the following input:

  • Buttons of the VR controller, including the touch buttons. They can be either pressed or released in the current frame or continuously pressed or touched for multiple frames in a row, including the current one.
  • Axes of the VR controller that detect 1-dimensional movement of the control. Depending on the type of the VR controller, there can be a different number of axes. Usually, there are 3 axes, however, UNIGINE supports up to 4.

    An axis can be mapped to a control of one of the following types (also referred to as an axis type): trackpad, joystick, or trigger. Each axis type has a different number of reserved axes.

    To identify the supported axes, call getNumAxes(). Additionally, you can get the axis type using getAxisType().

Notice
The article on VR Input System provides several examples of inputs on different types of OpenVR-supported controllers and information on buttons and axes mapping in UNIGINE.

InputVRController Class

枚举

MODEL_TYPE#

Name说明/描 述
MODEL_TYPE_UNKNOWN = 0Unknown controller.
MODEL_TYPE_HTC_VIVE = 1HTC Vive
MODEL_TYPE_OCULUS_RIFT = 2Oculus Rift
MODEL_TYPE_VALVE_KNUCKLES = 3Valve Index Knuckles
NUM_MODEL_TYPES = 4Total number of VR controller models.

CONTROLLER_TYPE#

Name说明/描 述
CONTROLLER_TYPE_UNKNOWN = 0Unknown controller type
CONTROLLER_TYPE_HAND_LEFT = 1Left hand controller
CONTROLLER_TYPE_HAND_RIGHT = 2Right hand controller
CONTROLLER_TYPE_TREADMILL = 3Treadmill
NUM_CONTROLLER_TYPES = 4Total number of controller types

AXIS_TYPE#

Name说明/描 述
AXIS_TYPE_NONE = 0Not specified
AXIS_TYPE_TRACK_PAD = 1Trackpad
AXIS_TYPE_JOYSTICK = 2Joystick
AXIS_TYPE_TRIGGER = 3Trigger
NUM_AXIS_TYPES = 4Total number of axis types.

Members


InputVRController::MODEL_TYPE getModelType ( ) const#

Returns the model type of the VR controller.

Return value

Controller model type.

void setFilter ( float filter ) #

Sets a filter value used to correct the current state of the analog axis relative to the previous one. Axis states are interpolated for thumbsticks and triggers.

Arguments

  • float filter - Filter value for interpolation between axis states. The provided value is clamped to a range [0.0;1.0].
    • Filter value of 0.0 means there is no interpolation and the current value is not corrected.
    • Filter value of 1.0 means the previous state is used instead of the current one.

float getFilter ( ) const#

Returns a filter value used to correct the current state of the analog axis (thumbsticks and triggers) relative to the previous one:
  • Filter value of 0.0 means there is no interpolation and the current value is not corrected.
  • Filter value of 1.0 means the previous state is used instead of the current one.

Return value

Filter value.

InputVRController::CONTROLLER_TYPE getControllerType ( ) const#

Returns the type of the VR controller.

Return value

Controller type.

int getNumAxes ( ) const#

Returns the number of axes supported by the VR controller.

Return value

Number of axes.

InputVRController::AXIS_TYPE getAxisType ( int axis ) const#

Returns the type of the specified axis.

Arguments

  • int axis - Axis number.

Return value

Axis type.

float getAxis ( int axis ) const#

Returns a state value for the specified axis. It includes position of the VR controller along the following axes: X, Y (two-axis controller) and Z (three-axis controller). When the VR controller is in the center position, X and Y axes values are zero. Negative values indicate left or down; positive values indicate right or up.

Arguments

  • int axis - Axis number.

Return value

Value in range [-1.0f; 1.0f].

float getAxisDelta ( int axis ) const#

Returns the axis delta — the difference between a new and the current state of the specified axis.

Arguments

  • int axis - Axis number.

Return value

Value in range [-1.0f; 1.0f].

bool isButtonPressed ( Input::VR_BUTTON button ) const#

Returns a value indicating if the specified button is pressed. Check this value to perform continuous actions.

Arguments

Return value

true if the button is pressed; otherwise, false.

bool isButtonDown ( Input::VR_BUTTON button ) const#

Returns a value indicating if the specified button was pressed during the current frame.

Arguments

Return value

true if the button was pressed; otherwise, false.

bool isButtonUp ( Input::VR_BUTTON button ) const#

Returns a value indicating if the specified button was released during the current frame.

Arguments

Return value

true if the button was released; otherwise, false.

bool isButtonTouchPressed ( Input::VR_BUTTON touch ) const#

Returns a value indicating if the specified button is touched.

Arguments

Return value

true if the button is touched; otherwise, false.

bool isButtonTouchDown ( Input::VR_BUTTON touch ) const#

Returns a value indicating if the specified touch button was "pressed" in the currect frame.

Arguments

Return value

true if the touch button was "pressed"; otherwise, false.

bool isButtonTouchUp ( Input::VR_BUTTON touch ) const#

Returns a value indicating if the specified touch button was "released" in the currect frame.

Arguments

Return value

true if the touch button was "released"; otherwise, false.

Ptr<InputEventVRButton> getButtonEvent ( Input::VR_BUTTON button ) const#

Returns the currently processed VR controller button input event.

Arguments

Return value

VR controller button input event, or nullptr if there are no events for the specified button in the current frame.

int getButtonEvents ( Input::VR_BUTTON button, Vector<Ptr<InputEventVRButton>> & OUT_events ) #

Returns the number of input events for the specified VR controller button and puts the events to the specified output buffer.

Arguments

Return value

Number of input events for the specified VR controller button.

Ptr<InputEventVRButtonTouch> getButtonTouchEvent ( Input::VR_BUTTON button ) const#

Returns the currently processed VR controller button touch event.

Arguments

Return value

VR controller button touch event, or nullptr if there are no events for the specified touch button in the current frame.

int getButtonTouchEvents ( Input::VR_BUTTON button, Vector<Ptr<InputEventVRButtonTouch>> & OUT_events ) #

Returns the number of touch events for the specified VR controller touch button and puts the events to the specified output buffer.

Arguments

Return value

Number of input events for the specified VR controller touch button.

void setVibration ( unsigned short duration_ms = 100 ) #

Sets the vibration of the given duration for the VR controller.

Arguments

  • unsigned short duration_ms - Duration of the vibration.
Last update: 2024-04-19
Build: ()