class_arvrserver.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/ARVRServer.xml.
  6. .. _class_ARVRServer:
  7. ARVRServer
  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:`../tutorials/vr/index`
  19. .. rst-class:: classref-reftable-group
  20. Properties
  21. ----------
  22. .. table::
  23. :widths: auto
  24. +-------------------------------------------+-----------------------------------------------------------------------+---------+
  25. | :ref:`ARVRInterface<class_ARVRInterface>` | :ref:`primary_interface<class_ARVRServer_property_primary_interface>` | |
  26. +-------------------------------------------+-----------------------------------------------------------------------+---------+
  27. | :ref:`float<class_float>` | :ref:`world_scale<class_ARVRServer_property_world_scale>` | ``1.0`` |
  28. +-------------------------------------------+-----------------------------------------------------------------------+---------+
  29. .. rst-class:: classref-reftable-group
  30. Methods
  31. -------
  32. .. table::
  33. :widths: auto
  34. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | void | :ref:`add_interface<class_ARVRServer_method_add_interface>` **(** :ref:`ARVRInterface<class_ARVRInterface>` interface **)** |
  36. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`add_tracker<class_ARVRServer_method_add_tracker>` **(** :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` tracker **)** |
  38. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | void | :ref:`center_on_hmd<class_ARVRServer_method_center_on_hmd>` **(** :ref:`RotationMode<enum_ARVRServer_RotationMode>` rotation_mode, :ref:`bool<class_bool>` keep_height **)** |
  40. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`clear_primary_interface_if<class_ARVRServer_method_clear_primary_interface_if>` **(** :ref:`ARVRInterface<class_ARVRInterface>` interface **)** |
  42. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`ARVRInterface<class_ARVRInterface>` | :ref:`find_interface<class_ARVRServer_method_find_interface>` **(** :ref:`String<class_String>` name **)** |const| |
  44. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`Transform<class_Transform>` | :ref:`get_hmd_transform<class_ARVRServer_method_get_hmd_transform>` **(** **)** |
  46. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`ARVRInterface<class_ARVRInterface>` | :ref:`get_interface<class_ARVRServer_method_get_interface>` **(** :ref:`int<class_int>` idx **)** |const| |
  48. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`int<class_int>` | :ref:`get_interface_count<class_ARVRServer_method_get_interface_count>` **(** **)** |const| |
  50. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`Array<class_Array>` | :ref:`get_interfaces<class_ARVRServer_method_get_interfaces>` **(** **)** |const| |
  52. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`get_last_commit_usec<class_ARVRServer_method_get_last_commit_usec>` **(** **)** |
  54. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`get_last_frame_usec<class_ARVRServer_method_get_last_frame_usec>` **(** **)** |
  56. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`get_last_process_usec<class_ARVRServer_method_get_last_process_usec>` **(** **)** |
  58. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`Transform<class_Transform>` | :ref:`get_reference_frame<class_ARVRServer_method_get_reference_frame>` **(** **)** |const| |
  60. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` | :ref:`get_tracker<class_ARVRServer_method_get_tracker>` **(** :ref:`int<class_int>` idx **)** |const| |
  62. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`int<class_int>` | :ref:`get_tracker_count<class_ARVRServer_method_get_tracker_count>` **(** **)** |const| |
  64. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | void | :ref:`remove_interface<class_ARVRServer_method_remove_interface>` **(** :ref:`ARVRInterface<class_ARVRInterface>` interface **)** |
  66. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | void | :ref:`remove_tracker<class_ARVRServer_method_remove_tracker>` **(** :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` tracker **)** |
  68. +-----------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. .. rst-class:: classref-section-separator
  70. ----
  71. .. rst-class:: classref-descriptions-group
  72. Signals
  73. -------
  74. .. _class_ARVRServer_signal_interface_added:
  75. .. rst-class:: classref-signal
  76. **interface_added** **(** :ref:`String<class_String>` interface_name **)**
  77. Emitted when a new interface has been added.
  78. .. rst-class:: classref-item-separator
  79. ----
  80. .. _class_ARVRServer_signal_interface_removed:
  81. .. rst-class:: classref-signal
  82. **interface_removed** **(** :ref:`String<class_String>` interface_name **)**
  83. Emitted when an interface is removed.
  84. .. rst-class:: classref-item-separator
  85. ----
  86. .. _class_ARVRServer_signal_tracker_added:
  87. .. rst-class:: classref-signal
  88. **tracker_added** **(** :ref:`String<class_String>` tracker_name, :ref:`int<class_int>` type, :ref:`int<class_int>` id **)**
  89. Emitted when a new tracker has been added. If you don't use a fixed number of controllers or if you're using :ref:`ARVRAnchor<class_ARVRAnchor>`\ s for an AR solution, it is important to react to this signal to add the appropriate :ref:`ARVRController<class_ARVRController>` or :ref:`ARVRAnchor<class_ARVRAnchor>` nodes related to this new tracker.
  90. .. rst-class:: classref-item-separator
  91. ----
  92. .. _class_ARVRServer_signal_tracker_removed:
  93. .. rst-class:: classref-signal
  94. **tracker_removed** **(** :ref:`String<class_String>` tracker_name, :ref:`int<class_int>` type, :ref:`int<class_int>` id **)**
  95. Emitted when a tracker is removed. You should remove any :ref:`ARVRController<class_ARVRController>` or :ref:`ARVRAnchor<class_ARVRAnchor>` 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).
  96. .. rst-class:: classref-section-separator
  97. ----
  98. .. rst-class:: classref-descriptions-group
  99. Enumerations
  100. ------------
  101. .. _enum_ARVRServer_TrackerType:
  102. .. rst-class:: classref-enumeration
  103. enum **TrackerType**:
  104. .. _class_ARVRServer_constant_TRACKER_CONTROLLER:
  105. .. rst-class:: classref-enumeration-constant
  106. :ref:`TrackerType<enum_ARVRServer_TrackerType>` **TRACKER_CONTROLLER** = ``1``
  107. The tracker tracks the location of a controller.
  108. .. _class_ARVRServer_constant_TRACKER_BASESTATION:
  109. .. rst-class:: classref-enumeration-constant
  110. :ref:`TrackerType<enum_ARVRServer_TrackerType>` **TRACKER_BASESTATION** = ``2``
  111. The tracker tracks the location of a base station.
  112. .. _class_ARVRServer_constant_TRACKER_ANCHOR:
  113. .. rst-class:: classref-enumeration-constant
  114. :ref:`TrackerType<enum_ARVRServer_TrackerType>` **TRACKER_ANCHOR** = ``4``
  115. The tracker tracks the location and size of an AR anchor.
  116. .. _class_ARVRServer_constant_TRACKER_ANY_KNOWN:
  117. .. rst-class:: classref-enumeration-constant
  118. :ref:`TrackerType<enum_ARVRServer_TrackerType>` **TRACKER_ANY_KNOWN** = ``127``
  119. Used internally to filter trackers of any known type.
  120. .. _class_ARVRServer_constant_TRACKER_UNKNOWN:
  121. .. rst-class:: classref-enumeration-constant
  122. :ref:`TrackerType<enum_ARVRServer_TrackerType>` **TRACKER_UNKNOWN** = ``128``
  123. Used internally if we haven't set the tracker type yet.
  124. .. _class_ARVRServer_constant_TRACKER_ANY:
  125. .. rst-class:: classref-enumeration-constant
  126. :ref:`TrackerType<enum_ARVRServer_TrackerType>` **TRACKER_ANY** = ``255``
  127. Used internally to select all trackers.
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _enum_ARVRServer_RotationMode:
  131. .. rst-class:: classref-enumeration
  132. enum **RotationMode**:
  133. .. _class_ARVRServer_constant_RESET_FULL_ROTATION:
  134. .. rst-class:: classref-enumeration-constant
  135. :ref:`RotationMode<enum_ARVRServer_RotationMode>` **RESET_FULL_ROTATION** = ``0``
  136. 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.
  137. .. _class_ARVRServer_constant_RESET_BUT_KEEP_TILT:
  138. .. rst-class:: classref-enumeration-constant
  139. :ref:`RotationMode<enum_ARVRServer_RotationMode>` **RESET_BUT_KEEP_TILT** = ``1``
  140. 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.
  141. .. _class_ARVRServer_constant_DONT_RESET_ROTATION:
  142. .. rst-class:: classref-enumeration-constant
  143. :ref:`RotationMode<enum_ARVRServer_RotationMode>` **DONT_RESET_ROTATION** = ``2``
  144. Does not reset the orientation of the HMD, only the position of the player gets centered.
  145. .. rst-class:: classref-section-separator
  146. ----
  147. .. rst-class:: classref-descriptions-group
  148. Property Descriptions
  149. ---------------------
  150. .. _class_ARVRServer_property_primary_interface:
  151. .. rst-class:: classref-property
  152. :ref:`ARVRInterface<class_ARVRInterface>` **primary_interface**
  153. .. rst-class:: classref-property-setget
  154. - void **set_primary_interface** **(** :ref:`ARVRInterface<class_ARVRInterface>` value **)**
  155. - :ref:`ARVRInterface<class_ARVRInterface>` **get_primary_interface** **(** **)**
  156. The primary :ref:`ARVRInterface<class_ARVRInterface>` currently bound to the **ARVRServer**.
  157. .. rst-class:: classref-item-separator
  158. ----
  159. .. _class_ARVRServer_property_world_scale:
  160. .. rst-class:: classref-property
  161. :ref:`float<class_float>` **world_scale** = ``1.0``
  162. .. rst-class:: classref-property-setget
  163. - void **set_world_scale** **(** :ref:`float<class_float>` value **)**
  164. - :ref:`float<class_float>` **get_world_scale** **(** **)**
  165. 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.
  166. .. rst-class:: classref-section-separator
  167. ----
  168. .. rst-class:: classref-descriptions-group
  169. Method Descriptions
  170. -------------------
  171. .. _class_ARVRServer_method_add_interface:
  172. .. rst-class:: classref-method
  173. void **add_interface** **(** :ref:`ARVRInterface<class_ARVRInterface>` interface **)**
  174. Registers an :ref:`ARVRInterface<class_ARVRInterface>` object.
  175. .. rst-class:: classref-item-separator
  176. ----
  177. .. _class_ARVRServer_method_add_tracker:
  178. .. rst-class:: classref-method
  179. void **add_tracker** **(** :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` tracker **)**
  180. Registers a new :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` that tracks a spatial location in real space.
  181. .. rst-class:: classref-item-separator
  182. ----
  183. .. _class_ARVRServer_method_center_on_hmd:
  184. .. rst-class:: classref-method
  185. void **center_on_hmd** **(** :ref:`RotationMode<enum_ARVRServer_RotationMode>` rotation_mode, :ref:`bool<class_bool>` keep_height **)**
  186. This is an important function to understand correctly. AR and VR platforms all handle positioning slightly differently.
  187. 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.
  188. 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.
  189. 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.
  190. For this method to produce usable results, tracking information must be available. This often takes a few frames after starting your game.
  191. You should call this method after a few seconds have passed. For instance, 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.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_ARVRServer_method_clear_primary_interface_if:
  195. .. rst-class:: classref-method
  196. void **clear_primary_interface_if** **(** :ref:`ARVRInterface<class_ARVRInterface>` interface **)**
  197. Clears our current primary interface if it is set to the provided interface.
  198. .. rst-class:: classref-item-separator
  199. ----
  200. .. _class_ARVRServer_method_find_interface:
  201. .. rst-class:: classref-method
  202. :ref:`ARVRInterface<class_ARVRInterface>` **find_interface** **(** :ref:`String<class_String>` name **)** |const|
  203. Finds an interface by its name. For instance, if your project uses capabilities of an AR/VR platform, you can find the interface for that platform by name and initialize it.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_ARVRServer_method_get_hmd_transform:
  207. .. rst-class:: classref-method
  208. :ref:`Transform<class_Transform>` **get_hmd_transform** **(** **)**
  209. Returns the primary interface's transformation.
  210. .. rst-class:: classref-item-separator
  211. ----
  212. .. _class_ARVRServer_method_get_interface:
  213. .. rst-class:: classref-method
  214. :ref:`ARVRInterface<class_ARVRInterface>` **get_interface** **(** :ref:`int<class_int>` idx **)** |const|
  215. Returns the interface registered at a given index in our list of interfaces.
  216. .. rst-class:: classref-item-separator
  217. ----
  218. .. _class_ARVRServer_method_get_interface_count:
  219. .. rst-class:: classref-method
  220. :ref:`int<class_int>` **get_interface_count** **(** **)** |const|
  221. 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``.
  222. .. rst-class:: classref-item-separator
  223. ----
  224. .. _class_ARVRServer_method_get_interfaces:
  225. .. rst-class:: classref-method
  226. :ref:`Array<class_Array>` **get_interfaces** **(** **)** |const|
  227. Returns a list of available interfaces the ID and name of each interface.
  228. .. rst-class:: classref-item-separator
  229. ----
  230. .. _class_ARVRServer_method_get_last_commit_usec:
  231. .. rst-class:: classref-method
  232. :ref:`int<class_int>` **get_last_commit_usec** **(** **)**
  233. Returns the absolute timestamp (in μs) of the last **ARVRServer** commit of the AR/VR eyes to :ref:`VisualServer<class_VisualServer>`. The value comes from an internal call to :ref:`OS.get_ticks_usec<class_OS_method_get_ticks_usec>`.
  234. .. rst-class:: classref-item-separator
  235. ----
  236. .. _class_ARVRServer_method_get_last_frame_usec:
  237. .. rst-class:: classref-method
  238. :ref:`int<class_int>` **get_last_frame_usec** **(** **)**
  239. Returns the duration (in μs) of the last frame. This is computed as the difference between :ref:`get_last_commit_usec<class_ARVRServer_method_get_last_commit_usec>` and :ref:`get_last_process_usec<class_ARVRServer_method_get_last_process_usec>` when committing.
  240. .. rst-class:: classref-item-separator
  241. ----
  242. .. _class_ARVRServer_method_get_last_process_usec:
  243. .. rst-class:: classref-method
  244. :ref:`int<class_int>` **get_last_process_usec** **(** **)**
  245. Returns the absolute timestamp (in μs) of the last **ARVRServer** process callback. The value comes from an internal call to :ref:`OS.get_ticks_usec<class_OS_method_get_ticks_usec>`.
  246. .. rst-class:: classref-item-separator
  247. ----
  248. .. _class_ARVRServer_method_get_reference_frame:
  249. .. rst-class:: classref-method
  250. :ref:`Transform<class_Transform>` **get_reference_frame** **(** **)** |const|
  251. Returns the reference frame transform. Mostly used internally and exposed for GDNative build interfaces.
  252. .. rst-class:: classref-item-separator
  253. ----
  254. .. _class_ARVRServer_method_get_tracker:
  255. .. rst-class:: classref-method
  256. :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` **get_tracker** **(** :ref:`int<class_int>` idx **)** |const|
  257. Returns the positional tracker at the given ID.
  258. .. rst-class:: classref-item-separator
  259. ----
  260. .. _class_ARVRServer_method_get_tracker_count:
  261. .. rst-class:: classref-method
  262. :ref:`int<class_int>` **get_tracker_count** **(** **)** |const|
  263. Returns the number of trackers currently registered.
  264. .. rst-class:: classref-item-separator
  265. ----
  266. .. _class_ARVRServer_method_remove_interface:
  267. .. rst-class:: classref-method
  268. void **remove_interface** **(** :ref:`ARVRInterface<class_ARVRInterface>` interface **)**
  269. Removes this interface.
  270. .. rst-class:: classref-item-separator
  271. ----
  272. .. _class_ARVRServer_method_remove_tracker:
  273. .. rst-class:: classref-method
  274. void **remove_tracker** **(** :ref:`ARVRPositionalTracker<class_ARVRPositionalTracker>` tracker **)**
  275. Removes this positional tracker.
  276. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  277. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  278. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  279. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`