envrdevice.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. #ifdef GAME_TEMPLATE
  2. /**
  3. * \defgroup VRDeviceAPI generic and platform specific devices
  4. * @{
  5. */
  6. enum VRDeviceType
  7. {
  8. DEVICE_TYPE_OCULUS,
  9. DEVICE_TYPE_PS4
  10. }
  11. enum VRStatus
  12. {
  13. VR_STATUS_UNKNOWN, //< Unknown state, probably uninitialized.
  14. VR_STATUS_VISIBLE, //< The HMD is being used for rendering.
  15. VR_STATUS_PRESENT, //< The HMD port is open.
  16. VR_STATUS_MOUNTED, //< The HMD is mounted on users head.
  17. VR_STATUS_DISPLAY_LOST, //< The HMD was present and disappeared.
  18. VR_STATUS_SHOULD_QUIT, //< Application requested exit.
  19. VR_STATUS_SHOULD_RECENTER, //< The HMD Recenter request event was triggered.
  20. VR_STATUS_TRACKED, //< The tracking data for the HMD are up to date.
  21. VR_STATUS_CALIBRATING, //< The HMD is being calibrated.
  22. }
  23. enum VRHandEnum
  24. {
  25. VR_HAND_LEFT, //< HMD controller left hand.
  26. VR_HAND_RIGHT //< HMD controller right hand.
  27. }
  28. enum VREye
  29. {
  30. VR_EYE_LEFT, // HMD left eye.
  31. VR_EYE_RIGHT // HMD right eye.
  32. }
  33. /*!
  34. VRDevice interface common for all VR implementations.
  35. DO NOT INHERIT FROM THIS CLASS!
  36. */
  37. class VRDevice : Managed
  38. {
  39. /*!
  40. \brief returns VRDevice instance.
  41. \return device instance.
  42. */
  43. proto native static VRDevice GetInstance();
  44. /*!
  45. \brief returns status flags.
  46. \return current device state flags.
  47. */
  48. proto native VRStatus GetStatusFlags();
  49. /*!
  50. \brief returns device name.
  51. \return device brand name.
  52. */
  53. proto native owned string GetName();
  54. /*!
  55. \brief returns device type.
  56. \return device type enum.
  57. */
  58. proto native VRDeviceType GetDeviceType();
  59. /*!
  60. \brief Forces immediate head recenter.
  61. Uses the current scene position and orientation
  62. as the new camera origin.
  63. */
  64. proto native void RecenterHeadTracking();
  65. /*!
  66. \brief returns HMD head position .
  67. \return position in world space.
  68. */
  69. proto native vector GetHeadPosition();
  70. /*!
  71. \brief returns HMD head orientation.
  72. \return Euler angles in device space. (Yaw, Pitch, Roll)
  73. */
  74. proto native vector GetHeadOrientation();
  75. /*!
  76. \brief returns HMD controller's position.
  77. \param hand left/right hand enum.
  78. \return position in world space.
  79. */
  80. proto native vector GetHandPosition(VRHand hand);
  81. /*!
  82. \brief returns HMD controller's orientation.
  83. \param hand left/right hand enum.
  84. \return Euler angles in device space. (Yaw, Pitch, Roll)
  85. */
  86. proto native vector GetHandOrientation(VRHand hand);
  87. /*!
  88. \brief returns HMD Eye's position.
  89. \param eye left/right eye enum.
  90. \return position in world space.
  91. */
  92. proto native vector GetEyePosition(VREye eye);
  93. /*!
  94. \brief returns HMD Eye's orientation.
  95. \param eye left/right eye enum.
  96. \return Euler angles in device space. (Yaw, Pitch, Roll)
  97. */
  98. proto native vector GetEyeOrientation(VREye eye);
  99. /*!
  100. \brief Sets up current vr scale.
  101. All translations will get scaled by this value.
  102. With higher scale values will the world around look smaller.
  103. "Warning: The tracking errors will render more visible with high scale."
  104. \param scale the scale amount.
  105. */
  106. proto native void SetScale(float scale);
  107. /*!
  108. \brief returns current vr scale.
  109. \return the scale amount.
  110. */
  111. proto native float GetScale();
  112. /*!
  113. \brief returns current FOV's tangent values.
  114. In VR mode the FOV should be asymmetric.
  115. \returns tangent values of asymetric FOV.
  116. */
  117. proto external void GetEyeFOV(VREye eye, out float leftTan, out float rightTan, out float upTan, out float downTan);
  118. };
  119. enum PSVrHeadRecenterFlagsEnum
  120. {
  121. VR_RECENTER_POSITION,
  122. VR_RECENTER_ORIENTATION
  123. }
  124. enum PSVrBrightnessRiskEnum
  125. {
  126. VR_BRIGHTNESS_RISK_LOW,
  127. VR_BRIGHTNESS_RISK_HIGH,
  128. VR_BRIGHTNESS_RISK_MAX
  129. }
  130. enum PSVrTrackingQualityEnum
  131. {
  132. VR_TRACKING_QUALITY_NONE,
  133. VR_TRACKING_QUALITY_NOT_VISIBLE,
  134. VR_TRACKING_QUALITY_PARTIAL,
  135. VR_TRACKING_QUALITY_FULL
  136. }
  137. enum PSVrDialogStatusEnum
  138. {
  139. VR_DIALOG_UNKNOWN,
  140. VR_DIALOG_OK,
  141. VR_DIALOG_CANCELED,
  142. VR_DIALOG_RUNNING
  143. }
  144. /*!
  145. PS4 specific VR interface.
  146. */
  147. class VRDevice_PS4 : VRDevice
  148. {
  149. /*!
  150. \brief Switches VR device into 2D "theater" mode.
  151. Don't forget to set appropriate FOV.
  152. At the moment the device uses the render targets of the
  153. left eye. These render targets are 8:9 and we are still rendering
  154. both eyes. If the feature gets used in a actual gameplay we can
  155. extend it to separate set of 16:9 render targets.
  156. \param enabled enable/disable flag.
  157. */
  158. proto native void Set2D(bool enabled);
  159. /*!
  160. \brief Pops up HMD service dialog.
  161. \return true when dialog was opened and his state was resolved as OK.
  162. */
  163. proto native bool ShowHmdServiceDialog();
  164. /*!
  165. \brief Pops up HMD setup dialog.
  166. \return true when dialog was opened and closed successfully.
  167. */
  168. proto native bool ShowHmdSetupDialog();
  169. /*!
  170. \brief Returns current setup dialog state.
  171. \return dialog state enum.
  172. */
  173. proto native PSVrDialogStatusEnum GetSetupDialogStatus();
  174. /*!
  175. \brief Returns current service dialog state.
  176. \return dialog state enum.
  177. */
  178. proto native PSVrDialogStatusEnum GetServiceDialogStatus();
  179. /*!
  180. \brief HMD recentering hint flags setup.
  181. */
  182. proto native void SetRecenterHeadFlags(PSVrHeadRecenterFlagsEnum flags);
  183. /*!
  184. \brief Returns HMD recentering flags.
  185. \return recentering enum.
  186. */
  187. proto native PSVrHeadRecenterFlagsEnum GetRecenterHeadFlags();
  188. /*!
  189. \brief Returns the eye offset in device space.
  190. \return 3D position centered around device space center.
  191. */
  192. proto native vector GetEyeOffset(VREye eye);
  193. /*!
  194. \brief Sets up the minimal displayable color.
  195. Setup this value when smears start appearing in
  196. dark environments.
  197. */
  198. proto native void SetMinOutputColor(int color);
  199. /*!
  200. \brief Per eye FOV setup.
  201. Keep in mind that changing the values from device presets
  202. may cause user discomfort.
  203. */
  204. proto native void SetEyeFOV(VREye eye, float leftTan, float rightTan, float upTan, float downTan);
  205. /*!
  206. \brief Resets the FOV settings to device preset value.
  207. */
  208. proto native void ResetToDeviceFOV(VREye eye);
  209. /*!
  210. \brief Sets up the render target size multiplier.
  211. Set this value before the device gets initialized.
  212. */
  213. proto native void SetOversamplingFactor(float factor);
  214. /*!
  215. \brief Returns HMD tracking status.
  216. \param bRisk tracked scene brightness risk.
  217. \param posQuality precision of the HMD position.
  218. \param orQuality precision of tthe HMD orientation.
  219. \return false when the HMD port is not open.
  220. */
  221. proto bool GetHmdTrackingStatus( out PSVrBrightnessRiskEnum bRisk,
  222. out PSVrTrackingQualityEnum posQuality,
  223. out PSVrTrackingQualityEnum orQuality);
  224. /*!
  225. \brief Returns Move controller tracking status.
  226. \param hand identifier of the contoller.
  227. \param bRisk tracked scene brightness risk.
  228. \param posQuality precision of the controllers position.
  229. \param orQuality precision of the controllers orientation.
  230. \return false when the Move port is not open.
  231. */
  232. proto bool GetMoveTrackingStatus( VRHand hand,
  233. out PSVrBrightnessRiskEnum bRisk,
  234. out PSVrTrackingQualityEnum posQuality,
  235. out PSVrTrackingQualityEnum orQuality);
  236. }
  237. /*!
  238. Oculus specific VR interface.
  239. */
  240. class Oculus : VRDevice
  241. {
  242. // TODO:
  243. }
  244. /*
  245. * @}
  246. */
  247. #endif