Class OpenVR

java.lang.Object
com.jme3.input.vr.openvr.OpenVR
All Implemented Interfaces:
VRAPI

public class OpenVR extends Object implements VRAPI
A class that wraps an OpenVR system.
  • Field Details

    • hmdTrackedDevicePoses

      protected TrackedDevicePose_t[] hmdTrackedDevicePoses
    • hmdErrorStore

      protected com.sun.jna.ptr.IntByReference hmdErrorStore
    • _tframeCount

      public static com.sun.jna.ptr.LongByReference _tframeCount
      The actual frame count.
    • poseMatrices

      protected Matrix4f[] poseMatrices
  • Constructor Details

    • OpenVR

      public OpenVR(VREnvironment environment)
      Create a new OpenVR system attached to the given VR environment.
      Parameters:
      environment - the VR environment to which this API is attached.
  • Method Details

    • convertSteamVRMatrix3ToMatrix4f

      public static Matrix4f convertSteamVRMatrix3ToMatrix4f(HmdMatrix34_t hmdMatrix, Matrix4f mat)
      Convert specific OpenVR HmdMatrix34_t into JME Matrix4f
      Parameters:
      hmdMatrix - the input matrix
      mat - the converted matrix
      Returns:
      the converted matrix
    • convertSteamVRMatrix4ToMatrix4f

      public static Matrix4f convertSteamVRMatrix4ToMatrix4f(HmdMatrix44_t hmdMatrix, Matrix4f mat)
      Convert specific OpenVR HmdMatrix34_t into JME Matrix4f
      Parameters:
      hmdMatrix - the input matrix
      mat - the converted matrix
      Returns:
      the converted matrix
    • getVRinput

      public OpenVRInput getVRinput()
      Description copied from interface: VRAPI
      Get the input provided by the underlying VR system.
      Specified by:
      getVRinput in interface VRAPI
      Returns:
      the input provided by the underlying VR system.
    • getVRSystem

      public VR_IVRSystem_FnTable getVRSystem()
      Description copied from interface: VRAPI
      Get the object that wraps natively the VR system.
      Specified by:
      getVRSystem in interface VRAPI
      Returns:
      the object that wraps natively the VR system.
    • getCompositor

      public VR_IVRCompositor_FnTable getCompositor()
      Description copied from interface: VRAPI
      Get the object that wraps natively the VR compositor.
      Specified by:
      getCompositor in interface VRAPI
      Returns:
      the object that wraps natively the VR system.
    • getTrackedCamera

      public VR_IVRTrackedCamera_FnTable getTrackedCamera()
    • getName

      public String getName()
      Description copied from interface: VRAPI
      Get the name of the underlying VR system.
      Specified by:
      getName in interface VRAPI
      Returns:
      the name of the underlying VR system.
    • setFlipEyes

      public void setFlipEyes(boolean set)
      Description copied from interface: VRAPI
      Flip the left and right eye.
      Specified by:
      setFlipEyes in interface VRAPI
      Parameters:
      set - true if the eyes has to be flipped and false otherwise.
    • printLatencyInfoToConsole

      public void printLatencyInfoToConsole(boolean set)
      Description copied from interface: VRAPI
      Set if latency information has to be logged.
      Specified by:
      printLatencyInfoToConsole in interface VRAPI
      Parameters:
      set - true if latency information has to be logged and false otherwise.
    • getDisplayFrequency

      public int getDisplayFrequency()
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) display frequency.
      Specified by:
      getDisplayFrequency in interface VRAPI
      Returns:
      the Head Mounted Device (HMD) display frequency.
    • initialize

      public boolean initialize()
      Description copied from interface: VRAPI
      Initialize this object from a VR system. All the native bindings to underlying VR system should be done within this method.
      Specified by:
      initialize in interface VRAPI
      Returns:
      true if the initialization is a success and false otherwise.
    • initVRCompositor

      public boolean initVRCompositor(boolean allowed)
      Description copied from interface: VRAPI
      Initialize the VR compositor that will be used for rendering.
      Specified by:
      initVRCompositor in interface VRAPI
      Parameters:
      allowed - true if the use of VR compositor is allowed and false otherwise.
      Returns:
      true if the initialization is a success and false otherwise.
    • initCamera

      public void initCamera(boolean allowed)
      Initialize the headset camera.
      Parameters:
      allowed - true is the use of the headset camera is allowed and false otherwise.
    • destroy

      public void destroy()
      Description copied from interface: VRAPI
      Close the link with underlying VR system and free all attached resources.
      Specified by:
      destroy in interface VRAPI
    • isInitialized

      public boolean isInitialized()
      Description copied from interface: VRAPI
      Check if the VR API is initialized.
      Specified by:
      isInitialized in interface VRAPI
      Returns:
      true if the VR API is initialized and false otherwise.
      See Also:
    • reset

      public void reset()
      Description copied from interface: VRAPI
      Reset the VR system. After a call to this method, the current position of the HMD should be the origin (i-e the observer without any combined transformation).
      Specified by:
      reset in interface VRAPI
    • getRenderSize

      public void getRenderSize(Vector2f store)
      Description copied from interface: VRAPI
      Get the size of a Head Mounted Device (HMD) rendering area in pixels.
      Specified by:
      getRenderSize in interface VRAPI
      Parameters:
      store - the size of a Head Mounted Device (HMD) rendering area in pixels (modified).
    • getInterpupillaryDistance

      public float getInterpupillaryDistance()
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) interpupilar distance in meters.
      Specified by:
      getInterpupillaryDistance in interface VRAPI
      Returns:
      the Head Mounted Device (HMD) interpupilar distance in meters.
    • getOrientation

      public Quaternion getOrientation()
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) orientation.
      Specified by:
      getOrientation in interface VRAPI
      Returns:
      the Head Mounted Device (HMD) orientation.
    • getPosition

      public Vector3f getPosition()
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) position.
      Specified by:
      getPosition in interface VRAPI
      Returns:
      the Head Mounted Device (HMD) orientation.
    • getPositionAndOrientation

      public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot)
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) position and orientation.
      Specified by:
      getPositionAndOrientation in interface VRAPI
      Parameters:
      storePos - the Head Mounted Device (HMD) position (modified).
      storeRot - the Head Mounted Device (HMD) rotation (modified).
    • updatePose

      public void updatePose()
      Description copied from interface: VRAPI
      Update Head Mounted Device (HMD) pose internal storage. This method should be called before other calls to HMD position/orientation access.
      Specified by:
      updatePose in interface VRAPI
    • getHMDMatrixProjectionLeftEye

      public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam)
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) left eye projection matrix.
      Specified by:
      getHMDMatrixProjectionLeftEye in interface VRAPI
      Parameters:
      cam - the camera attached to the left eye.
      Returns:
      the Head Mounted Device (HMD) left eye projection matrix.
    • getHMDMatrixProjectionRightEye

      public Matrix4f getHMDMatrixProjectionRightEye(Camera cam)
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) right eye projection matrix.
      Specified by:
      getHMDMatrixProjectionRightEye in interface VRAPI
      Parameters:
      cam - the camera attached to the right eye.
      Returns:
      the Head Mounted Device (HMD) right eye projection matrix.
    • getHMDVectorPoseLeftEye

      public Vector3f getHMDVectorPoseLeftEye()
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) left eye pose (position of the eye from the head) as a vector.
      Specified by:
      getHMDVectorPoseLeftEye in interface VRAPI
      Returns:
      the Head Mounted Device (HMD) left eye pose as a vector.
    • getHMDVectorPoseRightEye

      public Vector3f getHMDVectorPoseRightEye()
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) right eye pose (position of the eye from the head) as a vector.
      Specified by:
      getHMDVectorPoseRightEye in interface VRAPI
      Returns:
      the Head Mounted Device (HMD) right eye pose as a vector.
    • getSeatedToAbsolutePosition

      public Vector3f getSeatedToAbsolutePosition()
      Description copied from interface: VRAPI
      Get the seated to absolute position.
      Specified by:
      getSeatedToAbsolutePosition in interface VRAPI
      Returns:
      the seated to absolute position.
    • getHMDMatrixPoseLeftEye

      public Matrix4f getHMDMatrixPoseLeftEye()
      Description copied from interface: VRAPI
      Returns the transform between the view space and left eye space. Eye space is the per-eye flavor of view space that provides stereo disparity. Instead of Model * View * Projection the model is Model * View * Eye * Projection. Normally View and Eye will be multiplied together and treated as View. This matrix incorporates the user's interpupillary distance (IPD).
      Specified by:
      getHMDMatrixPoseLeftEye in interface VRAPI
      Returns:
      the transform between the view space and eye space.
    • getType

      public HmdType getType()
      Description copied from interface: VRAPI
      Get the Head Mounted Device (HMD) type.
      Specified by:
      getType in interface VRAPI
      Returns:
      the Head Mounted Device (HMD) type.
    • getHMDMatrixPoseRightEye

      public Matrix4f getHMDMatrixPoseRightEye()
      Description copied from interface: VRAPI
      Returns the transform between the view space and right eye space. Eye space is the per-eye flavor of view space that provides stereo disparity. Instead of Model * View * Projection the model is Model * View * Eye * Projection. Normally View and Eye will be multiplied together and treated as View. This matrix incorporates the user's interpupillary distance (IPD).
      Specified by:
      getHMDMatrixPoseRightEye in interface VRAPI
      Returns:
      the transform between the view space and eye space.