Skip to content

Commit

Permalink
Merge pull request #52003 from BastiaanOlij/xr_interface_extension
Browse files Browse the repository at this point in the history
Adding GDExtension support to XRInterface
  • Loading branch information
BastiaanOlij authored Aug 27, 2021
2 parents f6f5e0f + 86ff7f8 commit c5f62fa
Show file tree
Hide file tree
Showing 28 changed files with 495 additions and 1,009 deletions.
33 changes: 18 additions & 15 deletions doc/classes/XRInterface.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="XRInterface" inherits="RefCounted" version="4.0">
<brief_description>
Base class for an AR/VR interface implementation.
Base class for an XR interface implementation.
</brief_description>
<description>
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 GDNative modules (note that for GDNative the subclass XRScriptInterface should be used). Part of the interface is exposed to GDScript so you can detect, enable and configure an AR or VR platform.
Expand All @@ -26,17 +26,17 @@
<method name="get_name" qualifiers="const">
<return type="StringName" />
<description>
Returns the name of this interface (OpenVR, OpenHMD, ARKit, etc).
Returns the name of this interface (OpenXR, OpenVR, OpenHMD, ARKit, etc).
</description>
</method>
<method name="get_render_targetsize">
<method name="get_render_target_size">
<return type="Vector2" />
<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>
<method name="get_tracking_status" qualifiers="const">
<return type="int" enum="XRInterface.Tracking_status" />
<return type="int" enum="XRInterface.TrackingStatus" />
<description>
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.
</description>
Expand All @@ -52,11 +52,17 @@
<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.
After initializing the interface you want to use you then need to enable the AR/VR mode of a viewport and rendering should commence.
[b]Note:[/b] You must enable the AR/VR mode on the main viewport for any device that uses the main output of Godot, such as for mobile VR.
[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.
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.
</description>
</method>
<method name="is_initialized" qualifiers="const">
<return type="bool" />
<description>
Is [code]true[/code] if this interface has been initialised.
</description>
</method>
<method name="uninitialize">
<return type="void" />
<description>
Expand All @@ -68,10 +74,7 @@
<member name="ar_is_anchor_detection_enabled" type="bool" setter="set_anchor_detection_is_enabled" getter="get_anchor_detection_is_enabled" default="false">
On an AR interface, [code]true[/code] if anchor detection is enabled.
</member>
<member name="interface_is_initialized" type="bool" setter="set_is_initialized" getter="is_initialized" default="false">
[code]true[/code] if this interface been initialized.
</member>
<member name="interface_is_primary" type="bool" setter="set_is_primary" getter="is_primary" default="false">
<member name="interface_is_primary" type="bool" setter="set_primary" getter="is_primary" default="false">
[code]true[/code] if this is the primary interface.
</member>
</members>
Expand All @@ -89,7 +92,7 @@
This interface supports AR (video background and real world tracking).
</constant>
<constant name="XR_EXTERNAL" value="8" 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_targetsize]). Using a separate viewport node frees up the main viewport for other purposes.
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.
</constant>
<constant name="EYE_MONO" value="0" enum="Eyes">
Mono output, this is mostly used internally when retrieving positioning information for our camera node or when stereo scopic rendering is not supported.
Expand All @@ -100,19 +103,19 @@
<constant name="EYE_RIGHT" value="2" enum="Eyes">
Right eye output, this is mostly used internally when rendering the image for the right eye and obtaining positioning and projection information.
</constant>
<constant name="XR_NORMAL_TRACKING" value="0" enum="Tracking_status">
<constant name="XR_NORMAL_TRACKING" value="0" enum="TrackingStatus">
Tracking is behaving as expected.
</constant>
<constant name="XR_EXCESSIVE_MOTION" value="1" enum="Tracking_status">
<constant name="XR_EXCESSIVE_MOTION" value="1" enum="TrackingStatus">
Tracking is hindered by excessive motion (the player is moving faster than tracking can keep up).
</constant>
<constant name="XR_INSUFFICIENT_FEATURES" value="2" enum="Tracking_status">
<constant name="XR_INSUFFICIENT_FEATURES" value="2" enum="TrackingStatus">
Tracking is hindered by insufficient features, it's too dark (for camera-based tracking), player is blocked, etc.
</constant>
<constant name="XR_UNKNOWN_TRACKING" value="3" enum="Tracking_status">
<constant name="XR_UNKNOWN_TRACKING" value="3" enum="TrackingStatus">
We don't know the status of the tracking or this interface does not provide feedback.
</constant>
<constant name="XR_NOT_TRACKING" value="4" enum="Tracking_status">
<constant name="XR_NOT_TRACKING" value="4" enum="TrackingStatus">
Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.).
</constant>
</constants>
Expand Down
126 changes: 126 additions & 0 deletions doc/classes/XRInterfaceExtension.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="XRInterfaceExtension" inherits="XRInterface" version="4.0">
<brief_description>
Base class for XR interface extensions (plugins).
</brief_description>
<description>
External XR interface plugins should inherit from this class.
</description>
<tutorials>
</tutorials>
<methods>
<method name="_commit_views" qualifiers="virtual">
<return type="void" />
<argument index="0" name="" type="RID" />
<argument index="1" name="" type="Rect2" />
<description>
</description>
</method>
<method name="_get_anchor_detection_is_enabled" qualifiers="virtual const">
<return type="bool" />
<description>
</description>
</method>
<method name="_get_camera_feed_id" qualifiers="virtual const">
<return type="int" />
<description>
</description>
</method>
<method name="_get_camera_transform" qualifiers="virtual">
<return type="Transform3D" />
<description>
</description>
</method>
<method name="_get_capabilities" qualifiers="virtual const">
<return type="int" />
<description>
</description>
</method>
<method name="_get_name" qualifiers="virtual const">
<return type="StringName" />
<description>
</description>
</method>
<method name="_get_projection_for_view" qualifiers="virtual">
<return type="PackedFloat64Array" />
<argument index="0" name="view" type="int" />
<argument index="1" name="aspect" type="float" />
<argument index="2" name="z_near" type="float" />
<argument index="3" name="z_far" type="float" />
<description>
</description>
</method>
<method name="_get_render_target_size" qualifiers="virtual">
<return type="Vector2" />
<description>
</description>
</method>
<method name="_get_tracking_status" qualifiers="virtual const">
<return type="int" />
<description>
</description>
</method>
<method name="_get_transform_for_view" qualifiers="virtual">
<return type="Transform3D" />
<argument index="0" name="view" type="int" />
<argument index="1" name="cam_transform" type="Transform3D" />
<description>
</description>
</method>
<method name="_get_view_count" qualifiers="virtual">
<return type="int" />
<description>
</description>
</method>
<method name="_initialize" qualifiers="virtual">
<return type="bool" />
<description>
</description>
</method>
<method name="_is_initialized" qualifiers="virtual const">
<return type="bool" />
<description>
</description>
</method>
<method name="_notification" qualifiers="virtual">
<return type="void" />
<argument index="0" name="what" type="int" />
<description>
</description>
</method>
<method name="_process" qualifiers="virtual">
<return type="void" />
<description>
</description>
</method>
<method name="_set_anchor_detection_is_enabled" qualifiers="virtual">
<return type="void" />
<argument index="0" name="enabled" type="bool" />
<description>
</description>
</method>
<method name="_uninitialize" qualifiers="virtual">
<return type="void" />
<description>
</description>
</method>
<method name="add_blit">
<return type="void" />
<argument index="0" name="render_target" type="RID" />
<argument index="1" name="rect" type="Rect2i" />
<argument index="2" name="use_layer" type="bool" />
<argument index="3" name="layer" type="int" />
<argument index="4" name="apply_lens_distortion" type="bool" />
<argument index="5" name="eye_center" type="Vector2" />
<argument index="6" name="k1" type="float" />
<argument index="7" name="k2" type="float" />
<argument index="8" name="upscale" type="float" />
<argument index="9" name="aspect_ratio" type="float" />
<description>
Blits our render results to screen optionally applying lens distortion. This can only be called while processing [code]_commit_views[/code].
</description>
</method>
</methods>
<constants>
</constants>
</class>
7 changes: 0 additions & 7 deletions doc/classes/XRServer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@
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.
</description>
</method>
<method name="clear_primary_interface_if">
<return type="void" />
<argument index="0" name="interface" type="XRInterface" />
<description>
Clears our current primary interface if it is set to the provided interface.
</description>
</method>
<method name="find_interface" qualifiers="const">
<return type="XRInterface" />
<argument index="0" name="name" type="String" />
Expand Down
1 change: 0 additions & 1 deletion modules/gdnative/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def configure(env):

def get_doc_classes():
return [
"XRInterfaceGDNative",
"GDNative",
"GDNativeLibrary",
"MultiplayerPeerGDNative",
Expand Down
2 changes: 1 addition & 1 deletion modules/gdnative/doc_classes/GDNativeLibrary.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
An external library containing functions or script classes to use in Godot.
</brief_description>
<description>
A GDNative library can implement [NativeScript]s, global functions to call with the [GDNative] class, or low-level engine extensions through interfaces such as [XRInterfaceGDNative]. The library must be compiled for each platform and architecture that the project will run on.
A GDNative library can implement [NativeScript]s, global functions to call with the [GDNative] class, or low-level engine extensions through interfaces such as XRInterfaceGDNative. The library must be compiled for each platform and architecture that the project will run on.
</description>
<tutorials>
<link title="GDNative C example">https://docs.godotengine.org/en/latest/tutorials/plugins/gdnative/gdnative-c-example.html</link>
Expand Down
15 changes: 0 additions & 15 deletions modules/gdnative/doc_classes/XRInterfaceGDNative.xml

This file was deleted.

Loading

0 comments on commit c5f62fa

Please sign in to comment.