VRAPI.java 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package com.jme3.input.vr;
  7. import com.jme3.math.Matrix4f;
  8. import com.jme3.math.Quaternion;
  9. import com.jme3.math.Vector2f;
  10. import com.jme3.math.Vector3f;
  11. import com.jme3.renderer.Camera;
  12. /**
  13. * An interface that represents a VR system. This interface has to be implemented in order to wrap underlying VR system (OpenVR, OSVR, ...)
  14. * @author reden - phr00t - https://github.com/phr00t
  15. * @author Julien Seinturier - (c) 2016 - JOrigin project - <a href="http://www.jorigin.org">http:/www.jorigin.org</a>
  16. */
  17. public interface VRAPI {
  18. /**
  19. * Initialize this object from a VR system. All the native bindings to underlying VR system should be done within this method.
  20. * @return <code>true</code> if the initialization is a success and <code>false</code> otherwise.
  21. */
  22. public boolean initialize();
  23. /**
  24. * Initialize the VR compositor that will be used for rendering.
  25. * @param allowed <code>true</code> if the use of VR compositor is allowed and <code>false</code> otherwise.
  26. * @return <code>true</code> if the initialization is a success and <code>false</code> otherwise.
  27. */
  28. public boolean initVRCompositor(boolean allowed);
  29. /**
  30. * Get the object that wraps natively the VR system.
  31. * @return the object that wraps natively the VR system.
  32. */
  33. public Object getVRSystem();
  34. /**
  35. * Get the object that wraps natively the VR compositor.
  36. * @return the object that wraps natively the VR system.
  37. */
  38. public Object getCompositor();
  39. /**
  40. * Get the name of the underlying VR system.
  41. * @return the name of the underlying VR system.
  42. */
  43. public String getName();
  44. /**
  45. * Get the input provided by the underlying VR system.
  46. * @return the input provided by the underlying VR system.
  47. */
  48. public VRInputAPI getVRinput();
  49. /**
  50. * Flip the left and right eye..
  51. * @param set <code>true</code> if the eyes has to be flipped and <code>false</code> otherwise.
  52. */
  53. public void setFlipEyes(boolean set);
  54. /**
  55. * Set if latency information has to be logged.
  56. * @param set <code>true</code> if latency information has to be logged and <code>false</code> otherwise.
  57. */
  58. public void printLatencyInfoToConsole(boolean set);
  59. /**
  60. * Get the Head Mounted Device (HMD) display frequency.
  61. * @return the Head Mounted DEvice (HMD) display frequency.
  62. */
  63. public int getDisplayFrequency();
  64. /**
  65. * Close the link with underlying VR system and free all attached resources.
  66. */
  67. public void destroy();
  68. /**
  69. * Check if the VR API is initialized.
  70. * @return <code>true</code> if the VR API is initialized and <code>false</code> otherwise.
  71. * @see #initialize()
  72. */
  73. public boolean isInitialized();
  74. /**
  75. * Reset (recenter) the VR system. The current position of the HMD is
  76. * now considered the origin (observer+[0,0,0]).
  77. */
  78. public void reset();
  79. /**
  80. * Get the size of an Head Mounted Device (HMD) rendering area in pixels.
  81. * @param store the size of an Head Mounted Device (HMD) rendering area in pixels (modified).
  82. */
  83. public void getRenderSize(Vector2f store);
  84. //public float getFOV(int dir);
  85. /**
  86. * Get the Head Mounted Device (HMD) interpupilar distance in meters.
  87. * @return the Head Mounted Device (HMD) interpupilar distance in meters.
  88. */
  89. public float getInterpupillaryDistance();
  90. /**
  91. * Get the Head Mounted Device (HMD) orientation.
  92. * @return the Head Mounted Device (HMD) orientation.
  93. */
  94. public Quaternion getOrientation();
  95. /**
  96. * Get the Head Mounted Device (HMD) position.
  97. * @return the Head Mounted Device (HMD) orientation.
  98. */
  99. public Vector3f getPosition();
  100. /**
  101. * Get the Head Mounted Device (HMD) position and orientation.
  102. * @param storePos the Head Mounted Device (HMD) position (modified).
  103. * @param storeRot the Head Mounted Device (HMD) rotation (modified).
  104. */
  105. public void getPositionAndOrientation(Vector3f storePos, Quaternion storeRot);
  106. /**
  107. * Update Head Mounted Device (HMD) pose internal storage. This method should be called before other calls to HMD position/orientation access.
  108. */
  109. public void updatePose();
  110. /**
  111. * Get the Head Mounted Device (HMD) left eye projection matrix.
  112. * @param cam the camera attached to the left eye.
  113. * @return the Head Mounted Device (HMD) left eye projection matrix.
  114. */
  115. public Matrix4f getHMDMatrixProjectionLeftEye(Camera cam);
  116. /**
  117. * Get the Head Mounted Device (HMD) right eye projection matrix.
  118. * @param cam the camera attached to the right eye.
  119. * @return the Head Mounted Device (HMD) right eye projection matrix.
  120. */
  121. public Matrix4f getHMDMatrixProjectionRightEye(Camera cam);
  122. /**
  123. * Get the Head Mounted Device (HMD) left eye pose (position of the eye from the head) as a {@link Vector3f vector}.
  124. * @return the Head Mounted Device (HMD) left eye pose as a {@link Vector3f vector}.
  125. */
  126. public Vector3f getHMDVectorPoseLeftEye();
  127. /**
  128. * Get the Head Mounted Device (HMD) right eye pose (position of the eye from the head) as a {@link Vector3f vector}.
  129. * @return the Head Mounted Device (HMD) right eye pose as a {@link Vector3f vector}.
  130. */
  131. public Vector3f getHMDVectorPoseRightEye();
  132. /**
  133. * Returns the transform between the view space and left eye space.
  134. * Eye space is the per-eye flavor of view space that provides stereo disparity.
  135. * Instead of Model * View * Projection the model is Model * View * Eye * Projection.
  136. * Normally View and Eye will be multiplied together and treated as View.
  137. * This matrix incorporates the user's interpupillary distance (IPD).
  138. * @return the transform between the view space and eye space.
  139. */
  140. public Matrix4f getHMDMatrixPoseLeftEye();
  141. /**
  142. * Returns the transform between the view space and right eye space.
  143. * Eye space is the per-eye flavor of view space that provides stereo disparity.
  144. * Instead of Model * View * Projection the model is Model * View * Eye * Projection.
  145. * Normally View and Eye will be multiplied together and treated as View.
  146. * This matrix incorporates the user's interpupillary distance (IPD).
  147. * @return the transform between the view space and eye space.
  148. */
  149. public Matrix4f getHMDMatrixPoseRightEye();
  150. /**
  151. * Get the Head Mounted Device (HMD) type.
  152. * @return the Head Mounted Device (HMD) type.
  153. */
  154. public HmdType getType();
  155. /**
  156. * Get the seated to absolute position.
  157. * @return the seated to absolute position.
  158. */
  159. public Vector3f getSeatedToAbsolutePosition();
  160. }