2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 08:08:05 +00:00
<class name= "XRInterface" inherits= "RefCounted" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
2021-08-23 05:23:16 +00:00
Base class for an XR interface implementation.
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2022-03-09 12:56:14 +00:00
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.
2020-04-08 14:47:36 +00:00
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 [XRServer].
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
2022-07-22 12:05:31 +00:00
<link title= "XR documentation index" > $DOCS_URL/tutorials/xr/index.html</link>
2017-09-12 20:42:36 +00:00
</tutorials>
<methods >
2017-08-20 14:17:24 +00:00
<method name= "get_camera_feed_id" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2017-08-20 14:17:24 +00:00
<description >
2019-06-21 23:04:47 +00:00
If this is an AR interface that requires displaying a camera feed as the background, this method returns the feed ID in the [CameraServer] for this interface.
2017-08-20 14:17:24 +00:00
</description>
</method>
2017-09-29 11:36:27 +00:00
<method name= "get_capabilities" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2017-09-29 11:36:27 +00:00
<description >
2019-12-05 21:58:58 +00:00
Returns a combination of [enum Capabilities] flags providing information about the capabilities of this interface.
2017-09-29 11:36:27 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_name" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "StringName" />
2017-09-12 20:42:36 +00:00
<description >
2021-08-23 05:23:16 +00:00
Returns the name of this interface (OpenXR, OpenVR, OpenHMD, ARKit, etc).
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-06-27 11:51:30 +00:00
<method name= "get_play_area" qualifiers= "const" >
<return type= "PackedVector3Array" />
<description >
2022-11-01 14:29:38 +00:00
Returns an array of vectors that denotes the physical play area mapped to the virtual space around the [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.
2021-06-27 11:51:30 +00:00
</description>
</method>
2022-11-07 22:31:39 +00:00
<method name= "get_projection_for_view" >
<return type= "Projection" />
<param index= "0" name= "view" type= "int" />
<param index= "1" name= "aspect" type= "float" />
<param index= "2" name= "near" type= "float" />
<param index= "3" name= "far" type= "float" />
<description >
Returns the projection matrix for a view/eye.
</description>
</method>
2021-08-23 05:23:16 +00:00
<method name= "get_render_target_size" >
2021-07-30 13:28:05 +00:00
<return type= "Vector2" />
2017-09-12 20:42:36 +00:00
<description >
Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform.
</description>
</method>
2023-02-02 14:14:16 +00:00
<method name= "get_supported_environment_blend_modes" >
<return type= "Array" />
<description >
Returns the an array of supported environment blend modes, see [enum XRInterface.EnvironmentBlendMode].
</description>
</method>
2023-03-13 01:26:10 +00:00
<method name= "get_system_info" >
<return type= "Dictionary" />
<description >
Returns a [Dictionary] with extra system info. Interfaces are expected to return [code]XRRuntimeName[/code] and [code]XRRuntimeVersion[/code] providing info about the used XR runtime. Additional entries may be provided specific to an interface.
[b]Note:[/b]This information may only be available after [method initialize] was successfully called.
</description>
</method>
2017-09-29 11:36:27 +00:00
<method name= "get_tracking_status" qualifiers= "const" >
2021-08-23 05:23:16 +00:00
<return type= "int" enum= "XRInterface.TrackingStatus" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-29 11:36:27 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
</method>
2022-11-07 22:31:39 +00:00
<method name= "get_transform_for_view" >
<return type= "Transform3D" />
<param index= "0" name= "view" type= "int" />
<param index= "1" name= "cam_transform" type= "Transform3D" />
<description >
Returns the transform for a view/eye.
[param view] is the view/eye index.
2023-04-18 11:53:47 +00:00
[param cam_transform] is the transform that maps device coordinates to scene coordinates, typically the [member Node3D.global_transform] of the current XROrigin3D.
2022-11-07 22:31:39 +00:00
</description>
</method>
2021-05-07 13:19:04 +00:00
<method name= "get_view_count" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2021-05-07 13:19:04 +00:00
<description >
Returns the number of views that need to be rendered for this device. 1 for Monoscopic, 2 for Stereoscopic.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "initialize" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
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.
2018-11-20 10:14:07 +00:00
After initializing the interface you want to use you then need to enable the AR/VR mode of a viewport and rendering should commence.
2021-08-23 05:23:16 +00:00
[b]Note:[/b] 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.
2019-12-05 21:58:58 +00:00
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.
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.
2017-09-12 20:42:36 +00:00
</description>
</method>
2021-08-23 05:23:16 +00:00
<method name= "is_initialized" qualifiers= "const" >
<return type= "bool" />
<description >
2022-11-01 14:29:38 +00:00
Is [code]true[/code] if this interface has been initialized.
2021-08-23 05:23:16 +00:00
</description>
</method>
2024-01-25 20:07:50 +00:00
<method name= "is_passthrough_enabled" is_deprecated= "true" >
2022-09-26 07:04:12 +00:00
<return type= "bool" />
<description >
Is [code]true[/code] if passthrough is enabled.
2024-01-25 20:07:50 +00:00
[i]Deprecated.[/i] Check if [member environment_blend_mode] is [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND], instead.
2022-09-26 07:04:12 +00:00
</description>
</method>
2024-01-25 20:07:50 +00:00
<method name= "is_passthrough_supported" is_deprecated= "true" >
2022-09-26 07:04:12 +00:00
<return type= "bool" />
<description >
Is [code]true[/code] if this interface supports passthrough.
2024-01-25 20:07:50 +00:00
[i]Deprecated.[/i] Check that [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND] is supported using [method get_supported_environment_blend_modes], instead.
2022-09-26 07:04:12 +00:00
</description>
</method>
2023-02-02 14:14:16 +00:00
<method name= "set_environment_blend_mode" >
<return type= "bool" />
<param index= "0" name= "mode" type= "int" enum= "XRInterface.EnvironmentBlendMode" />
<description >
Sets the active environment blend mode.
2023-11-09 09:16:30 +00:00
[param mode] is the environment blend mode starting with the next frame.
2023-02-02 14:14:16 +00:00
[b]Note:[/b] Not all runtimes support all environment blend modes, so it is important to check this at startup. For example:
[codeblock]
func _ready():
2023-03-03 14:42:32 +00:00
var xr_interface: XRInterface = XRServer.find_interface("OpenXR")
2023-02-02 14:14:16 +00:00
if xr_interface and xr_interface.is_initialized():
2023-03-03 14:42:32 +00:00
var vp: Viewport = get_viewport()
2023-02-02 14:14:16 +00:00
vp.use_xr = true
var acceptable_modes = [ XRInterface.XR_ENV_BLEND_MODE_OPAQUE, XRInterface.XR_ENV_BLEND_MODE_ADDITIVE ]
var modes = xr_interface.get_supported_environment_blend_modes()
for mode in acceptable_modes:
if mode in modes:
xr_interface.set_environment_blend_mode(mode)
break
[/codeblock]
</description>
</method>
2021-06-27 11:51:30 +00:00
<method name= "set_play_area_mode" >
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "mode" type= "int" enum= "XRInterface.PlayAreaMode" />
2021-06-27 11:51:30 +00:00
<description >
Sets the active play area mode, will return [code]false[/code] if the mode can't be used with this interface.
2024-01-30 16:30:54 +00:00
[b]Note:[/b] Changing this after the interface has already been initialized can be jarring for the player, so it's recommended to recenter on the HMD with [method XRServer.center_on_hmd] (if switching to [constant XRInterface.XR_PLAY_AREA_STAGE]) or make the switch during a scene change.
2021-06-27 11:51:30 +00:00
</description>
</method>
2024-01-25 20:07:50 +00:00
<method name= "start_passthrough" is_deprecated= "true" >
2022-09-26 07:04:12 +00:00
<return type= "bool" />
<description >
Starts passthrough, will return [code]false[/code] if passthrough couldn't be started.
[b]Note:[/b] The viewport used for XR must have a transparent background, otherwise passthrough may not properly render.
2024-01-25 20:07:50 +00:00
[i]Deprecated.[/i] Set the [member environment_blend_mode] to [constant XRInterface.XR_ENV_BLEND_MODE_ALPHA_BLEND], instead.
2022-09-26 07:04:12 +00:00
</description>
</method>
2024-01-25 20:07:50 +00:00
<method name= "stop_passthrough" is_deprecated= "true" >
2022-09-26 07:04:12 +00:00
<return type= "void" />
<description >
Stops passthrough.
2024-01-25 20:07:50 +00:00
[i]Deprecated.[/i] Set the [member environment_blend_mode] to [constant XRInterface.XR_ENV_BLEND_MODE_OPAQUE], instead.
2022-09-26 07:04:12 +00:00
</description>
</method>
2021-06-27 11:51:30 +00:00
<method name= "supports_play_area_mode" >
<return type= "bool" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "mode" type= "int" enum= "XRInterface.PlayAreaMode" />
2021-06-27 11:51:30 +00:00
<description >
Call this to find out if a given play area mode is supported by this interface.
</description>
</method>
2021-08-29 06:05:11 +00:00
<method name= "trigger_haptic_pulse" >
<return type= "void" />
2022-08-06 18:11:48 +00:00
<param index= "0" name= "action_name" type= "String" />
<param index= "1" name= "tracker_name" type= "StringName" />
<param index= "2" name= "frequency" type= "float" />
<param index= "3" name= "amplitude" type= "float" />
<param index= "4" name= "duration_sec" type= "float" />
<param index= "5" name= "delay_sec" type= "float" />
2021-08-29 06:05:11 +00:00
<description >
Triggers a haptic pulse on a device associated with this interface.
2022-08-08 23:41:07 +00:00
[param action_name] is the name of the action for this pulse.
[param tracker_name] is optional and can be used to direct the pulse to a specific device provided that device is bound to this haptic.
2021-08-29 06:05:11 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "uninitialize" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2017-09-12 20:42:36 +00:00
<description >
Turns the interface off.
</description>
</method>
</methods>
<members >
2019-06-29 10:38:01 +00:00
<member name= "ar_is_anchor_detection_enabled" type= "bool" setter= "set_anchor_detection_is_enabled" getter= "get_anchor_detection_is_enabled" default= "false" >
2019-12-05 21:58:58 +00:00
On an AR interface, [code]true[/code] if anchor detection is enabled.
2017-09-29 11:36:27 +00:00
</member>
2023-09-12 02:39:48 +00:00
<member name= "environment_blend_mode" type= "int" setter= "set_environment_blend_mode" getter= "get_environment_blend_mode" enum= "XRInterface.EnvironmentBlendMode" default= "0" >
Specify how XR should blend in the environment. This is specific to certain AR and passthrough devices where camera images are blended in by the XR compositor.
</member>
2021-08-23 05:23:16 +00:00
<member name= "interface_is_primary" type= "bool" setter= "set_primary" getter= "is_primary" default= "false" >
2019-12-05 21:58:58 +00:00
[code]true[/code] if this is the primary interface.
2017-09-12 20:42:36 +00:00
</member>
2021-06-27 11:51:30 +00:00
<member name= "xr_play_area_mode" type= "int" setter= "set_play_area_mode" getter= "get_play_area_mode" enum= "XRInterface.PlayAreaMode" default= "0" >
The play area mode for this interface.
</member>
2017-09-12 20:42:36 +00:00
</members>
2021-06-27 11:51:30 +00:00
<signals >
<signal name= "play_area_changed" >
2022-08-06 18:11:48 +00:00
<param index= "0" name= "mode" type= "int" />
2021-06-27 11:51:30 +00:00
<description >
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.
</description>
</signal>
</signals>
2017-09-12 20:42:36 +00:00
<constants >
2020-04-08 14:47:36 +00:00
<constant name= "XR_NONE" value= "0" enum= "Capabilities" >
No XR capabilities.
2017-09-29 11:36:27 +00:00
</constant>
2020-04-08 14:47:36 +00:00
<constant name= "XR_MONO" value= "1" enum= "Capabilities" >
2017-09-29 11:36:27 +00:00
This interface can work with normal rendering output (non-HMD based AR).
</constant>
2020-04-08 14:47:36 +00:00
<constant name= "XR_STEREO" value= "2" enum= "Capabilities" >
2017-09-29 11:36:27 +00:00
This interface supports stereoscopic rendering.
</constant>
2021-08-29 06:05:11 +00:00
<constant name= "XR_QUAD" value= "4" enum= "Capabilities" >
This interface supports quad rendering (not yet supported by Godot).
2017-09-29 11:36:27 +00:00
</constant>
2021-08-29 06:05:11 +00:00
<constant name= "XR_VR" value= "8" enum= "Capabilities" >
2023-02-16 05:26:17 +00:00
This interface supports VR.
2017-09-12 20:42:36 +00:00
</constant>
2021-08-29 06:05:11 +00:00
<constant name= "XR_AR" value= "16" enum= "Capabilities" >
This interface supports AR (video background and real world tracking).
2017-09-12 20:42:36 +00:00
</constant>
2021-08-29 06:05:11 +00:00
<constant name= "XR_EXTERNAL" value= "32" enum= "Capabilities" >
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 [method get_render_target_size]). Using a separate viewport node frees up the main viewport for other purposes.
2017-09-12 20:42:36 +00:00
</constant>
2021-08-23 05:23:16 +00:00
<constant name= "XR_NORMAL_TRACKING" value= "0" enum= "TrackingStatus" >
2017-09-29 11:36:27 +00:00
Tracking is behaving as expected.
</constant>
2021-08-23 05:23:16 +00:00
<constant name= "XR_EXCESSIVE_MOTION" value= "1" enum= "TrackingStatus" >
2019-12-05 21:58:58 +00:00
Tracking is hindered by excessive motion (the player is moving faster than tracking can keep up).
2017-09-29 11:36:27 +00:00
</constant>
2021-08-23 05:23:16 +00:00
<constant name= "XR_INSUFFICIENT_FEATURES" value= "2" enum= "TrackingStatus" >
2019-06-21 23:04:47 +00:00
Tracking is hindered by insufficient features, it's too dark (for camera-based tracking), player is blocked, etc.
2017-09-29 11:36:27 +00:00
</constant>
2021-08-23 05:23:16 +00:00
<constant name= "XR_UNKNOWN_TRACKING" value= "3" enum= "TrackingStatus" >
2017-09-29 11:36:27 +00:00
We don't know the status of the tracking or this interface does not provide feedback.
</constant>
2021-08-23 05:23:16 +00:00
<constant name= "XR_NOT_TRACKING" value= "4" enum= "TrackingStatus" >
2020-01-23 10:14:14 +00:00
Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.).
2017-09-29 11:36:27 +00:00
</constant>
2021-06-27 11:51:30 +00:00
<constant name= "XR_PLAY_AREA_UNKNOWN" value= "0" enum= "PlayAreaMode" >
Play area mode not set or not available.
</constant>
<constant name= "XR_PLAY_AREA_3DOF" value= "1" enum= "PlayAreaMode" >
Play area only supports orientation tracking, no positional tracking, area will center around player.
</constant>
<constant name= "XR_PLAY_AREA_SITTING" value= "2" enum= "PlayAreaMode" >
Player is in seated position, limited positional tracking, fixed guardian around player.
</constant>
<constant name= "XR_PLAY_AREA_ROOMSCALE" value= "3" enum= "PlayAreaMode" >
Player is free to move around, full positional tracking.
</constant>
<constant name= "XR_PLAY_AREA_STAGE" value= "4" enum= "PlayAreaMode" >
2024-01-15 22:26:55 +00:00
Same as [constant XR_PLAY_AREA_ROOMSCALE] but origin point is fixed to the center of the physical space. In this mode, system-level recentering may be disabled, requiring the use of [method XRServer.center_on_hmd].
2021-06-27 11:51:30 +00:00
</constant>
2023-02-02 14:14:16 +00:00
<constant name= "XR_ENV_BLEND_MODE_OPAQUE" value= "0" enum= "EnvironmentBlendMode" >
Opaque blend mode. This is typically used for VR devices.
</constant>
<constant name= "XR_ENV_BLEND_MODE_ADDITIVE" value= "1" enum= "EnvironmentBlendMode" >
Additive blend mode. This is typically used for AR devices or VR devices with passthrough.
</constant>
<constant name= "XR_ENV_BLEND_MODE_ALPHA_BLEND" value= "2" enum= "EnvironmentBlendMode" >
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.
</constant>
2017-09-12 20:42:36 +00:00
</constants>
</class>