This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
Version Control
设置和首选项
项目开发
调整节点参数
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
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
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials

Unigine::VR Class

Header: #include <UnigineVR.h>

The base class for managing virtual reality in UNIGINE.

VR Initialization#

By default, VR is not initialized. To run the engine with VR, you need to specify the -vr_app command-line option on the application start-up.

Notice
You cannot launch the deprecated VR plugins (OpenVR , Varjo , Oculus ) when the built-in VR is initialized, as it overrides the plugin's functionality. If you try to add a VR plugin after VR initialization, you will get an error message.

Supported Graphics APIs#

The following graphics APIs are supported out of the box:

  • DirectX 11
  • DirectX 12
  • Vulkan
Notice
For OpenGL API support, use the corresponding VR plugins (deprecated).

VR Class

枚举

API#

Name描述
API_NULL = 0VR API is not initialized.
API_VARJO = 1Varjo API.
API_OPENVR = 2OpenVR API.
API_OPENXR = 3OpenXR API.

VIEWPORT_TYPE#

Name描述
VIEWPORT_TYPE_CONTEXT = 0Context (low-res) viewport.
VIEWPORT_TYPE_FOCUS = 1Focus (high-res) viewport.
VIEWPORT_TYPE_NUM = 2Number of viewport types.

EYE_TYPE#

Name描述
EYE_TYPE_LEFT = 0Left eye.
EYE_TYPE_RIGHT = 1Right eye.
EYE_TYPE_NUM = 2Number of eye types.

MIRROR_MODE#

Name描述
MIRROR_MODE_BEGIN = 0The first element to be used for iteration.
MIRROR_MODE_BLACK_SCREEN = 0No image (black screen).
MIRROR_MODE_MONO_LEFT = 1Mono image for the left eye.
MIRROR_MODE_MONO_RIGHT = 2Mono image for the right eye.
MIRROR_MODE_STEREO = 3Stereo image (left and right eyes).
MIRROR_MODE_END = 3The last element to be used for iteration.

WINDOW_MODE#

Name描述
WINDOW_MODE_BEGIN = 0The first element to be used for iteration.
WINDOW_MODE_DISABLED = 0Showing the mirrored image is disabled.
WINDOW_MODE_MAIN = 1The main window shows the mirrored image.
WINDOW_MODE_END = 1The last element to be used for iteration.

TRACKING_SPACE#

Name描述
TRACKING_SPACE_BEGIN = 0The first element to be used for iteration.
TRACKING_SPACE_UNKNOWN = 0Poses are provided in the coordinate system defined by the tracker driver.
TRACKING_SPACE_SEATED = 1Poses are provided relative to the seated zero pose.
TRACKING_SPACE_STANDING = 2Poses are provided relative to the safe bounds specified by the user.
TRACKING_SPACE_END = 2The last element to be used for iteration.

DEBUG_MODE#

Name描述
DEBUG_MODE_DISABLED = 0Debug VR context is disabled.
DEBUG_MODE_ENABLED = 1Debug VR context is enabled.
DEBUG_MODE_ENABLED_BREAK_ON_ERROR = 2Debug VR context with the break on error option is enabled (only on debug binaries).

RUNTIME_TYPE#

Name描述
RUNTIME_TYPE_UNKNOWN = 0The runtime type is unknown.
RUNTIME_TYPE_NULL = 1The runtime is null.
RUNTIME_TYPE_STEAMVR = 2SteamVR runtime.
RUNTIME_TYPE_OCULUS = 3Oculus runtime.
RUNTIME_TYPE_VARJO = 4Varjo runtime.
RUNTIME_TYPE_WMR = 5Windows Mixed Reality OpenXR runtime.

Members

void setRenderEnabled ( bool enabled = 0 ) #

Console: vr_render_enabled
Sets a new value indicating if rendering into the head-mounted display is enabled. This parameter is stored in the following configuration file: *.boot. The default value is 0.

Arguments

  • bool enabled - Set true to enable rendering into the HMD; false - to disable it. The default value is false.

bool isRenderEnabled() const#

Console: vr_render_enabled
Returns the current value indicating if rendering into the head-mounted display is enabled. This parameter is stored in the following configuration file: *.boot.

Return value

true if rendering into the HMD is enabled; otherwise false. The default value is false.

void setPeripheralRenderingModeEnabled ( bool enabled = 0 ) #

Console: vr_peripheral_rendering_mode_enabled
Sets a new value indicating if the peripheral rendering mode is enabled. In this mode, the HMD has two context (peripheral) and two focus displays. You can disable two additional viewports to improve peformance.
Notice
This feature is available for the Varjo devices only.
This parameter is stored in the following configuration file: *.boot. The default value is 0.

Arguments

  • bool enabled - Set true to enable the peripheral rendering mode; false - to disable it. The default value is false.

bool isPeripheralRenderingModeEnabled() const#

Console: vr_peripheral_rendering_mode_enabled
Returns the current value indicating if the peripheral rendering mode is enabled. In this mode, the HMD has two context (peripheral) and two focus displays. You can disable two additional viewports to improve peformance.
Notice
This feature is available for the Varjo devices only.
This parameter is stored in the following configuration file: *.boot.

Return value

true if the peripheral rendering mode is enabled; otherwise false. The default value is false.

void setMirrorMode ( VR::MIRROR_MODE mode = 3 ) #

Console: vr_mirror_mode
Sets a new mirror mode that defines how the mirrored image (i.e. VR image) will be displayed in the target window. This parameter is stored in the following configuration file: *.boot. The default value is 3.

Arguments

  • VR::MIRROR_MODE mode - The mirror mode that defines how the mirrored image (i.e. VR image) will be displayed in the target window. One of the following values:
    • 0 - black screen (no image is displayed).
    • 1 - image rendered for the left eye.
    • 2 - image rendered for the right eye.
    • 3 - stereo image (both the left and right eyes). (by default)

VR::MIRROR_MODE getMirrorMode() const#

Console: vr_mirror_mode
Returns the current mirror mode that defines how the mirrored image (i.e. VR image) will be displayed in the target window. This parameter is stored in the following configuration file: *.boot.

Return value

Current mirror mode that defines how the mirrored image (i.e. VR image) will be displayed in the target window. One of the following values:
  • 0 - black screen (no image is displayed).
  • 1 - image rendered for the left eye.
  • 2 - image rendered for the right eye.
  • 3 - stereo image (both the left and right eyes). (by default)

void setWindowMode ( VR::WINDOW_MODE mode = 1 ) #

Console: vr_window_mode
Sets a new window mode that defines which window will display the mirrored image (i.e. VR image). This parameter is stored in the following configuration file: *.boot. The default value is 1.

Arguments

  • VR::WINDOW_MODE mode - The window mode that defines which window will display the mirrored image (i.e. VR image). One of the following values:
    • 0 - mirroring is disabled.
    • 1 - main window displays the mirrored image. (by default)

VR::WINDOW_MODE getWindowMode() const#

Console: vr_window_mode
Returns the current window mode that defines which window will display the mirrored image (i.e. VR image). This parameter is stored in the following configuration file: *.boot.

Return value

Current window mode that defines which window will display the mirrored image (i.e. VR image). One of the following values:
  • 0 - mirroring is disabled.
  • 1 - main window displays the mirrored image. (by default)

void setTrackingSpace ( VR::TRACKING_SPACE space = 1 ) #

Console: vr_tracking_space
Sets a new zero pose of the tracking origin. This parameter is stored in the following configuration file: *.boot. The default value is 1.

Arguments

  • VR::TRACKING_SPACE space - The zero pose of the tracking origin. One of the following values:
    • 0 - seated.
    • 1 - standing. (by default)
    • 2 - raw (uncalibrated).

VR::TRACKING_SPACE getTrackingSpace() const#

Console: vr_tracking_space
Returns the current zero pose of the tracking origin. This parameter is stored in the following configuration file: *.boot.

Return value

Current zero pose of the tracking origin. One of the following values:
  • 0 - seated.
  • 1 - standing. (by default)
  • 2 - raw (uncalibrated).

void setMotionPrediction ( bool prediction = 0 ) #

Console: vr_motion_prediction
Sets a new value indicating if motion prediction in the Varjo headsets is enabled. When enabled, the engine submits the velocity value from the GBuffer to the Varjo Composer. This parameter is stored in the following configuration file: *.boot. The default value is 0.

Arguments

  • bool prediction - Set true to enable motion prediction; false - to disable it. The default value is false.

bool isMotionPrediction() const#

Console: vr_motion_prediction
Returns the current value indicating if motion prediction in the Varjo headsets is enabled. When enabled, the engine submits the velocity value from the GBuffer to the Varjo Composer. This parameter is stored in the following configuration file: *.boot.

Return value

true if motion prediction is enabled; otherwise false. The default value is false.

void setMotionPredictionVelocityPrecision ( float precision = 32.0f ) #

Console: vr_motion_prediction_velocity_precision
Sets a new factor of velocity scale before packing a floating point value into a 2x8 bit unsigned integer (uint).
Notice
This feature is available for the Varjo devices only.
This parameter is stored in the following configuration file: *.boot. The default value is 32.0f.

Arguments

  • float precision - The factor of velocity scale before packing a floating point value into a 2x8 bit unsigned integer (uint).
    Range of values: [eps, inf]. The default value is : 32.0f.

float getMotionPredictionVelocityPrecision() const#

Console: vr_motion_prediction_velocity_precision
Returns the current factor of velocity scale before packing a floating point value into a 2x8 bit unsigned integer (uint).
Notice
This feature is available for the Varjo devices only.
This parameter is stored in the following configuration file: *.boot.

Return value

Current factor of velocity scale before packing a floating point value into a 2x8 bit unsigned integer (uint).
Range of values: [eps, inf]. The default value is : 32.0f.

void setMotionPredictionVelocityTimeDelta ( float delta = 1.0f / 60.0f ) #

Console: vr_motion_prediction_velocity_time_delta
Sets a new factor for optimizing between fast and slow-moving objects. A smaller number works better for fast-moving objects, and vice versa.
Notice
This feature is available for the Varjo devices only.
This parameter is stored in the following configuration file: *.boot. The default value is 1.0f / 60.0f.

Arguments

  • float delta - The factor for optimizing between fast and slow-moving objects. A smaller number works better for fast-moving objects, and vice versa.
    Range of values: [eps, inf]. The default value is : 1.0f / 60.0f.

float getMotionPredictionVelocityTimeDelta() const#

Console: vr_motion_prediction_velocity_time_delta
Returns the current factor for optimizing between fast and slow-moving objects. A smaller number works better for fast-moving objects, and vice versa.
Notice
This feature is available for the Varjo devices only.
This parameter is stored in the following configuration file: *.boot.

Return value

Current factor for optimizing between fast and slow-moving objects. A smaller number works better for fast-moving objects, and vice versa.
Range of values: [eps, inf]. The default value is : 1.0f / 60.0f.

void setFoveatedRenderingEnabled ( bool enabled = 1 ) #

Console: vr_foveated_rendering_enabled
Sets a new value indicating if foveated rendering is enabled. Foveated rendering makes use of the eye tracking functionality in the Varjo headsets to improve performance by reducing the image quality in peripheral areas where the user is not looking. Foveation allows applications to render fewer pixels and achieve a better VR experience.
Notice
This feature is available for the Varjo devices only.
This parameter is stored in the following configuration file: *.boot. The default value is 1.

Arguments

  • bool enabled - Set true to enable foveated rendering; false - to disable it. The default value is true.

bool isFoveatedRenderingEnabled() const#

Console: vr_foveated_rendering_enabled
Returns the current value indicating if foveated rendering is enabled. Foveated rendering makes use of the eye tracking functionality in the Varjo headsets to improve performance by reducing the image quality in peripheral areas where the user is not looking. Foveation allows applications to render fewer pixels and achieve a better VR experience.
Notice
This feature is available for the Varjo devices only.
This parameter is stored in the following configuration file: *.boot.

Return value

true if foveated rendering is enabled; otherwise false. The default value is true.

const char * getApiName() const#

Returns the current name of the VR API.

Return value

Current name of the VR API.

VR::API getApiType() const#

Returns the current type of the VR API.

Return value

Current type of the VR API.

float getHMDRefreshRate() const#

Returns the current refresh rate of the head-mounted display.

Return value

Current refresh rate of the HMD.

Math::Vec3 getHandTrackingOffset() const#

Returns the current hand tracking offset (for the Ultraleap device only).

Return value

Current hand tracking offset.

bool isPeripheralRenderingModeUsed() const#

Returns the current value indicating if the peripheral rendering is used.

Return value

true if the peripheral rendering is used; otherwise false.

bool isHMDConnected() const#

Returns the current value indicating if the head-mounted display is connected.

Return value

true if the HMD is connected; otherwise false.

bool isUsingFoveatedRendering() const#

Returns the current value indicating if the foveated rendering is used.

Return value

true if the foveated rendering is used; otherwise false.

Ptr<Viewport> getViewport() const#

Returns the current viewport. It can be useful when implementing extra VR logic.

Return value

Current viewport.

static Event<bool> getEventRenderModelsVisibility() const#

Event triggered when the render models visibility is changed. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(visible)

Usage Example

Source code (C++)
// implement the RenderModelsVisibility event handler
void rendermodelsvisibility_event_handler(visible)
{
	Log::message("\Handling RenderModelsVisibility event\n");
}


//////////////////////////////////////////////////////////////////////////////
//  1. Multiple subscriptions can be linked to an instance of the EventConnections 
//  class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnections class
EventConnections rendermodelsvisibility_event_connections;

// link to this instance when subscribing to an event (subscription to various events can be linked)
VR::getEventRenderModelsVisibility().connect(rendermodelsvisibility_event_connections, rendermodelsvisibility_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
VR::getEventRenderModelsVisibility().connect(rendermodelsvisibility_event_connections, [](visible) { 
		Log::message("\Handling RenderModelsVisibility event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
rendermodelsvisibility_event_connections.disconnectAll();

//////////////////////////////////////////////////////////////////////////////
//  2. You can subscribe and unsubscribe via an instance of the EventConnection 
//  class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnection class
EventConnection rendermodelsvisibility_event_connection;

// subscribe to the RenderModelsVisibility event with a handler function keeping the connection
VR::getEventRenderModelsVisibility().connect(rendermodelsvisibility_event_connection, rendermodelsvisibility_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
rendermodelsvisibility_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
rendermodelsvisibility_event_connection.setEnabled(true);

// ...

// remove subscription to the RenderModelsVisibility event via the connection
rendermodelsvisibility_event_connection.disconnect();

//////////////////////////////////////////////////////////////////////////////
//  3. You can add EventConnection/EventConnections instance as a member of the
//  class that handles the event. In this case all linked subscriptions will be 
//  automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////

// Class handling the event
class SomeClass
{
public:
	// instance of the EventConnections class as a class member
	EventConnections e_connections;

	// A RenderModelsVisibility event handler implemented as a class member
	void event_handler(visible)
	{
		Log::message("\Handling RenderModelsVisibility event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
VR::getEventRenderModelsVisibility().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;


//////////////////////////////////////////////////////////////////////////////
//   4. Subscribe to an event saving a particular connection ID
//   and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;

// define a particular connection ID to be used to unsubscribe later
EventConnectionId rendermodelsvisibility_handler_id;

// subscribe to the RenderModelsVisibility event with a lambda handler function and keeping connection ID
rendermodelsvisibility_handler_id = VR::getEventRenderModelsVisibility().connect(e_connections, [](visible) { 
		Log::message("\Handling RenderModelsVisibility event (lambda).\n");
	}
);

// remove the subscription later using the ID
VR::getEventRenderModelsVisibility().disconnect(rendermodelsvisibility_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   5. Ignoring all RenderModelsVisibility events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
VR::getEventRenderModelsVisibility().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
VR::getEventRenderModelsVisibility().setEnabled(true);

Return value

Event reference.

static Event<> getEventAudioSettingsChanged() const#

Event triggered when the audio settings changed. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler()

Usage Example

Source code (C++)
// implement the AudioSettingsChanged event handler
void audiosettingschanged_event_handler()
{
	Log::message("\Handling AudioSettingsChanged event\n");
}


//////////////////////////////////////////////////////////////////////////////
//  1. Multiple subscriptions can be linked to an instance of the EventConnections 
//  class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnections class
EventConnections audiosettingschanged_event_connections;

// link to this instance when subscribing to an event (subscription to various events can be linked)
VR::getEventAudioSettingsChanged().connect(audiosettingschanged_event_connections, audiosettingschanged_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
VR::getEventAudioSettingsChanged().connect(audiosettingschanged_event_connections, []() { 
		Log::message("\Handling AudioSettingsChanged event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
audiosettingschanged_event_connections.disconnectAll();

//////////////////////////////////////////////////////////////////////////////
//  2. You can subscribe and unsubscribe via an instance of the EventConnection 
//  class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnection class
EventConnection audiosettingschanged_event_connection;

// subscribe to the AudioSettingsChanged event with a handler function keeping the connection
VR::getEventAudioSettingsChanged().connect(audiosettingschanged_event_connection, audiosettingschanged_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
audiosettingschanged_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
audiosettingschanged_event_connection.setEnabled(true);

// ...

// remove subscription to the AudioSettingsChanged event via the connection
audiosettingschanged_event_connection.disconnect();

//////////////////////////////////////////////////////////////////////////////
//  3. You can add EventConnection/EventConnections instance as a member of the
//  class that handles the event. In this case all linked subscriptions will be 
//  automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////

// Class handling the event
class SomeClass
{
public:
	// instance of the EventConnections class as a class member
	EventConnections e_connections;

	// A AudioSettingsChanged event handler implemented as a class member
	void event_handler()
	{
		Log::message("\Handling AudioSettingsChanged event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
VR::getEventAudioSettingsChanged().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;


//////////////////////////////////////////////////////////////////////////////
//   4. Subscribe to an event saving a particular connection ID
//   and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;

// define a particular connection ID to be used to unsubscribe later
EventConnectionId audiosettingschanged_handler_id;

// subscribe to the AudioSettingsChanged event with a lambda handler function and keeping connection ID
audiosettingschanged_handler_id = VR::getEventAudioSettingsChanged().connect(e_connections, []() { 
		Log::message("\Handling AudioSettingsChanged event (lambda).\n");
	}
);

// remove the subscription later using the ID
VR::getEventAudioSettingsChanged().disconnect(audiosettingschanged_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   5. Ignoring all AudioSettingsChanged events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
VR::getEventAudioSettingsChanged().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
VR::getEventAudioSettingsChanged().setEnabled(true);

Return value

Event reference.

static Event<int> getEventDeviceRenderModelChanged() const#

Event triggered when the render model of the VR device is changed. You can subscribe to events via connect()  and unsubscribe via disconnect(). You can also use EventConnection  and EventConnections  classes for convenience (see examples below).
Notice
For more details see the Event Handling article.
The event handler signature is as follows: myhandler(vr_device_number)

Usage Example

Source code (C++)
// implement the DeviceRenderModelChanged event handler
void devicerendermodelchanged_event_handler(vr_device_number)
{
	Log::message("\Handling DeviceRenderModelChanged event\n");
}


//////////////////////////////////////////////////////////////////////////////
//  1. Multiple subscriptions can be linked to an instance of the EventConnections 
//  class that you can use later to remove all these subscriptions at once
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnections class
EventConnections devicerendermodelchanged_event_connections;

// link to this instance when subscribing to an event (subscription to various events can be linked)
VR::getEventDeviceRenderModelChanged().connect(devicerendermodelchanged_event_connections, devicerendermodelchanged_event_handler);

// other subscriptions are also linked to this EventConnections instance 
// (e.g. you can subscribe using lambdas)
VR::getEventDeviceRenderModelChanged().connect(devicerendermodelchanged_event_connections, [](vr_device_number) { 
		Log::message("\Handling DeviceRenderModelChanged event (lambda).\n");
	}
);

// ...

// later all of these linked subscriptions can be removed with a single line
devicerendermodelchanged_event_connections.disconnectAll();

//////////////////////////////////////////////////////////////////////////////
//  2. You can subscribe and unsubscribe via an instance of the EventConnection 
//  class. And toggle this particular connection off and on, when necessary.
//////////////////////////////////////////////////////////////////////////////

// create an instance of the EventConnection class
EventConnection devicerendermodelchanged_event_connection;

// subscribe to the DeviceRenderModelChanged event with a handler function keeping the connection
VR::getEventDeviceRenderModelChanged().connect(devicerendermodelchanged_event_connection, devicerendermodelchanged_event_handler);

// ...

// you can temporarily disable a particular event connection to perform certain actions
devicerendermodelchanged_event_connection.setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
devicerendermodelchanged_event_connection.setEnabled(true);

// ...

// remove subscription to the DeviceRenderModelChanged event via the connection
devicerendermodelchanged_event_connection.disconnect();

//////////////////////////////////////////////////////////////////////////////
//  3. You can add EventConnection/EventConnections instance as a member of the
//  class that handles the event. In this case all linked subscriptions will be 
//  automatically removed when class destructor is called
//////////////////////////////////////////////////////////////////////////////

// Class handling the event
class SomeClass
{
public:
	// instance of the EventConnections class as a class member
	EventConnections e_connections;

	// A DeviceRenderModelChanged event handler implemented as a class member
	void event_handler(vr_device_number)
	{
		Log::message("\Handling DeviceRenderModelChanged event\n");
		// ...
	}
};

SomeClass *sc = new SomeClass();

// ...

// specify a class instance in case a handler method belongs to some class
VR::getEventDeviceRenderModelChanged().connect(sc->e_connections, sc, &SomeClass::event_handler);

// ...

// handler class instance is deleted with all its subscriptions removed automatically
delete sc;


//////////////////////////////////////////////////////////////////////////////
//   4. Subscribe to an event saving a particular connection ID
//   and unsubscribe later by this ID
//////////////////////////////////////////////////////////////////////////////
// instance of the EventConnections class to manage event connections
EventConnections e_connections;

// define a particular connection ID to be used to unsubscribe later
EventConnectionId devicerendermodelchanged_handler_id;

// subscribe to the DeviceRenderModelChanged event with a lambda handler function and keeping connection ID
devicerendermodelchanged_handler_id = VR::getEventDeviceRenderModelChanged().connect(e_connections, [](vr_device_number) { 
		Log::message("\Handling DeviceRenderModelChanged event (lambda).\n");
	}
);

// remove the subscription later using the ID
VR::getEventDeviceRenderModelChanged().disconnect(devicerendermodelchanged_handler_id);


//////////////////////////////////////////////////////////////////////////////
//   5. Ignoring all DeviceRenderModelChanged events when necessary
//////////////////////////////////////////////////////////////////////////////

// you can temporarily disable the event to perform certain actions without triggering it
VR::getEventDeviceRenderModelChanged().setEnabled(false);

// ... actions to be performed

// and enable it back when necessary
VR::getEventDeviceRenderModelChanged().setEnabled(true);

Return value

Event reference.

bool isSteamVRDashboardActive() const#

Returns the current value indicating if the SteamVR controllers are rendered. When you access the SteamVR menu during the application runtime, the SteamVR controllers start to be rendered along with the application controllers. You can use this function to check the state of the SteamVR controllers and disable the application controllers to avoid performance drops caused by the simultaneous rendering of both controllers.

Return value

true if the SteamVR controllers are rendered is enabled; otherwise false.

VR::RUNTIME_TYPE getInputRuntimeType() const#

Returns the current type of the VR input runtime.

Return value

Current type of the VR input runtime.

const char * getInputRuntimeName() const#

Returns the current name of the VR input runtime.

Return value

Current name of the VR input runtime.

void setDebugMode ( VR::DEBUG_MODE mode ) #

Sets a new debug mode for VR. If the debug mode is disabled, displaying of GAPI errors in VR runtime is also disabled.

Arguments


VR::DEBUG_MODE getDebugMode() const#

Returns the current debug mode for VR. If the debug mode is disabled, displaying of GAPI errors in VR runtime is also disabled.

Return value

Current debug mode for VR.

Math::ivec2 getHMDResolution ( VR::VIEWPORT_TYPE viewport_type = Enum.VR.VIEWPORT_TYPE.CONTEXT ) const#

Returns the current resolution of the head-mounted display. For HMDs having context (peripheral) and focus displays, you should specify the viewport type.

Arguments

  • VR::VIEWPORT_TYPE viewport_type - Type of the viewport (for HMDs having context (peripheral) and focus displays).

Return value

HMD resolution.

bool hasFeatureMixedReality ( ) const#

Returns a value indicating if the mixed reality mode is available. Mixed reality enables you to combine real-world view from front-facing cameras mounted on the headset with the VR image rendered. This feature is available for the Varjo devices only.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureEyeTracking ( ) const#

Returns a value indicating if eye tracking is available. This feature is available for the Varjo devices only.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureTrackingSpaceRaw ( ) const#

Returns a value indicating if poses can be provided in the coordinate system defined by the tracker driver.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureMotionPrediction ( ) const#

Returns a value indicating if motion prediction is available. This feature is available for the Varjo devices only. It allows the engine to submit the velocity from the GBuffer to the Varjo Composer.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureFoveatedRendering ( ) const#

Returns a value indicating if foveated rendering is available. This feature is available for the Varjo devices only. Foveated rendering enhances performance by using the eye tracking functionality in Varjo headsets: it decreases the image quality in the peripheral areas where the user is not looking. Foveation allows applications to render fewer pixels and achieve a better VR experience.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureReportProximitySensor ( ) const#

Returns a value indicating if proximity sensor reporting is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureSupportForTreadmill ( ) const#

Returns a value indicating if the user treadmill support is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureSupportForBaseStations ( ) const#

Returns a value indicating if the base stations support is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureSupportForTrackers ( ) const#

Returns a value indicating if support for trackers is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureSupportForRenderModelComponents ( ) const#

Returns a value indicating if support for render model components is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool resetZeroPose ( ) const#

Sets the zero pose to the current tracker position.

Return value

true if the pose is reset successfully; otherwise, false.

bool hasFeatureSupportForRenderModel ( ) const#

Returns a value indicating if VR API can provide Render Models for the controllers.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureFadeToColor ( ) const#

Returns a value indicating if the FadeToColor feature is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureFadeGrid ( ) const#

Returns the value indicating if the FadeGrid feature is available.
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

bool hasFeatureGetAudioDevice ( ) const#

Returns the value indicating if VR API can return Audio Device name (usually Oculus only).
Notice
If VR is not initialized, the function will return false.

Return value

true if the feature is available; otherwise, false.

void fadeToColor ( float seconds, const Math::vec4 & color, bool background ) #

Fades the engine render to the specified color over time.

Arguments

  • float seconds - Fade period, in seconds.
  • const Math::vec4 & color - Target color.
  • bool background

void fadeGrid ( float seconds, bool fade_in ) #

Fades the engine render to/from the grid over the specified time.

Arguments

  • float seconds - Fade period, in seconds.
  • bool fade_in - true fades render to grid; false fades grid to render.
Last update: 2024-10-09
Build: ()