Inheritance #
- AudioServer
- CameraServer
- ClassDB
- DisplayServer
- EditorFileSystemDirectory
- EditorInterface
- EditorPaths
- EditorSelection
- EditorUndoRedoManager
- EditorVCSInterface
- Engine
- EngineDebugger
- FramebufferCacheRD
- GDExtensionManager
- Geometry2D
- Geometry3D
- IP
- Input
- InputMap
- JNISingleton
- JSONRPC
- JavaClassWrapper
- JavaScriptBridge
- MainLoop (1)
- Marshalls
- MovieWriter
- NativeMenu
- NavigationMeshGenerator
- NavigationServer2D
- NavigationServer3D
- Node (21)
- OS
- OpenXRExtensionWrapperExtension
- OpenXRInteractionProfileMetadata
- Performance
- PhysicsDirectBodyState2D (1)
- PhysicsDirectBodyState3D (1)
- PhysicsDirectSpaceState2D (1)
- PhysicsDirectSpaceState3D (1)
- PhysicsServer2D (1)
- PhysicsServer2DManager
- PhysicsServer3D (1)
- PhysicsServer3DManager
- PhysicsServer3DRendering
ServerHandler
- ProjectSettings
- RefCounted (121)
- RenderData (2)
- RenderSceneData (2)
- RenderingDevice
- RenderingServer
- ResourceLoader
- ResourceSaver
- ResourceUID
- ScriptLanguage (1)
- ShaderIncludeDB
- TextServerManager
- ThemeDB
- TileData
- Time
- TranslationServer
- TreeItem
- UndoRedo
- UniformSetCacheRD
- WorkerThreadPool
- XRServer
- XRVRS
- AESContext
- AStar2D
- AStar3D
- AStarGrid2D
- AudioEffectInstance (1)
- AudioSample
- AudioSamplePlayback
- AudioStreamPlayback (5)
- CameraFeed
- CharFXTransform
- ConfigFile
- Crypto
- DTLSServer
- DirAccess
- ENetConnection
- EditorContextMenuPlugin
- EditorDebuggerPlugin
- EditorDebuggerSession
- EditorExportPlatform (6)
- EditorExportPlugin
- EditorExportPreset
- EditorFeatureProfile
- EditorFileSystemImportFormatSupportQuery
- EditorInspectorPlugin
- EditorResourceConversionPlugin
- EditorResourcePreviewGenerator
- EditorResourceTooltipPlugin
- EditorSceneFormatImporter (4)
- EditorScenePostImport
- EditorScenePostImportPlugin
- EditorScript
- EditorTranslationParserPlugin
- EncodedObjectAsID
- EngineProfiler
- Expression
- FileAccess
- GLTFObjectModelProperty
- HMACContext
- HTTPClient
- HashingContext
- ImageFormatLoader (1)
- JavaClass
- JavaObject
- JavaScriptObject
- KinematicCollision2D
- KinematicCollision3D
- Lightmapper (1)
- MeshConvexDecompositionSettings
- MeshDataTool
- MultiplayerAPI (2)
- Mutex
- NavigationPathQueryParameters2D
- NavigationPathQueryParameters3D
- NavigationPathQueryResult2D
- NavigationPathQueryResult3D
- Node3DGizmo (1)
- OggPacketSequencePlayback
- OpenXRAPIExtension
- PCKPacker
- PackedDataContainerRef
- PacketPeer (8)
- PhysicsPointQueryParameters2D
- PhysicsPointQueryParameters3D
- PhysicsRayQueryParameters2D
- PhysicsRayQueryParameters3D
- PhysicsShapeQueryParameters2D
- PhysicsShapeQueryParameters3D
- PhysicsTestMotionParameters2D
- PhysicsTestMotionParameters3D
- PhysicsTestMotionResult2D
- PhysicsTestMotionResult3D
- RDAttachmentFormat
- RDFramebufferPass
- RDPipelineColorBlendState
- RDPipelineColorBlendStateAttachment
- RDPipelineDepthStencilState
- RDPipelineMultisampleState
- RDPipelineRasterizationState
- RDPipelineSpecializationConstant
- RDSamplerState
- RDShaderSource
- RDTextureFormat
- RDTextureView
- RDUniform
- RDVertexAttribute
- RandomNumberGenerator
- RegEx
- RegExMatch
- RenderSceneBuffers (2)
- RenderSceneBuffersConfiguration
- Resource (103)
- ResourceFormatLoader
- ResourceFormatSaver
- ResourceImporter (16)
- SceneState
- SceneTreeTimer
- Semaphore
- SkinReference
- StreamPeer (5)
- SurfaceTool
- TCPServer
- TLSOptions
- TextLine
- TextParagraph
- TextServer (1)
- Thread
- TranslationDomain
- TriangleMesh
- Tween
- Tweener (5)
- UDPServer
- UPNP
- UPNPDevice
- WeakRef
- WebRTCPeerConnection (1)
- XMLParser
- XRInterface (4)
- XRPose
- XRTracker (2)
- ZIPPacker
- ZIPReader
Table of contents
-
var ar_is_anchor_detection_enabled: bool = false -
var environment_blend_mode = XR_ENV_BLEND_MODE_OPAQUE -
var interface_is_primary: bool = false -
var xr_play_area_mode = XR_PLAY_AREA_UNKNOWN -
func get_camera_feed_id() -> int -
const func get_capabilities() -> int -
const func get_name() -> StringName -
const func get_play_area() -> PackedVector3Array -
func get_projection_for_view(far: float) -> Projection -
func get_render_target_size() -> Vector2 -
func get_supported_environment_blend_modes() -> Array -
func get_system_info() -> Dictionary -
const func get_tracking_status() -> intXRInterface.TrackingStatus -
func get_transform_for_view(cam_transform: Transform3D) -> Transform3D -
func get_view_count() -> int -
func initialize() -> bool -
const func is_initialized() -> bool -
func is_passthrough_enabled() -> bool -
func is_passthrough_supported() -> bool -
func set_environment_blend_mode(mode: int enumXRInterface.EnvironmentBlendMode) -> bool -
func set_play_area_mode(mode: int enumXRInterface.PlayAreaMode) -> bool -
func start_passthrough() -> bool -
func stop_passthrough() -> void -
func supports_play_area_mode(mode: int enumXRInterface.PlayAreaMode) -> bool -
func trigger_haptic_pulse(delay_sec: float) -> void -
func uninitialize() -> void -
const XR_NONE = 0 enum Capabilities -
const XR_MONO = 1 enum Capabilities -
const XR_STEREO = 2 enum Capabilities -
const XR_QUAD = 4 enum Capabilities -
const XR_VR = 8 enum Capabilities -
const XR_AR = 16 enum Capabilities -
const XR_EXTERNAL = 32 enum Capabilities -
const XR_NORMAL_TRACKING = 0 enum TrackingStatus -
const XR_EXCESSIVE_MOTION = 1 enum TrackingStatus -
const XR_INSUFFICIENT_FEATURES = 2 enum TrackingStatus -
const XR_UNKNOWN_TRACKING = 3 enum TrackingStatus -
const XR_NOT_TRACKING = 4 enum TrackingStatus -
const XR_PLAY_AREA_UNKNOWN = 0 enum PlayAreaMode -
const XR_PLAY_AREA_3DOF = 1 enum PlayAreaMode -
const XR_PLAY_AREA_SITTING = 2 enum PlayAreaMode -
const XR_PLAY_AREA_ROOMSCALE = 3 enum PlayAreaMode -
const XR_PLAY_AREA_STAGE = 4 enum PlayAreaMode -
const XR_ENV_BLEND_MODE_OPAQUE = 0 enum EnvironmentBlendMode -
const XR_ENV_BLEND_MODE_ADDITIVE = 1 enum EnvironmentBlendMode -
const XR_ENV_BLEND_MODE_ALPHA_BLEND = 2 enum EnvironmentBlendMode -
enum Capabilities -
enum TrackingStatus -
enum PlayAreaMode -
enum EnvironmentBlendMode -
signal play_area_changed(mode: int)
XRInterface #
is_refcounted, core, not_builtin_classes
Base class for an XR interface implementation.
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.
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.
Members #
var ar_is_anchor_detection_enabled: bool = false#
On an AR interface, true if anchor detection is enabled.
var environment_blend_mode = XR_ENV_BLEND_MODE_OPAQUE#
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.
var interface_is_primary: bool = false#
true if this is the primary interface.
var xr_play_area_mode = XR_PLAY_AREA_UNKNOWN#
The play area mode for this interface.
Methods #
func get_camera_feed_id() -> int#
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.
const func get_capabilities() -> int#
Returns a combination of Capabilities flags providing information about the capabilities of this interface.
const func get_name() -> StringName#
Returns the name of this interface ("OpenXR", "OpenVR", "OpenHMD", "ARKit", etc.).
const func get_play_area() -> PackedVector3Array#
Returns an array of vectors that represent 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.
func get_projection_for_view(far: float) -> Projection#
Returns the projection matrix for a view/eye.
func get_render_target_size() -> Vector2#
Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform.
func get_supported_environment_blend_modes() -> Array#
Returns the an array of supported environment blend modes, see XRInterface.EnvironmentBlendMode.
func get_system_info() -> Dictionary#
Returns a Dictionary with extra system info. Interfaces are expected to return XRRuntimeName and XRRuntimeVersion providing info about the used XR runtime. Additional entries may be provided specific to an interface.
Note:This information may only be available after initialize was successfully called.
const func get_tracking_status() -> intXRInterface.TrackingStatus#
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.
func get_transform_for_view(cam_transform: Transform3D) -> Transform3D#
Returns the transform for a view/eye.
view is the view/eye index.
cam_transform is the transform that maps device coordinates to scene coordinates, typically the Node3D.global_transform of the current XROrigin3D.
func get_view_count() -> int#
Returns the number of views that need to be rendered for this device. 1 for Monoscopic, 2 for Stereoscopic.
func initialize() -> bool#
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.
After initializing the interface you want to use you then need to enable the AR/VR mode of a viewport and rendering should commence.
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.
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.
const func is_initialized() -> bool#
Returns true if this interface has been initialized.
func is_passthrough_enabled() -> bool#
Returns true if passthrough is enabled.
func is_passthrough_supported() -> bool#
Returns true if this interface supports passthrough.
func set_environment_blend_mode(mode: int enumXRInterface.EnvironmentBlendMode) -> bool#
Sets the active environment blend mode.
mode is the environment blend mode starting with the next frame.
Note: Not all runtimes support all environment blend modes, so it is important to check this at startup. For example:
func _ready():
var xr_interface = XRServer.find_interface("OpenXR")
if xr_interface and xr_interface.is_initialized():
var vp = get_viewport()
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)
breakfunc set_play_area_mode(mode: int enumXRInterface.PlayAreaMode) -> bool#
Sets the active play area mode, will return false if the mode can't be used with this interface.
Note: 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 XRServer.center_on_hmd (if switching to XRInterface.XR_PLAY_AREA_STAGE) or make the switch during a scene change.
func start_passthrough() -> bool#
Starts passthrough, will return false if passthrough couldn't be started.
Note: The viewport used for XR must have a transparent background, otherwise passthrough may not properly render.
func stop_passthrough() -> void#
Stops passthrough.
func supports_play_area_mode(mode: int enumXRInterface.PlayAreaMode) -> bool#
Call this to find out if a given play area mode is supported by this interface.
func trigger_haptic_pulse(delay_sec: float) -> void#
Triggers a haptic pulse on a device associated with this interface.
action_name is the name of the action for this pulse.
tracker_name is optional and can be used to direct the pulse to a specific device provided that device is bound to this haptic.
frequency is the frequency of the pulse, set to 0.0 to have the system use a default frequency.
amplitude is the amplitude of the pulse between 0.0 and 1.0.
duration_sec is the duration of the pulse in seconds.
delay_sec is a delay in seconds before the pulse is given.
func uninitialize() -> void#
Turns the interface off.
Annotations #
Constants #
const XR_NONE = 0 enum Capabilities#
No XR capabilities.
const XR_MONO = 1 enum Capabilities#
This interface can work with normal rendering output (non-HMD based AR).
const XR_STEREO = 2 enum Capabilities#
This interface supports stereoscopic rendering.
const XR_QUAD = 4 enum Capabilities#
This interface supports quad rendering (not yet supported by Godot).
const XR_VR = 8 enum Capabilities#
This interface supports VR.
const XR_AR = 16 enum Capabilities#
This interface supports AR (video background and real world tracking).
const XR_EXTERNAL = 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 get_render_target_size). Using a separate viewport node frees up the main viewport for other purposes.
const XR_NORMAL_TRACKING = 0 enum TrackingStatus#
Tracking is behaving as expected.
const XR_EXCESSIVE_MOTION = 1 enum TrackingStatus#
Tracking is hindered by excessive motion (the player is moving faster than tracking can keep up).
const XR_INSUFFICIENT_FEATURES = 2 enum TrackingStatus#
Tracking is hindered by insufficient features, it's too dark (for camera-based tracking), player is blocked, etc.
const XR_UNKNOWN_TRACKING = 3 enum TrackingStatus#
We don't know the status of the tracking or this interface does not provide feedback.
const XR_NOT_TRACKING = 4 enum TrackingStatus#
Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.).
const XR_PLAY_AREA_UNKNOWN = 0 enum PlayAreaMode#
Play area mode not set or not available.
const XR_PLAY_AREA_3DOF = 1 enum PlayAreaMode#
Play area only supports orientation tracking, no positional tracking, area will center around player.
const XR_PLAY_AREA_SITTING = 2 enum PlayAreaMode#
Player is in seated position, limited positional tracking, fixed guardian around player.
const XR_PLAY_AREA_ROOMSCALE = 3 enum PlayAreaMode#
Player is free to move around, full positional tracking.
const XR_PLAY_AREA_STAGE = 4 enum PlayAreaMode#
Same as 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 XRServer.center_on_hmd.
const XR_ENV_BLEND_MODE_OPAQUE = 0 enum EnvironmentBlendMode#
Opaque blend mode. This is typically used for VR devices.
const XR_ENV_BLEND_MODE_ADDITIVE = 1 enum EnvironmentBlendMode#
Additive blend mode. This is typically used for AR devices or VR devices with passthrough.
const XR_ENV_BLEND_MODE_ALPHA_BLEND = 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.
Constructors #
Enums #
Capabilities#
enum Capabilities {
XR_NONE = 0,
XR_MONO = 1,
XR_STEREO = 2,
XR_QUAD = 4,
XR_VR = 8,
XR_AR = 16,
XR_EXTERNAL = 32,
}TrackingStatus#
enum TrackingStatus {
XR_NORMAL_TRACKING = 0,
XR_EXCESSIVE_MOTION = 1,
XR_INSUFFICIENT_FEATURES = 2,
XR_UNKNOWN_TRACKING = 3,
XR_NOT_TRACKING = 4,
}PlayAreaMode#
enum PlayAreaMode {
XR_PLAY_AREA_UNKNOWN = 0,
XR_PLAY_AREA_3DOF = 1,
XR_PLAY_AREA_SITTING = 2,
XR_PLAY_AREA_ROOMSCALE = 3,
XR_PLAY_AREA_STAGE = 4,
}EnvironmentBlendMode#
enum EnvironmentBlendMode {
XR_ENV_BLEND_MODE_OPAQUE = 0,
XR_ENV_BLEND_MODE_ADDITIVE = 1,
XR_ENV_BLEND_MODE_ALPHA_BLEND = 2,
} Operators #
Signals #
signal play_area_changed(mode: int)#
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.