Documentation
¶
Overview ¶
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 graphics.gd/classdb/XRServer.
Index ¶
- type Advanced
- type Any
- type Capabilities
- type EnvironmentBlendMode
- type Extension
- type ID
- type Instance
- func (self Instance) ArIsAnchorDetectionEnabled() bool
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRefCounted() [1]gd.RefCounted
- func (self Instance) AsXRInterface() Instance
- func (self Instance) EnvironmentBlendMode() EnvironmentBlendMode
- func (self Instance) GetCameraFeedId() int
- func (self Instance) GetCapabilities() int
- func (self Instance) GetName() string
- func (self Instance) GetPlayArea() []Vector3.XYZ
- func (self Instance) GetProjectionForView(view int, aspect Float.X, near Float.X, far Float.X) Projection.XYZW
- func (self Instance) GetRenderTargetSize() Vector2.XY
- func (self Instance) GetSupportedEnvironmentBlendModes() []EnvironmentBlendMode
- func (self Instance) GetSystemInfo() map[string]interface{}
- func (self Instance) GetTrackingStatus() TrackingStatus
- func (self Instance) GetTransformForView(view int, cam_transform Transform3D.BasisOrigin) Transform3D.BasisOrigin
- func (self Instance) GetViewCount() int
- func (self Instance) ID() ID
- func (self Instance) Initialize() bool
- func (self Instance) InterfaceIsPrimary() bool
- func (self Instance) IsInitialized() bool
- func (self Instance) IsPassthroughEnabled() bool
- func (self Instance) IsPassthroughSupported() bool
- func (self Instance) OnPlayAreaChanged(cb func(mode int), flags ...Signal.Flags)
- func (self Instance) SetArIsAnchorDetectionEnabled(value bool)
- func (self Instance) SetEnvironmentBlendMode(value EnvironmentBlendMode)
- func (self Instance) SetInterfaceIsPrimary(value bool)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetXrPlayAreaMode(value PlayAreaMode)
- func (self Instance) StartPassthrough() bool
- func (self Instance) StopPassthrough()
- func (self Instance) SupportsPlayAreaMode(mode PlayAreaMode) bool
- func (self Instance) TriggerHapticPulse(action_name string, tracker_name string, frequency Float.X, amplitude Float.X, ...)
- func (self Instance) Uninitialize()
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) XrPlayAreaMode() PlayAreaMode
- type PlayAreaMode
- type TrackingStatus
- type VRSTextureFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Capabilities ¶
type Capabilities int //gd:XRInterface.Capabilities
const ( // No XR capabilities. XrNone Capabilities = 0 // This interface can work with normal rendering output (non-HMD based AR). XrMono Capabilities = 1 // This interface supports stereoscopic rendering. XrStereo Capabilities = 2 // This interface supports quad rendering (not yet supported by Godot). XrQuad Capabilities = 4 // This interface supports VR. XrVr Capabilities = 8 // This interface supports AR (video background and real world tracking). XrAr Capabilities = 16 // 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 [Instance.GetRenderTargetSize]). Using a separate viewport node frees up the main viewport for other purposes. XrExternal Capabilities = 32 )
type EnvironmentBlendMode ¶
type EnvironmentBlendMode int //gd:XRInterface.EnvironmentBlendMode
const ( // Opaque blend mode. This is typically used for VR devices. XrEnvBlendModeOpaque EnvironmentBlendMode = 0 // Additive blend mode. This is typically used for AR devices or VR devices with passthrough. XrEnvBlendModeAdditive EnvironmentBlendMode = 1 // 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. XrEnvBlendModeAlphaBlend EnvironmentBlendMode = 2 )
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsRefCounted ¶
func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted
func (*Extension[T]) AsXRInterface ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.XRInterface
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) ArIsAnchorDetectionEnabled ¶
func (Instance) AsRefCounted ¶
func (self Instance) AsRefCounted() [1]gd.RefCounted
func (Instance) AsXRInterface ¶
func (Instance) EnvironmentBlendMode ¶
func (self Instance) EnvironmentBlendMode() EnvironmentBlendMode
func (Instance) GetCameraFeedId ¶
If this is an AR interface that requires displaying a camera feed as the background, this method returns the feed ID in the graphics.gd/classdb/CameraServer for this interface.
func (Instance) GetCapabilities ¶
Returns a combination of Capabilities flags providing information about the capabilities of this interface.
func (Instance) GetName ¶
Returns the name of this interface ("OpenXR", "OpenVR", "OpenHMD", "ARKit", etc.).
func (Instance) GetPlayArea ¶
Returns an array of vectors that represent the physical play area mapped to the virtual space around the graphics.gd/classdb/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 (Instance) GetProjectionForView ¶
func (self Instance) GetProjectionForView(view int, aspect Float.X, near Float.X, far Float.X) Projection.XYZW
Returns the projection matrix for a view/eye.
func (Instance) GetRenderTargetSize ¶
Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform.
func (Instance) GetSupportedEnvironmentBlendModes ¶
func (self Instance) GetSupportedEnvironmentBlendModes() []EnvironmentBlendMode
Returns the an array of supported environment blend modes, see [XRInterface.EnvironmentBlendMode].
func (Instance) GetSystemInfo ¶
Returns a data structure 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 Instance.Initialize was successfully called.
func (Instance) GetTrackingStatus ¶
func (self Instance) GetTrackingStatus() 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 (Instance) GetTransformForView ¶
func (self Instance) GetTransformForView(view int, cam_transform Transform3D.BasisOrigin) Transform3D.BasisOrigin
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 graphics.gd/classdb/Node3D.Instance.GlobalTransform of the current XROrigin3D.
func (Instance) GetViewCount ¶
Returns the number of views that need to be rendered for this device. 1 for Monoscopic, 2 for Stereoscopic.
func (Instance) Initialize ¶
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.
func (Instance) InterfaceIsPrimary ¶
func (Instance) IsInitialized ¶
Returns true if this interface has been initialized.
func (Instance) IsPassthroughEnabled ¶
Returns true if passthrough is enabled.
func (Instance) IsPassthroughSupported ¶
Returns true if this interface supports passthrough.
func (Instance) OnPlayAreaChanged ¶
func (Instance) SetArIsAnchorDetectionEnabled ¶
func (Instance) SetEnvironmentBlendMode ¶
func (self Instance) SetEnvironmentBlendMode(value EnvironmentBlendMode)
func (Instance) SetInterfaceIsPrimary ¶
func (Instance) SetXrPlayAreaMode ¶
func (self Instance) SetXrPlayAreaMode(value PlayAreaMode)
func (Instance) StartPassthrough ¶
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 (Instance) SupportsPlayAreaMode ¶
func (self Instance) SupportsPlayAreaMode(mode PlayAreaMode) bool
Call this to find out if a given play area mode is supported by this interface.
func (Instance) TriggerHapticPulse ¶
func (self Instance) TriggerHapticPulse(action_name string, tracker_name string, frequency Float.X, amplitude Float.X, duration_sec Float.X, delay_sec Float.X)
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 (Instance) XrPlayAreaMode ¶
func (self Instance) XrPlayAreaMode() PlayAreaMode
type PlayAreaMode ¶
type PlayAreaMode int //gd:XRInterface.PlayAreaMode
const ( // Play area mode not set or not available. XrPlayAreaUnknown PlayAreaMode = 0 // Play area only supports orientation tracking, no positional tracking, area will center around player. XrPlayArea3dof PlayAreaMode = 1 // Player is in seated position, limited positional tracking, fixed guardian around player. XrPlayAreaSitting PlayAreaMode = 2 // Player is free to move around, full positional tracking. XrPlayAreaRoomscale PlayAreaMode = 3 // Same as [XrPlayAreaRoomscale] 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 [graphics.gd/classdb/XRServer.CenterOnHmd]. XrPlayAreaStage PlayAreaMode = 4 // Custom play area set by a GDExtension. XrPlayAreaCustom PlayAreaMode = 2147483647 )
type TrackingStatus ¶
type TrackingStatus int //gd:XRInterface.TrackingStatus
const ( // Tracking is behaving as expected. XrNormalTracking TrackingStatus = 0 // Tracking is hindered by excessive motion (the player is moving faster than tracking can keep up). XrExcessiveMotion TrackingStatus = 1 // Tracking is hindered by insufficient features, it's too dark (for camera-based tracking), player is blocked, etc. XrInsufficientFeatures TrackingStatus = 2 // We don't know the status of the tracking or this interface does not provide feedback. XrUnknownTracking TrackingStatus = 3 // Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.). XrNotTracking TrackingStatus = 4 )
type VRSTextureFormat ¶
type VRSTextureFormat int //gd:XRInterface.VRSTextureFormat
const ( // The texture format is the same as returned by [graphics.gd/classdb/XRVRS.Instance.MakeVrsTexture]. XrVrsTextureFormatUnified VRSTextureFormat = 0 // The texture format is the same as expected by the Vulkan VK_KHR_fragment_shading_rate extension. XrVrsTextureFormatFragmentShadingRate VRSTextureFormat = 1 // The texture format is the same as expected by the Vulkan VK_EXT_fragment_density_map extension. XrVrsTextureFormatFragmentDensityMap VRSTextureFormat = 2 )