This page has been translated automatically.
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
CIGI Client Plugin
Rendering-Related Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Oculus Rift Output with AppOculus Plugin

An AppOculus plugin is used to support the Oculus Rift head-mounted display. For the correct work of the plugin Oculus Rift PC Runtime is required. Note that your customers must have runtime installed as well. The plugin supports all HMD types supported by the latest Oculus Rift PC Runtime (including Oculus Rift CV1 (Consumer Version).

Notice
Since Oculus VR has stopped supporting Linux and Mac, the plugin is available only for Windows.

The AppOculus plugin provides the VR mode that allows for rendering to both the Oculus Rift head-mounted display and the PC display. When the VR mode is disabled, the image is rendered only to the PC display. The mode can be toggled by using the engine.oculus.setEnabled() function.

Both the windowed and the full screen modes are supported. On the PC display the image is rendered as follows:

Valley benchmark rendered on PC display with AppOculus

See Also

To run the plugin sample from the Unigine SDK Browser, go to the Samples tab, choose UnigineScript -> App and run the app_oculus_00 sample.

Implementing Unigine Application with Oculus Support

To use the Oculus Rift virtual display with Unigine, perform the following:

  1. Get and set up the latest Oculus Rift PC Runtime.
  2. Create a new project with AppOculus support via Unigine SDK Browser: click Video Output Options, check the Oculus support (AppOculus plugin) option in the form that opens and clickOk.
    Notice
    To add Oculus support to an existing project, in Unigine SDK Browser, click Other Actions ->Configure Project -> Video Output Options -> Oculus support (AppOculus plugin) -> Ok.

  3. Implement the application logic by using functions of the AppOculus plugin API. You can also change the plugin API functions or add new ones and then recompile the plugin.
  4. Plug in the Oculus Rift virtual display.
  5. Launch the AppOculus plugin on the application start-up.

Launching AppOculus

To launch the plugin, specify the extern_plugin command line option on the application start-up:

Shell commands
main_x86d -extern_plugin "AppOculus"

If you run the application via Unigine SDK Browser, set the Stereo 3D option to Oculus Rift in the Options tab and click Apply:

Notice
Head-tracking support is available by default.

AppOculus Options

The following CLI options can be specified on the application start-up:

  • oculus_density - the render target pixel density. In other words, this is the ratio of the number of render target pixels to display pixels at the center of distortion. The default value is 1.0 (the render target pixel density matches the display surface at the point on the display).
  • oculus_scale - the world scale. The default value is 1.0.

Shell commands
main_x86d -extern_plugin "AppOculus" -oculus_density 1.0 -oculus_scale 8.0

Compiling AppOculus

Plugin compilation is required if you change its source code (for example, add new API functions).

Oculus SDK is required for recompiling the AppOculus plugin:

  1. Get the Oculus Rift SDK.
    Notice
    The 1.10 version is required.
  2. Set the path to the <Oculus Rift SDK>/LibOVR folder in the OCULUSROOT environment variable:
    Shell commands
    OCULUSROOT=<Oculus Rift SDK>/LibOVR
  3. Compile the plugin in one of the following ways:
    Notice
    Since version 1.10, Oculus Rift SDK library (LibOVR) is compiled with the /MT flag set for the runtime library. For the plugin to work correctly, you can:
    • Compile the plugin with the /MT flag (see details below) or
    • recompile the libovr.lib library with the /MD flag.
    • Via Microsoft Visual Studio: go to the <UnigineSDK>\source\plugins\App\AppOculus, open the appoculus_vs2013.vcxproj or appoculus_vs2015.vcxproj project and build it.

      To change the flag set for the runtime library, go to Project -> Properties -> Configuration Properties -> C/C++ -> Code Generation and set Multi-threaded (/MT) for Runtime Library.

    • Via the command prompt by using the build script or Scons:
      Shell commands
      C:\UnigineSDK\utils>build.py --plugin AppOculus
      Shell commands
      C:\UnigineSDK\source\plugins\App\AppOculus>scons -u
      To change the flag set for the runtime library, go to <Unigine SDK>\source\plugins\App\AppOculus\SConscript and add the following code before calling BuildPlugin('AppOculus',Split(sources)):
      Output
      env.Append(CPPFLAGS = Split('/MT'))
Last update: 2017-10-20
Build: ()