Skip to end of metadata
Go to start of metadata

 

Overview

Oculus Rift support is now included in CRYENGINE. This article covers the programming side of interacting with a Rift headset. For information on basic use, see VR - Oculus Rift.
 

 

Chapters:


Code

This section describes how to access VR in general, but specifically the Oculus from Game Code.

Check VR Setup

In order to check if the current VR setup is valid, you can check if the VR related pointers are set and valid:

C++  Expand source
C#  Expand source

Get HMD Device Tracking State

You can retrieve the position and rotation of the HMD device. While the camera will usually be controlled by the ViewSystem directly, this might be useful to setup additional checks and game-play logic that takes the user's head position into consideration. In the following code samples we will assume pDevice to be set according to 'Check VR Support':

C++  Expand source
C#  Expand source

Get Controller Tracking State

You can get the controller's tracking states similar to the HMD's tracking state.

C++  Expand source
C#  Expand source

React to Controller Input

The Oculus Touch controller provides more than just tracking information. It has some buttons, a trigger and a touchpad, and you have several options should you want to react to inputs other than just tracking information:

 

NameTypeDescription
otouch_aButton 
otouch_bButton 
otouch_xButton 
otouch_yButton 
otouch_l3TriggerLeft thumb button (stick).
otouch_r3TriggerRight thumb button (stick).
otouch_triggerl_btnButtonLeft trigger button.
otouch_triggerr_btnButtonRight trigger button.
otouch_l1TriggerLeft index trigger.
otouch_r1TriggerRight index trigger.
otouch_l2TriggerLeft hand trigger.
otouch_r2TriggerRight hand trigger.
otouch_sticklyAxisLeft stick vertical motion.
otouch_stickryAxisRight stick vertical motion.
otouch_sticklxAxisLeft stick horizontal motion.
otouch_stickrxAxisRight stick horizontal motion.

 

  • InputListener: Please read CryInput. Check for DeviceType eIDT_Motion and KeyIds:
  • eKI_Motion_OculusTouch_A
  • eKI_Motion_OculusTouch_B
  • eKI_Motion_OculusTouch_X
  • eKI_Motion_OculusTouch_Y
  • eKI_Motion_OculusTouch_L3
  • eKI_Motion_OculusTouch_R3
  • eKI_Motion_OculusTouch_TriggerBtnL
  • eKI_Motion_OculusTouch_TriggerBtnR
  • eKI_Motion_OculusTouch_L1
  • eKI_Motion_OculusTouch_R1
  • eKI_Motion_OculusTouch_L2
  • eKI_Motion_OculusTouch_R2
  • eKI_Motion_OculusTouch_StickL_Y
  • eKI_Motion_OculusTouch_StickR_Y
  • eKI_Motion_OculusTouch_StickL_X
  • eKI_Motion_OculusTouch_StickR_X
  • eKI_Motion_OculusTouch_Gesture_ThumbUpL
  • eKI_Motion_OculusTouch_Gesture_ThumbUpR
  • eKI_Motion_OculusTouch_Gesture_IndexPointingL
  • eKI_Motion_OculusTouch_Gesture_IndexPointingR
  • Polling: Additionally, you can poll the current controller state. A nice bonus of this approach, is that you will not only get the information if a button is pressed, but also (in most cases) if the button is just touched:
C++  Expand source
C#  Expand source

Oculus HRTF Plugin Support in Wwise

To activate HRTF plugin support in Wwise,  set the AUDIO_HRTF option in CMake.

  • No labels