class_xrinterface.rst 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.0/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.0/doc/classes/XRInterface.xml.
  6. .. _class_XRInterface:
  7. XRInterface
  8. ===========
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`MobileVRInterface<class_MobileVRInterface>`, :ref:`OpenXRInterface<class_OpenXRInterface>`, :ref:`WebXRInterface<class_WebXRInterface>`, :ref:`XRInterfaceExtension<class_XRInterfaceExtension>`
  11. Base class for an XR interface implementation.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. This class needs to be implemented to make an AR or VR platform available to Godot and these should be implemented as C++ modules or GDExtension modules. Part of the interface is exposed to GDScript so you can detect, enable and configure an AR or VR platform.
  16. Interfaces should be written in such a way that simply enabling them will give us a working setup. You can query the available interfaces through :ref:`XRServer<class_XRServer>`.
  17. .. rst-class:: classref-introduction-group
  18. Tutorials
  19. ---------
  20. - :doc:`XR documentation index <../tutorials/xr/index>`
  21. .. rst-class:: classref-reftable-group
  22. Properties
  23. ----------
  24. .. table::
  25. :widths: auto
  26. +----------------------------------------------------+--------------------------------------------------------------------------------------------------+-----------+
  27. | :ref:`bool<class_bool>` | :ref:`ar_is_anchor_detection_enabled<class_XRInterface_property_ar_is_anchor_detection_enabled>` | ``false`` |
  28. +----------------------------------------------------+--------------------------------------------------------------------------------------------------+-----------+
  29. | :ref:`bool<class_bool>` | :ref:`interface_is_primary<class_XRInterface_property_interface_is_primary>` | ``false`` |
  30. +----------------------------------------------------+--------------------------------------------------------------------------------------------------+-----------+
  31. | :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` | :ref:`xr_play_area_mode<class_XRInterface_property_xr_play_area_mode>` | ``0`` |
  32. +----------------------------------------------------+--------------------------------------------------------------------------------------------------+-----------+
  33. .. rst-class:: classref-reftable-group
  34. Methods
  35. -------
  36. .. table::
  37. :widths: auto
  38. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`get_camera_feed_id<class_XRInterface_method_get_camera_feed_id>` **(** **)** |
  40. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`int<class_int>` | :ref:`get_capabilities<class_XRInterface_method_get_capabilities>` **(** **)** |const| |
  42. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`StringName<class_StringName>` | :ref:`get_name<class_XRInterface_method_get_name>` **(** **)** |const| |
  44. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`PackedVector3Array<class_PackedVector3Array>` | :ref:`get_play_area<class_XRInterface_method_get_play_area>` **(** **)** |const| |
  46. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`Projection<class_Projection>` | :ref:`get_projection_for_view<class_XRInterface_method_get_projection_for_view>` **(** :ref:`int<class_int>` view, :ref:`float<class_float>` aspect, :ref:`float<class_float>` near, :ref:`float<class_float>` far **)** |
  48. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`Vector2<class_Vector2>` | :ref:`get_render_target_size<class_XRInterface_method_get_render_target_size>` **(** **)** |
  50. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Array<class_Array>` | :ref:`get_supported_environment_blend_modes<class_XRInterface_method_get_supported_environment_blend_modes>` **(** **)** |
  52. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`TrackingStatus<enum_XRInterface_TrackingStatus>` | :ref:`get_tracking_status<class_XRInterface_method_get_tracking_status>` **(** **)** |const| |
  54. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`Transform3D<class_Transform3D>` | :ref:`get_transform_for_view<class_XRInterface_method_get_transform_for_view>` **(** :ref:`int<class_int>` view, :ref:`Transform3D<class_Transform3D>` cam_transform **)** |
  56. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`get_view_count<class_XRInterface_method_get_view_count>` **(** **)** |
  58. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`bool<class_bool>` | :ref:`initialize<class_XRInterface_method_initialize>` **(** **)** |
  60. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`bool<class_bool>` | :ref:`is_initialized<class_XRInterface_method_is_initialized>` **(** **)** |const| |
  62. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`bool<class_bool>` | :ref:`is_passthrough_enabled<class_XRInterface_method_is_passthrough_enabled>` **(** **)** |
  64. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`bool<class_bool>` | :ref:`is_passthrough_supported<class_XRInterface_method_is_passthrough_supported>` **(** **)** |
  66. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`bool<class_bool>` | :ref:`set_environment_blend_mode<class_XRInterface_method_set_environment_blend_mode>` **(** :ref:`EnvironmentBlendMode<enum_XRInterface_EnvironmentBlendMode>` mode **)** |
  68. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`bool<class_bool>` | :ref:`set_play_area_mode<class_XRInterface_method_set_play_area_mode>` **(** :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` mode **)** |
  70. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`bool<class_bool>` | :ref:`start_passthrough<class_XRInterface_method_start_passthrough>` **(** **)** |
  72. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | void | :ref:`stop_passthrough<class_XRInterface_method_stop_passthrough>` **(** **)** |
  74. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`bool<class_bool>` | :ref:`supports_play_area_mode<class_XRInterface_method_supports_play_area_mode>` **(** :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` mode **)** |
  76. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | void | :ref:`trigger_haptic_pulse<class_XRInterface_method_trigger_haptic_pulse>` **(** :ref:`String<class_String>` action_name, :ref:`StringName<class_StringName>` tracker_name, :ref:`float<class_float>` frequency, :ref:`float<class_float>` amplitude, :ref:`float<class_float>` duration_sec, :ref:`float<class_float>` delay_sec **)** |
  78. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`uninitialize<class_XRInterface_method_uninitialize>` **(** **)** |
  80. +--------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. .. rst-class:: classref-section-separator
  82. ----
  83. .. rst-class:: classref-descriptions-group
  84. Signals
  85. -------
  86. .. _class_XRInterface_signal_play_area_changed:
  87. .. rst-class:: classref-signal
  88. **play_area_changed** **(** :ref:`int<class_int>` mode **)**
  89. Emitted when the play area is changed. This can be a result of the player resetting the boundary or entering a new play area, the player changing the play area mode, the world scale changing or the player resetting their headset orientation.
  90. .. rst-class:: classref-section-separator
  91. ----
  92. .. rst-class:: classref-descriptions-group
  93. Enumerations
  94. ------------
  95. .. _enum_XRInterface_Capabilities:
  96. .. rst-class:: classref-enumeration
  97. enum **Capabilities**:
  98. .. _class_XRInterface_constant_XR_NONE:
  99. .. rst-class:: classref-enumeration-constant
  100. :ref:`Capabilities<enum_XRInterface_Capabilities>` **XR_NONE** = ``0``
  101. No XR capabilities.
  102. .. _class_XRInterface_constant_XR_MONO:
  103. .. rst-class:: classref-enumeration-constant
  104. :ref:`Capabilities<enum_XRInterface_Capabilities>` **XR_MONO** = ``1``
  105. This interface can work with normal rendering output (non-HMD based AR).
  106. .. _class_XRInterface_constant_XR_STEREO:
  107. .. rst-class:: classref-enumeration-constant
  108. :ref:`Capabilities<enum_XRInterface_Capabilities>` **XR_STEREO** = ``2``
  109. This interface supports stereoscopic rendering.
  110. .. _class_XRInterface_constant_XR_QUAD:
  111. .. rst-class:: classref-enumeration-constant
  112. :ref:`Capabilities<enum_XRInterface_Capabilities>` **XR_QUAD** = ``4``
  113. This interface supports quad rendering (not yet supported by Godot).
  114. .. _class_XRInterface_constant_XR_VR:
  115. .. rst-class:: classref-enumeration-constant
  116. :ref:`Capabilities<enum_XRInterface_Capabilities>` **XR_VR** = ``8``
  117. This interface supports VR.
  118. .. _class_XRInterface_constant_XR_AR:
  119. .. rst-class:: classref-enumeration-constant
  120. :ref:`Capabilities<enum_XRInterface_Capabilities>` **XR_AR** = ``16``
  121. This interface supports AR (video background and real world tracking).
  122. .. _class_XRInterface_constant_XR_EXTERNAL:
  123. .. rst-class:: classref-enumeration-constant
  124. :ref:`Capabilities<enum_XRInterface_Capabilities>` **XR_EXTERNAL** = ``32``
  125. This interface outputs to an external device. If the main viewport is used, the on screen output is an unmodified buffer of either the left or right eye (stretched if the viewport size is not changed to the same aspect ratio of :ref:`get_render_target_size<class_XRInterface_method_get_render_target_size>`). Using a separate viewport node frees up the main viewport for other purposes.
  126. .. rst-class:: classref-item-separator
  127. ----
  128. .. _enum_XRInterface_TrackingStatus:
  129. .. rst-class:: classref-enumeration
  130. enum **TrackingStatus**:
  131. .. _class_XRInterface_constant_XR_NORMAL_TRACKING:
  132. .. rst-class:: classref-enumeration-constant
  133. :ref:`TrackingStatus<enum_XRInterface_TrackingStatus>` **XR_NORMAL_TRACKING** = ``0``
  134. Tracking is behaving as expected.
  135. .. _class_XRInterface_constant_XR_EXCESSIVE_MOTION:
  136. .. rst-class:: classref-enumeration-constant
  137. :ref:`TrackingStatus<enum_XRInterface_TrackingStatus>` **XR_EXCESSIVE_MOTION** = ``1``
  138. Tracking is hindered by excessive motion (the player is moving faster than tracking can keep up).
  139. .. _class_XRInterface_constant_XR_INSUFFICIENT_FEATURES:
  140. .. rst-class:: classref-enumeration-constant
  141. :ref:`TrackingStatus<enum_XRInterface_TrackingStatus>` **XR_INSUFFICIENT_FEATURES** = ``2``
  142. Tracking is hindered by insufficient features, it's too dark (for camera-based tracking), player is blocked, etc.
  143. .. _class_XRInterface_constant_XR_UNKNOWN_TRACKING:
  144. .. rst-class:: classref-enumeration-constant
  145. :ref:`TrackingStatus<enum_XRInterface_TrackingStatus>` **XR_UNKNOWN_TRACKING** = ``3``
  146. We don't know the status of the tracking or this interface does not provide feedback.
  147. .. _class_XRInterface_constant_XR_NOT_TRACKING:
  148. .. rst-class:: classref-enumeration-constant
  149. :ref:`TrackingStatus<enum_XRInterface_TrackingStatus>` **XR_NOT_TRACKING** = ``4``
  150. Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.).
  151. .. rst-class:: classref-item-separator
  152. ----
  153. .. _enum_XRInterface_PlayAreaMode:
  154. .. rst-class:: classref-enumeration
  155. enum **PlayAreaMode**:
  156. .. _class_XRInterface_constant_XR_PLAY_AREA_UNKNOWN:
  157. .. rst-class:: classref-enumeration-constant
  158. :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` **XR_PLAY_AREA_UNKNOWN** = ``0``
  159. Play area mode not set or not available.
  160. .. _class_XRInterface_constant_XR_PLAY_AREA_3DOF:
  161. .. rst-class:: classref-enumeration-constant
  162. :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` **XR_PLAY_AREA_3DOF** = ``1``
  163. Play area only supports orientation tracking, no positional tracking, area will center around player.
  164. .. _class_XRInterface_constant_XR_PLAY_AREA_SITTING:
  165. .. rst-class:: classref-enumeration-constant
  166. :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` **XR_PLAY_AREA_SITTING** = ``2``
  167. Player is in seated position, limited positional tracking, fixed guardian around player.
  168. .. _class_XRInterface_constant_XR_PLAY_AREA_ROOMSCALE:
  169. .. rst-class:: classref-enumeration-constant
  170. :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` **XR_PLAY_AREA_ROOMSCALE** = ``3``
  171. Player is free to move around, full positional tracking.
  172. .. _class_XRInterface_constant_XR_PLAY_AREA_STAGE:
  173. .. rst-class:: classref-enumeration-constant
  174. :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` **XR_PLAY_AREA_STAGE** = ``4``
  175. Same as :ref:`XR_PLAY_AREA_ROOMSCALE<class_XRInterface_constant_XR_PLAY_AREA_ROOMSCALE>` but origin point is fixed to the center of the physical space, :ref:`XRServer.center_on_hmd<class_XRServer_method_center_on_hmd>` disabled.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. _enum_XRInterface_EnvironmentBlendMode:
  179. .. rst-class:: classref-enumeration
  180. enum **EnvironmentBlendMode**:
  181. .. _class_XRInterface_constant_XR_ENV_BLEND_MODE_OPAQUE:
  182. .. rst-class:: classref-enumeration-constant
  183. :ref:`EnvironmentBlendMode<enum_XRInterface_EnvironmentBlendMode>` **XR_ENV_BLEND_MODE_OPAQUE** = ``0``
  184. Opaque blend mode. This is typically used for VR devices.
  185. .. _class_XRInterface_constant_XR_ENV_BLEND_MODE_ADDITIVE:
  186. .. rst-class:: classref-enumeration-constant
  187. :ref:`EnvironmentBlendMode<enum_XRInterface_EnvironmentBlendMode>` **XR_ENV_BLEND_MODE_ADDITIVE** = ``1``
  188. Additive blend mode. This is typically used for AR devices or VR devices with passthrough.
  189. .. _class_XRInterface_constant_XR_ENV_BLEND_MODE_ALPHA_BLEND:
  190. .. rst-class:: classref-enumeration-constant
  191. :ref:`EnvironmentBlendMode<enum_XRInterface_EnvironmentBlendMode>` **XR_ENV_BLEND_MODE_ALPHA_BLEND** = ``2``
  192. Alpha blend mode. This is typically used for AR or VR devices with passthrough capabilities. The alpha channel controls how much of the passthrough is visible. Alpha of 0.0 means the passthrough is visible and this pixel works in ADDITIVE mode. Alpha of 1.0 means that the passthrough is not visible and this pixel works in OPAQUE mode.
  193. .. rst-class:: classref-section-separator
  194. ----
  195. .. rst-class:: classref-descriptions-group
  196. Property Descriptions
  197. ---------------------
  198. .. _class_XRInterface_property_ar_is_anchor_detection_enabled:
  199. .. rst-class:: classref-property
  200. :ref:`bool<class_bool>` **ar_is_anchor_detection_enabled** = ``false``
  201. .. rst-class:: classref-property-setget
  202. - void **set_anchor_detection_is_enabled** **(** :ref:`bool<class_bool>` value **)**
  203. - :ref:`bool<class_bool>` **get_anchor_detection_is_enabled** **(** **)**
  204. On an AR interface, ``true`` if anchor detection is enabled.
  205. .. rst-class:: classref-item-separator
  206. ----
  207. .. _class_XRInterface_property_interface_is_primary:
  208. .. rst-class:: classref-property
  209. :ref:`bool<class_bool>` **interface_is_primary** = ``false``
  210. .. rst-class:: classref-property-setget
  211. - void **set_primary** **(** :ref:`bool<class_bool>` value **)**
  212. - :ref:`bool<class_bool>` **is_primary** **(** **)**
  213. ``true`` if this is the primary interface.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_XRInterface_property_xr_play_area_mode:
  217. .. rst-class:: classref-property
  218. :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` **xr_play_area_mode** = ``0``
  219. .. rst-class:: classref-property-setget
  220. - :ref:`bool<class_bool>` **set_play_area_mode** **(** :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` mode **)**
  221. - :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` **get_play_area_mode** **(** **)**
  222. The play area mode for this interface.
  223. .. rst-class:: classref-section-separator
  224. ----
  225. .. rst-class:: classref-descriptions-group
  226. Method Descriptions
  227. -------------------
  228. .. _class_XRInterface_method_get_camera_feed_id:
  229. .. rst-class:: classref-method
  230. :ref:`int<class_int>` **get_camera_feed_id** **(** **)**
  231. If this is an AR interface that requires displaying a camera feed as the background, this method returns the feed ID in the :ref:`CameraServer<class_CameraServer>` for this interface.
  232. .. rst-class:: classref-item-separator
  233. ----
  234. .. _class_XRInterface_method_get_capabilities:
  235. .. rst-class:: classref-method
  236. :ref:`int<class_int>` **get_capabilities** **(** **)** |const|
  237. Returns a combination of :ref:`Capabilities<enum_XRInterface_Capabilities>` flags providing information about the capabilities of this interface.
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_XRInterface_method_get_name:
  241. .. rst-class:: classref-method
  242. :ref:`StringName<class_StringName>` **get_name** **(** **)** |const|
  243. Returns the name of this interface (OpenXR, OpenVR, OpenHMD, ARKit, etc).
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_XRInterface_method_get_play_area:
  247. .. rst-class:: classref-method
  248. :ref:`PackedVector3Array<class_PackedVector3Array>` **get_play_area** **(** **)** |const|
  249. Returns an array of vectors that denotes the physical play area mapped to the virtual space around the :ref:`XROrigin3D<class_XROrigin3D>` point. The points form a convex polygon that can be used to react to or visualize the play area. This returns an empty array if this feature is not supported or if the information is not yet available.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_XRInterface_method_get_projection_for_view:
  253. .. rst-class:: classref-method
  254. :ref:`Projection<class_Projection>` **get_projection_for_view** **(** :ref:`int<class_int>` view, :ref:`float<class_float>` aspect, :ref:`float<class_float>` near, :ref:`float<class_float>` far **)**
  255. Returns the projection matrix for a view/eye.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_XRInterface_method_get_render_target_size:
  259. .. rst-class:: classref-method
  260. :ref:`Vector2<class_Vector2>` **get_render_target_size** **(** **)**
  261. Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_XRInterface_method_get_supported_environment_blend_modes:
  265. .. rst-class:: classref-method
  266. :ref:`Array<class_Array>` **get_supported_environment_blend_modes** **(** **)**
  267. Returns the an array of supported environment blend modes, see :ref:`EnvironmentBlendMode<enum_XRInterface_EnvironmentBlendMode>`.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_XRInterface_method_get_tracking_status:
  271. .. rst-class:: classref-method
  272. :ref:`TrackingStatus<enum_XRInterface_TrackingStatus>` **get_tracking_status** **(** **)** |const|
  273. If supported, returns the status of our tracking. This will allow you to provide feedback to the user whether there are issues with positional tracking.
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_XRInterface_method_get_transform_for_view:
  277. .. rst-class:: classref-method
  278. :ref:`Transform3D<class_Transform3D>` **get_transform_for_view** **(** :ref:`int<class_int>` view, :ref:`Transform3D<class_Transform3D>` cam_transform **)**
  279. Returns the transform for a view/eye.
  280. \ ``view`` is the view/eye index.
  281. \ ``cam_transform`` is the transform that maps device coordinates to scene coordinates, typically the :ref:`Node3D.global_transform<class_Node3D_property_global_transform>` of the current XROrigin3D.
  282. .. rst-class:: classref-item-separator
  283. ----
  284. .. _class_XRInterface_method_get_view_count:
  285. .. rst-class:: classref-method
  286. :ref:`int<class_int>` **get_view_count** **(** **)**
  287. Returns the number of views that need to be rendered for this device. 1 for Monoscopic, 2 for Stereoscopic.
  288. .. rst-class:: classref-item-separator
  289. ----
  290. .. _class_XRInterface_method_initialize:
  291. .. rst-class:: classref-method
  292. :ref:`bool<class_bool>` **initialize** **(** **)**
  293. Call this to initialize this interface. The first interface that is initialized is identified as the primary interface and it will be used for rendering output.
  294. After initializing the interface you want to use you then need to enable the AR/VR mode of a viewport and rendering should commence.
  295. \ **Note:** You must enable the XR mode on the main viewport for any device that uses the main output of Godot, such as for mobile VR.
  296. If you do this for a platform that handles its own output (such as OpenVR) Godot will show just one eye without distortion on screen. Alternatively, you can add a separate viewport node to your scene and enable AR/VR on that viewport. It will be used to output to the HMD, leaving you free to do anything you like in the main window, such as using a separate camera as a spectator camera or rendering something completely different.
  297. While currently not used, you can activate additional interfaces. You may wish to do this if you want to track controllers from other platforms. However, at this point in time only one interface can render to an HMD.
  298. .. rst-class:: classref-item-separator
  299. ----
  300. .. _class_XRInterface_method_is_initialized:
  301. .. rst-class:: classref-method
  302. :ref:`bool<class_bool>` **is_initialized** **(** **)** |const|
  303. Is ``true`` if this interface has been initialized.
  304. .. rst-class:: classref-item-separator
  305. ----
  306. .. _class_XRInterface_method_is_passthrough_enabled:
  307. .. rst-class:: classref-method
  308. :ref:`bool<class_bool>` **is_passthrough_enabled** **(** **)**
  309. Is ``true`` if passthrough is enabled.
  310. .. rst-class:: classref-item-separator
  311. ----
  312. .. _class_XRInterface_method_is_passthrough_supported:
  313. .. rst-class:: classref-method
  314. :ref:`bool<class_bool>` **is_passthrough_supported** **(** **)**
  315. Is ``true`` if this interface supports passthrough.
  316. .. rst-class:: classref-item-separator
  317. ----
  318. .. _class_XRInterface_method_set_environment_blend_mode:
  319. .. rst-class:: classref-method
  320. :ref:`bool<class_bool>` **set_environment_blend_mode** **(** :ref:`EnvironmentBlendMode<enum_XRInterface_EnvironmentBlendMode>` mode **)**
  321. Sets the active environment blend mode.
  322. \ ``mode`` is the :ref:`EnvironmentBlendMode<enum_XRInterface_EnvironmentBlendMode>` starting with the next frame.
  323. \ **Note:** Not all runtimes support all environment blend modes, so it is important to check this at startup. For example:
  324. ::
  325. func _ready():
  326. var xr_interface: XRInterface = XRServer.find_interface("OpenXR")
  327. if xr_interface and xr_interface.is_initialized():
  328. var vp: Viewport = get_viewport()
  329. vp.use_xr = true
  330. var acceptable_modes = [ XRInterface.XR_ENV_BLEND_MODE_OPAQUE, XRInterface.XR_ENV_BLEND_MODE_ADDITIVE ]
  331. var modes = xr_interface.get_supported_environment_blend_modes()
  332. for mode in acceptable_modes:
  333. if mode in modes:
  334. xr_interface.set_environment_blend_mode(mode)
  335. break
  336. .. rst-class:: classref-item-separator
  337. ----
  338. .. _class_XRInterface_method_set_play_area_mode:
  339. .. rst-class:: classref-method
  340. :ref:`bool<class_bool>` **set_play_area_mode** **(** :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` mode **)**
  341. Sets the active play area mode, will return ``false`` if the mode can't be used with this interface.
  342. .. rst-class:: classref-item-separator
  343. ----
  344. .. _class_XRInterface_method_start_passthrough:
  345. .. rst-class:: classref-method
  346. :ref:`bool<class_bool>` **start_passthrough** **(** **)**
  347. Starts passthrough, will return ``false`` if passthrough couldn't be started.
  348. \ **Note:** The viewport used for XR must have a transparent background, otherwise passthrough may not properly render.
  349. .. rst-class:: classref-item-separator
  350. ----
  351. .. _class_XRInterface_method_stop_passthrough:
  352. .. rst-class:: classref-method
  353. void **stop_passthrough** **(** **)**
  354. Stops passthrough.
  355. .. rst-class:: classref-item-separator
  356. ----
  357. .. _class_XRInterface_method_supports_play_area_mode:
  358. .. rst-class:: classref-method
  359. :ref:`bool<class_bool>` **supports_play_area_mode** **(** :ref:`PlayAreaMode<enum_XRInterface_PlayAreaMode>` mode **)**
  360. Call this to find out if a given play area mode is supported by this interface.
  361. .. rst-class:: classref-item-separator
  362. ----
  363. .. _class_XRInterface_method_trigger_haptic_pulse:
  364. .. rst-class:: classref-method
  365. void **trigger_haptic_pulse** **(** :ref:`String<class_String>` action_name, :ref:`StringName<class_StringName>` tracker_name, :ref:`float<class_float>` frequency, :ref:`float<class_float>` amplitude, :ref:`float<class_float>` duration_sec, :ref:`float<class_float>` delay_sec **)**
  366. Triggers a haptic pulse on a device associated with this interface.
  367. \ ``action_name`` is the name of the action for this pulse.
  368. \ ``tracker_name`` is optional and can be used to direct the pulse to a specific device provided that device is bound to this haptic.
  369. .. rst-class:: classref-item-separator
  370. ----
  371. .. _class_XRInterface_method_uninitialize:
  372. .. rst-class:: classref-method
  373. void **uninitialize** **(** **)**
  374. Turns the interface off.
  375. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  376. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  377. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  378. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  379. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  380. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`