class_xrserver.rst 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  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/master/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/XRServer.xml.
  6. .. _class_XRServer:
  7. XRServer
  8. ========
  9. **Inherits:** :ref:`Object<class_Object>`
  10. Server for AR and VR features.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. The AR/VR server is the heart of our Advanced and Virtual Reality solution and handles all the processing.
  15. .. rst-class:: classref-introduction-group
  16. Tutorials
  17. ---------
  18. - :doc:`XR documentation index <../tutorials/xr/index>`
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +---------------------------------------+---------------------------------------------------------------------+-----------------------------------------------------+
  25. | :ref:`XRInterface<class_XRInterface>` | :ref:`primary_interface<class_XRServer_property_primary_interface>` | |
  26. +---------------------------------------+---------------------------------------------------------------------+-----------------------------------------------------+
  27. | :ref:`Transform3D<class_Transform3D>` | :ref:`world_origin<class_XRServer_property_world_origin>` | ``Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)`` |
  28. +---------------------------------------+---------------------------------------------------------------------+-----------------------------------------------------+
  29. | :ref:`float<class_float>` | :ref:`world_scale<class_XRServer_property_world_scale>` | ``1.0`` |
  30. +---------------------------------------+---------------------------------------------------------------------+-----------------------------------------------------+
  31. .. rst-class:: classref-reftable-group
  32. Methods
  33. -------
  34. .. table::
  35. :widths: auto
  36. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`add_interface<class_XRServer_method_add_interface>` **(** :ref:`XRInterface<class_XRInterface>` interface **)** |
  38. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`add_tracker<class_XRServer_method_add_tracker>` **(** :ref:`XRPositionalTracker<class_XRPositionalTracker>` tracker **)** |
  40. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`center_on_hmd<class_XRServer_method_center_on_hmd>` **(** :ref:`RotationMode<enum_XRServer_RotationMode>` rotation_mode, :ref:`bool<class_bool>` keep_height **)** |
  42. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`XRInterface<class_XRInterface>` | :ref:`find_interface<class_XRServer_method_find_interface>` **(** :ref:`String<class_String>` name **)** |const| |
  44. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Transform3D<class_Transform3D>` | :ref:`get_hmd_transform<class_XRServer_method_get_hmd_transform>` **(** **)** |
  46. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`XRInterface<class_XRInterface>` | :ref:`get_interface<class_XRServer_method_get_interface>` **(** :ref:`int<class_int>` idx **)** |const| |
  48. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`int<class_int>` | :ref:`get_interface_count<class_XRServer_method_get_interface_count>` **(** **)** |const| |
  50. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Dictionary[]<class_Dictionary>` | :ref:`get_interfaces<class_XRServer_method_get_interfaces>` **(** **)** |const| |
  52. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`Transform3D<class_Transform3D>` | :ref:`get_reference_frame<class_XRServer_method_get_reference_frame>` **(** **)** |const| |
  54. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`XRPositionalTracker<class_XRPositionalTracker>` | :ref:`get_tracker<class_XRServer_method_get_tracker>` **(** :ref:`StringName<class_StringName>` tracker_name **)** |const| |
  56. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`Dictionary<class_Dictionary>` | :ref:`get_trackers<class_XRServer_method_get_trackers>` **(** :ref:`int<class_int>` tracker_types **)** |
  58. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | void | :ref:`remove_interface<class_XRServer_method_remove_interface>` **(** :ref:`XRInterface<class_XRInterface>` interface **)** |
  60. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | void | :ref:`remove_tracker<class_XRServer_method_remove_tracker>` **(** :ref:`XRPositionalTracker<class_XRPositionalTracker>` tracker **)** |
  62. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. .. rst-class:: classref-section-separator
  64. ----
  65. .. rst-class:: classref-descriptions-group
  66. Signals
  67. -------
  68. .. _class_XRServer_signal_interface_added:
  69. .. rst-class:: classref-signal
  70. **interface_added** **(** :ref:`StringName<class_StringName>` interface_name **)**
  71. Emitted when a new interface has been added.
  72. .. rst-class:: classref-item-separator
  73. ----
  74. .. _class_XRServer_signal_interface_removed:
  75. .. rst-class:: classref-signal
  76. **interface_removed** **(** :ref:`StringName<class_StringName>` interface_name **)**
  77. Emitted when an interface is removed.
  78. .. rst-class:: classref-item-separator
  79. ----
  80. .. _class_XRServer_signal_tracker_added:
  81. .. rst-class:: classref-signal
  82. **tracker_added** **(** :ref:`StringName<class_StringName>` tracker_name, :ref:`int<class_int>` type **)**
  83. Emitted when a new tracker has been added. If you don't use a fixed number of controllers or if you're using :ref:`XRAnchor3D<class_XRAnchor3D>`\ s for an AR solution, it is important to react to this signal to add the appropriate :ref:`XRController3D<class_XRController3D>` or :ref:`XRAnchor3D<class_XRAnchor3D>` nodes related to this new tracker.
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_XRServer_signal_tracker_removed:
  87. .. rst-class:: classref-signal
  88. **tracker_removed** **(** :ref:`StringName<class_StringName>` tracker_name, :ref:`int<class_int>` type **)**
  89. Emitted when a tracker is removed. You should remove any :ref:`XRController3D<class_XRController3D>` or :ref:`XRAnchor3D<class_XRAnchor3D>` points if applicable. This is not mandatory, the nodes simply become inactive and will be made active again when a new tracker becomes available (i.e. a new controller is switched on that takes the place of the previous one).
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_XRServer_signal_tracker_updated:
  93. .. rst-class:: classref-signal
  94. **tracker_updated** **(** :ref:`StringName<class_StringName>` tracker_name, :ref:`int<class_int>` type **)**
  95. Emitted when an existing tracker has been updated. This can happen if the user switches controllers.
  96. .. rst-class:: classref-section-separator
  97. ----
  98. .. rst-class:: classref-descriptions-group
  99. Enumerations
  100. ------------
  101. .. _enum_XRServer_TrackerType:
  102. .. rst-class:: classref-enumeration
  103. enum **TrackerType**:
  104. .. _class_XRServer_constant_TRACKER_HEAD:
  105. .. rst-class:: classref-enumeration-constant
  106. :ref:`TrackerType<enum_XRServer_TrackerType>` **TRACKER_HEAD** = ``1``
  107. The tracker tracks the location of the players head. This is usually a location centered between the players eyes. Note that for handheld AR devices this can be the current location of the device.
  108. .. _class_XRServer_constant_TRACKER_CONTROLLER:
  109. .. rst-class:: classref-enumeration-constant
  110. :ref:`TrackerType<enum_XRServer_TrackerType>` **TRACKER_CONTROLLER** = ``2``
  111. The tracker tracks the location of a controller.
  112. .. _class_XRServer_constant_TRACKER_BASESTATION:
  113. .. rst-class:: classref-enumeration-constant
  114. :ref:`TrackerType<enum_XRServer_TrackerType>` **TRACKER_BASESTATION** = ``4``
  115. The tracker tracks the location of a base station.
  116. .. _class_XRServer_constant_TRACKER_ANCHOR:
  117. .. rst-class:: classref-enumeration-constant
  118. :ref:`TrackerType<enum_XRServer_TrackerType>` **TRACKER_ANCHOR** = ``8``
  119. The tracker tracks the location and size of an AR anchor.
  120. .. _class_XRServer_constant_TRACKER_ANY_KNOWN:
  121. .. rst-class:: classref-enumeration-constant
  122. :ref:`TrackerType<enum_XRServer_TrackerType>` **TRACKER_ANY_KNOWN** = ``127``
  123. Used internally to filter trackers of any known type.
  124. .. _class_XRServer_constant_TRACKER_UNKNOWN:
  125. .. rst-class:: classref-enumeration-constant
  126. :ref:`TrackerType<enum_XRServer_TrackerType>` **TRACKER_UNKNOWN** = ``128``
  127. Used internally if we haven't set the tracker type yet.
  128. .. _class_XRServer_constant_TRACKER_ANY:
  129. .. rst-class:: classref-enumeration-constant
  130. :ref:`TrackerType<enum_XRServer_TrackerType>` **TRACKER_ANY** = ``255``
  131. Used internally to select all trackers.
  132. .. rst-class:: classref-item-separator
  133. ----
  134. .. _enum_XRServer_RotationMode:
  135. .. rst-class:: classref-enumeration
  136. enum **RotationMode**:
  137. .. _class_XRServer_constant_RESET_FULL_ROTATION:
  138. .. rst-class:: classref-enumeration-constant
  139. :ref:`RotationMode<enum_XRServer_RotationMode>` **RESET_FULL_ROTATION** = ``0``
  140. Fully reset the orientation of the HMD. Regardless of what direction the user is looking to in the real world. The user will look dead ahead in the virtual world.
  141. .. _class_XRServer_constant_RESET_BUT_KEEP_TILT:
  142. .. rst-class:: classref-enumeration-constant
  143. :ref:`RotationMode<enum_XRServer_RotationMode>` **RESET_BUT_KEEP_TILT** = ``1``
  144. Resets the orientation but keeps the tilt of the device. So if we're looking down, we keep looking down but heading will be reset.
  145. .. _class_XRServer_constant_DONT_RESET_ROTATION:
  146. .. rst-class:: classref-enumeration-constant
  147. :ref:`RotationMode<enum_XRServer_RotationMode>` **DONT_RESET_ROTATION** = ``2``
  148. Does not reset the orientation of the HMD, only the position of the player gets centered.
  149. .. rst-class:: classref-section-separator
  150. ----
  151. .. rst-class:: classref-descriptions-group
  152. Property Descriptions
  153. ---------------------
  154. .. _class_XRServer_property_primary_interface:
  155. .. rst-class:: classref-property
  156. :ref:`XRInterface<class_XRInterface>` **primary_interface**
  157. .. rst-class:: classref-property-setget
  158. - void **set_primary_interface** **(** :ref:`XRInterface<class_XRInterface>` value **)**
  159. - :ref:`XRInterface<class_XRInterface>` **get_primary_interface** **(** **)**
  160. The primary :ref:`XRInterface<class_XRInterface>` currently bound to the **XRServer**.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _class_XRServer_property_world_origin:
  164. .. rst-class:: classref-property
  165. :ref:`Transform3D<class_Transform3D>` **world_origin** = ``Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)``
  166. .. rst-class:: classref-property-setget
  167. - void **set_world_origin** **(** :ref:`Transform3D<class_Transform3D>` value **)**
  168. - :ref:`Transform3D<class_Transform3D>` **get_world_origin** **(** **)**
  169. The current origin of our tracking space in the virtual world. This is used by the renderer to properly position the camera with new tracking data.
  170. \ **Note:** This property is managed by the current :ref:`XROrigin3D<class_XROrigin3D>` node. It is exposed for access from GDExtensions.
  171. .. rst-class:: classref-item-separator
  172. ----
  173. .. _class_XRServer_property_world_scale:
  174. .. rst-class:: classref-property
  175. :ref:`float<class_float>` **world_scale** = ``1.0``
  176. .. rst-class:: classref-property-setget
  177. - void **set_world_scale** **(** :ref:`float<class_float>` value **)**
  178. - :ref:`float<class_float>` **get_world_scale** **(** **)**
  179. Allows you to adjust the scale to your game's units. Most AR/VR platforms assume a scale of 1 game world unit = 1 real world meter.
  180. .. rst-class:: classref-section-separator
  181. ----
  182. .. rst-class:: classref-descriptions-group
  183. Method Descriptions
  184. -------------------
  185. .. _class_XRServer_method_add_interface:
  186. .. rst-class:: classref-method
  187. void **add_interface** **(** :ref:`XRInterface<class_XRInterface>` interface **)**
  188. Registers an :ref:`XRInterface<class_XRInterface>` object.
  189. .. rst-class:: classref-item-separator
  190. ----
  191. .. _class_XRServer_method_add_tracker:
  192. .. rst-class:: classref-method
  193. void **add_tracker** **(** :ref:`XRPositionalTracker<class_XRPositionalTracker>` tracker **)**
  194. Registers a new :ref:`XRPositionalTracker<class_XRPositionalTracker>` that tracks a spatial location in real space.
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_XRServer_method_center_on_hmd:
  198. .. rst-class:: classref-method
  199. void **center_on_hmd** **(** :ref:`RotationMode<enum_XRServer_RotationMode>` rotation_mode, :ref:`bool<class_bool>` keep_height **)**
  200. This is an important function to understand correctly. AR and VR platforms all handle positioning slightly differently.
  201. For platforms that do not offer spatial tracking, our origin point (0, 0, 0) is the location of our HMD, but you have little control over the direction the player is facing in the real world.
  202. For platforms that do offer spatial tracking, our origin point depends very much on the system. For OpenVR, our origin point is usually the center of the tracking space, on the ground. For other platforms, it's often the location of the tracking camera.
  203. This method allows you to center your tracker on the location of the HMD. It will take the current location of the HMD and use that to adjust all your tracking data; in essence, realigning the real world to your player's current position in the game world.
  204. For this method to produce usable results, tracking information must be available. This often takes a few frames after starting your game.
  205. You should call this method after a few seconds have passed. For example, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, or when implementing a teleport mechanism.
  206. .. rst-class:: classref-item-separator
  207. ----
  208. .. _class_XRServer_method_find_interface:
  209. .. rst-class:: classref-method
  210. :ref:`XRInterface<class_XRInterface>` **find_interface** **(** :ref:`String<class_String>` name **)** |const|
  211. Finds an interface by its ``name``. For example, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it.
  212. .. rst-class:: classref-item-separator
  213. ----
  214. .. _class_XRServer_method_get_hmd_transform:
  215. .. rst-class:: classref-method
  216. :ref:`Transform3D<class_Transform3D>` **get_hmd_transform** **(** **)**
  217. Returns the primary interface's transformation.
  218. .. rst-class:: classref-item-separator
  219. ----
  220. .. _class_XRServer_method_get_interface:
  221. .. rst-class:: classref-method
  222. :ref:`XRInterface<class_XRInterface>` **get_interface** **(** :ref:`int<class_int>` idx **)** |const|
  223. Returns the interface registered at the given ``idx`` index in the list of interfaces.
  224. .. rst-class:: classref-item-separator
  225. ----
  226. .. _class_XRServer_method_get_interface_count:
  227. .. rst-class:: classref-method
  228. :ref:`int<class_int>` **get_interface_count** **(** **)** |const|
  229. Returns the number of interfaces currently registered with the AR/VR server. If your project supports multiple AR/VR platforms, you can look through the available interface, and either present the user with a selection or simply try to initialize each interface and use the first one that returns ``true``.
  230. .. rst-class:: classref-item-separator
  231. ----
  232. .. _class_XRServer_method_get_interfaces:
  233. .. rst-class:: classref-method
  234. :ref:`Dictionary[]<class_Dictionary>` **get_interfaces** **(** **)** |const|
  235. Returns a list of available interfaces the ID and name of each interface.
  236. .. rst-class:: classref-item-separator
  237. ----
  238. .. _class_XRServer_method_get_reference_frame:
  239. .. rst-class:: classref-method
  240. :ref:`Transform3D<class_Transform3D>` **get_reference_frame** **(** **)** |const|
  241. Returns the reference frame transform. Mostly used internally and exposed for GDExtension build interfaces.
  242. .. rst-class:: classref-item-separator
  243. ----
  244. .. _class_XRServer_method_get_tracker:
  245. .. rst-class:: classref-method
  246. :ref:`XRPositionalTracker<class_XRPositionalTracker>` **get_tracker** **(** :ref:`StringName<class_StringName>` tracker_name **)** |const|
  247. Returns the positional tracker with the given ``tracker_name``.
  248. .. rst-class:: classref-item-separator
  249. ----
  250. .. _class_XRServer_method_get_trackers:
  251. .. rst-class:: classref-method
  252. :ref:`Dictionary<class_Dictionary>` **get_trackers** **(** :ref:`int<class_int>` tracker_types **)**
  253. Returns a dictionary of trackers for ``tracker_types``.
  254. .. rst-class:: classref-item-separator
  255. ----
  256. .. _class_XRServer_method_remove_interface:
  257. .. rst-class:: classref-method
  258. void **remove_interface** **(** :ref:`XRInterface<class_XRInterface>` interface **)**
  259. Removes this ``interface``.
  260. .. rst-class:: classref-item-separator
  261. ----
  262. .. _class_XRServer_method_remove_tracker:
  263. .. rst-class:: classref-method
  264. void **remove_tracker** **(** :ref:`XRPositionalTracker<class_XRPositionalTracker>` tracker **)**
  265. Removes this positional ``tracker``.
  266. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  267. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  268. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  269. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  270. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  271. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  272. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`