Class VRContext

java.lang.Object
gaiasky.vr.openvr.VRContext
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable

public class VRContext extends Object implements com.badlogic.gdx.utils.Disposable
Responsible for initializing the VR system, managing rendering surfaces, getting tracking device poses, submitting the rendering results to the HMD and rendering the surfaces side by side to the companion window on the desktop. Wrapper around OpenVR.

  • Constructor Details Link icon

    • VRContext Link icon

      public VRContext()
      Creates a new VRContext, initializes the VR system, and sets up rendering surfaces with depth attachments.
    • VRContext Link icon

      public VRContext(float renderTargetMultiplier, boolean hasStencil)
      Creates a new VRContext, initializes the VR system, and sets up rendering surfaces.
      Parameters:
      renderTargetMultiplier - multiplier to scale the render surface dimensions as a replacement for multisampling
      hasStencil - whether the rendering surfaces should have a stencil buffer
  • Method Details Link icon

    • hmdMat4toMatrix4 Link icon

      public static void hmdMat4toMatrix4(org.lwjgl.openvr.HmdMatrix44 hdm, com.badlogic.gdx.math.Matrix4 mat)
    • hmdMat34ToMatrix4 Link icon

      public static void hmdMat34ToMatrix4(org.lwjgl.openvr.HmdMatrix34 hmd, com.badlogic.gdx.math.Matrix4 mat)
    • getWidth Link icon

      public int getWidth()
    • getHeight Link icon

      public int getHeight()
    • getTrackerSpaceOriginToWorldSpaceTranslationOffset Link icon

      public com.badlogic.gdx.math.Vector3 getTrackerSpaceOriginToWorldSpaceTranslationOffset()
      Returns the tracker space to world space translation offset. All positional vectors returned by VRContext.VRDevice methods taking a VRContext.Space.World are multiplied offset by this vector. This allows offsetting VRContext.VRDevice positions and orientations in world space.
    • getTrackerSpaceToWorldspaceRotationOffset Link icon

      public com.badlogic.gdx.math.Matrix4 getTrackerSpaceToWorldspaceRotationOffset()
      Returns the tracker space to world space rotation offset. All rotational vectors returned by VRContext.VRDevice methods taking a VRContext.Space.World are rotated by this offset. This allows offsetting VRContext.VRDevice orientations in world space. The matrix needs to only have rotational components.
    • addListener Link icon

      public void addListener(VRDeviceListener listener)
      Adds a VRDeviceListener to receive events
    • removeListener Link icon

      public void removeListener(VRDeviceListener listener)
    • getDeviceByType Link icon

      public VRContext.VRDevice getDeviceByType(VRContext.VRDeviceType type)
      Returns:
      the first VRContext.VRDevice of the given VRContext.VRDeviceType or null.
    • getDevicesByType Link icon

      public com.badlogic.gdx.utils.Array<VRContext.VRDevice> getDevicesByType(VRContext.VRDeviceType type)
      Returns:
      all VRContext.VRDevice instances of the given VRContext.VRDeviceType.
    • getDevices Link icon

      public com.badlogic.gdx.utils.Array<VRContext.VRDevice> getDevices()
      Returns:
      all currently connected VRContext.VRDevice instances.
    • getControllerByRole Link icon

      public VRContext.VRDevice getControllerByRole(VRContext.VRControllerRole role)
      Returns:
      the VRContext.VRDevice of ype VRContext.VRDeviceType.Controller that matches the role, or null.
    • begin Link icon

      public void begin()
      Start rendering. Call beginEye to set up rendering for each individual eye. End rendering by calling #end
    • pollEvents Link icon

      public void pollEvents()
      Get the latest tracking data and send events to VRDeviceListener instance registered with the context.

      Must be called before begin!

    • dispose Link icon

      public void dispose()
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable