Renaming all ARVR nodes to XR
This commit is contained in:
parent
23d786d6fb
commit
afc8c6391c
|
@ -12,8 +12,8 @@
|
|||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="ARVRServer" type="ARVRServer" setter="" getter="">
|
||||
The [ARVRServer] singleton.
|
||||
<member name="XRServer" type="XRServer" setter="" getter="">
|
||||
The [XRServer] singleton.
|
||||
</member>
|
||||
<member name="AudioServer" type="AudioServer" setter="" getter="">
|
||||
The [AudioServer] singleton.
|
||||
|
|
|
@ -3067,15 +3067,15 @@
|
|||
Sets when the viewport should be updated. See [enum ViewportUpdateMode] constants for options.
|
||||
</description>
|
||||
</method>
|
||||
<method name="viewport_set_use_arvr">
|
||||
<method name="viewport_set_use_xr">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="viewport" type="RID">
|
||||
</argument>
|
||||
<argument index="1" name="use_arvr" type="bool">
|
||||
<argument index="1" name="use_xr" type="bool">
|
||||
</argument>
|
||||
<description>
|
||||
If [code]true[/code], the viewport uses augmented or virtual reality technologies. See [ARVRInterface].
|
||||
If [code]true[/code], the viewport uses augmented or virtual reality technologies. See [XRInterface].
|
||||
</description>
|
||||
</method>
|
||||
</methods>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<methods>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="arvr" type="bool" setter="set_use_arvr" getter="is_using_arvr" default="false">
|
||||
<member name="xr" type="bool" setter="set_use_xr" getter="is_using_xr" default="false">
|
||||
If [code]true[/code], the sub-viewport will be used in AR/VR process.
|
||||
</member>
|
||||
<member name="render_target_clear_mode" type="int" setter="set_clear_mode" getter="get_clear_mode" enum="SubViewport.ClearMode" default="0">
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="ARVRAnchor" inherits="Node3D" version="4.0">
|
||||
<class name="XRAnchor3D" inherits="Node3D" version="4.0">
|
||||
<brief_description>
|
||||
An anchor point in AR space.
|
||||
</brief_description>
|
||||
<description>
|
||||
The [ARVRAnchor] point is a spatial node that maps a real world location identified by the AR platform to a position within the game world. For example, as long as plane detection in ARKit is on, ARKit will identify and update the position of planes (tables, floors, etc) and create anchors for them.
|
||||
The [XRAnchor3D] point is a spatial node that maps a real world location identified by the AR platform to a position within the game world. For example, as long as plane detection in ARKit is on, ARKit will identify and update the position of planes (tables, floors, etc) and create anchors for them.
|
||||
This node is mapped to one of the anchors through its unique ID. When you receive a signal that a new anchor is available, you should add this node to your scene for that anchor. You can predefine nodes and set the ID; the nodes will simply remain on 0,0,0 until a plane is recognized.
|
||||
Keep in mind that, as long as plane detection is enabled, the size, placing and orientation of an anchor will be updated as the detection logic learns more about the real world out there especially if only part of the surface is in view.
|
||||
</description>
|
||||
|
@ -29,7 +29,7 @@
|
|||
<return type="Mesh">
|
||||
</return>
|
||||
<description>
|
||||
If provided by the [ARVRInterface], this returns a mesh object for the anchor. For an anchor, this can be a shape related to the object being tracked or it can be a mesh that provides topology related to the anchor and can be used to create shadows/reflections on surfaces or for generating collision shapes.
|
||||
If provided by the [XRInterface], this returns a mesh object for the anchor. For an anchor, this can be a shape related to the object being tracked or it can be a mesh that provides topology related to the anchor and can be used to create shadows/reflections on surfaces or for generating collision shapes.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_plane" qualifiers="const">
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="ARVRCamera" inherits="Camera3D" version="4.0">
|
||||
<class name="XRCamera3D" inherits="Camera3D" version="4.0">
|
||||
<brief_description>
|
||||
A camera node with a few overrules for AR/VR applied, such as location tracking.
|
||||
</brief_description>
|
||||
<description>
|
||||
This is a helper spatial node for our camera; note that, if stereoscopic rendering is applicable (VR-HMD), most of the camera properties are ignored, as the HMD information overrides them. The only properties that can be trusted are the near and far planes.
|
||||
The position and orientation of this node is automatically updated by the ARVR Server to represent the location of the HMD if such tracking is available and can thus be used by game logic. Note that, in contrast to the ARVR Controller, the render thread has access to the most up-to-date tracking data of the HMD and the location of the ARVRCamera can lag a few milliseconds behind what is used for rendering as a result.
|
||||
The position and orientation of this node is automatically updated by the XR Server to represent the location of the HMD if such tracking is available and can thus be used by game logic. Note that, in contrast to the XR Controller, the render thread has access to the most up-to-date tracking data of the HMD and the location of the XRCamera3D can lag a few milliseconds behind what is used for rendering as a result.
|
||||
</description>
|
||||
<tutorials>
|
||||
<link>https://docs.godotengine.org/en/latest/tutorials/vr/index.html</link>
|
|
@ -1,12 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="ARVRController" inherits="Node3D" version="4.0">
|
||||
<class name="XRController3D" inherits="Node3D" version="4.0">
|
||||
<brief_description>
|
||||
A spatial node representing a spatially-tracked controller.
|
||||
</brief_description>
|
||||
<description>
|
||||
This is a helper spatial node that is linked to the tracking of controllers. It also offers several handy passthroughs to the state of buttons and such on the controllers.
|
||||
Controllers are linked by their ID. You can create controller nodes before the controllers are available. If your game always uses two controllers (one for each hand), you can predefine the controllers with ID 1 and 2; they will become active as soon as the controllers are identified. If you expect additional controllers to be used, you should react to the signals and add ARVRController nodes to your scene.
|
||||
The position of the controller node is automatically updated by the [ARVRServer]. This makes this node ideal to add child nodes to visualize the controller.
|
||||
Controllers are linked by their ID. You can create controller nodes before the controllers are available. If your game always uses two controllers (one for each hand), you can predefine the controllers with ID 1 and 2; they will become active as soon as the controllers are identified. If you expect additional controllers to be used, you should react to the signals and add XRController3D nodes to your scene.
|
||||
The position of the controller node is automatically updated by the [XRServer]. This makes this node ideal to add child nodes to visualize the controller.
|
||||
</description>
|
||||
<tutorials>
|
||||
<link>https://docs.godotengine.org/en/latest/tutorials/vr/index.html</link>
|
||||
|
@ -20,17 +20,17 @@
|
|||
</description>
|
||||
</method>
|
||||
<method name="get_hand" qualifiers="const">
|
||||
<return type="int" enum="ARVRPositionalTracker.TrackerHand">
|
||||
<return type="int" enum="XRPositionalTracker.TrackerHand">
|
||||
</return>
|
||||
<description>
|
||||
Returns the hand holding this controller, if known. See [enum ARVRPositionalTracker.TrackerHand].
|
||||
Returns the hand holding this controller, if known. See [enum XRPositionalTracker.TrackerHand].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_is_active" qualifiers="const">
|
||||
<return type="bool">
|
||||
</return>
|
||||
<description>
|
||||
Returns [code]true[/code] if the bound controller is active. ARVR systems attempt to track active controllers.
|
||||
Returns [code]true[/code] if the bound controller is active. XR systems attempt to track active controllers.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_joystick_axis" qualifiers="const">
|
||||
|
@ -46,14 +46,14 @@
|
|||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Returns the ID of the joystick object bound to this. Every controller tracked by the [ARVRServer] that has buttons and axis will also be registered as a joystick within Godot. This means that all the normal joystick tracking and input mapping will work for buttons and axis found on the AR/VR controllers. This ID is purely offered as information so you can link up the controller with its joystick entry.
|
||||
Returns the ID of the joystick object bound to this. Every controller tracked by the [XRServer] that has buttons and axis will also be registered as a joystick within Godot. This means that all the normal joystick tracking and input mapping will work for buttons and axis found on the AR/VR controllers. This ID is purely offered as information so you can link up the controller with its joystick entry.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_mesh" qualifiers="const">
|
||||
<return type="Mesh">
|
||||
</return>
|
||||
<description>
|
||||
If provided by the [ARVRInterface], this returns a mesh associated with the controller. This can be used to visualize the controller.
|
||||
If provided by the [XRInterface], this returns a mesh associated with the controller. This can be used to visualize the controller.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_button_pressed" qualifiers="const">
|
||||
|
@ -70,11 +70,11 @@
|
|||
<member name="controller_id" type="int" setter="set_controller_id" getter="get_controller_id" default="1">
|
||||
The controller's ID.
|
||||
A controller ID of 0 is unbound and will always result in an inactive node. Controller ID 1 is reserved for the first controller that identifies itself as the left-hand controller and ID 2 is reserved for the first controller that identifies itself as the right-hand controller.
|
||||
For any other controller that the [ARVRServer] detects, we continue with controller ID 3.
|
||||
For any other controller that the [XRServer] detects, we continue with controller ID 3.
|
||||
When a controller is turned off, its slot is freed. This ensures controllers will keep the same ID even when controllers with lower IDs are turned off.
|
||||
</member>
|
||||
<member name="rumble" type="float" setter="set_rumble" getter="get_rumble" default="0.0">
|
||||
The degree to which the controller vibrates. Ranges from [code]0.0[/code] to [code]1.0[/code] with precision [code].01[/code]. If changed, updates [member ARVRPositionalTracker.rumble] accordingly.
|
||||
The degree to which the controller vibrates. Ranges from [code]0.0[/code] to [code]1.0[/code] with precision [code].01[/code]. If changed, updates [member XRPositionalTracker.rumble] accordingly.
|
||||
This is a useful property to animate if you want the controller to vibrate for a limited duration.
|
||||
</member>
|
||||
</members>
|
|
@ -1,11 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="ARVRInterface" inherits="Reference" version="4.0">
|
||||
<class name="XRInterface" inherits="Reference" version="4.0">
|
||||
<brief_description>
|
||||
Base class for an AR/VR 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 ARVRScriptInterface should be used). 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 [ARVRServer].
|
||||
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.
|
||||
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].
|
||||
</description>
|
||||
<tutorials>
|
||||
<link>https://docs.godotengine.org/en/latest/tutorials/vr/index.html</link>
|
||||
|
@ -40,7 +40,7 @@
|
|||
</description>
|
||||
</method>
|
||||
<method name="get_tracking_status" qualifiers="const">
|
||||
<return type="int" enum="ARVRInterface.Tracking_status">
|
||||
<return type="int" enum="XRInterface.Tracking_status">
|
||||
</return>
|
||||
<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.
|
||||
|
@ -84,19 +84,19 @@
|
|||
</member>
|
||||
</members>
|
||||
<constants>
|
||||
<constant name="ARVR_NONE" value="0" enum="Capabilities">
|
||||
No ARVR capabilities.
|
||||
<constant name="XR_NONE" value="0" enum="Capabilities">
|
||||
No XR capabilities.
|
||||
</constant>
|
||||
<constant name="ARVR_MONO" value="1" enum="Capabilities">
|
||||
<constant name="XR_MONO" value="1" enum="Capabilities">
|
||||
This interface can work with normal rendering output (non-HMD based AR).
|
||||
</constant>
|
||||
<constant name="ARVR_STEREO" value="2" enum="Capabilities">
|
||||
<constant name="XR_STEREO" value="2" enum="Capabilities">
|
||||
This interface supports stereoscopic rendering.
|
||||
</constant>
|
||||
<constant name="ARVR_AR" value="4" enum="Capabilities">
|
||||
<constant name="XR_AR" value="4" enum="Capabilities">
|
||||
This interface supports AR (video background and real world tracking).
|
||||
</constant>
|
||||
<constant name="ARVR_EXTERNAL" value="8" enum="Capabilities">
|
||||
<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.
|
||||
</constant>
|
||||
<constant name="EYE_MONO" value="0" enum="Eyes">
|
||||
|
@ -108,19 +108,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="ARVR_NORMAL_TRACKING" value="0" enum="Tracking_status">
|
||||
<constant name="XR_NORMAL_TRACKING" value="0" enum="Tracking_status">
|
||||
Tracking is behaving as expected.
|
||||
</constant>
|
||||
<constant name="ARVR_EXCESSIVE_MOTION" value="1" enum="Tracking_status">
|
||||
<constant name="XR_EXCESSIVE_MOTION" value="1" enum="Tracking_status">
|
||||
Tracking is hindered by excessive motion (the player is moving faster than tracking can keep up).
|
||||
</constant>
|
||||
<constant name="ARVR_INSUFFICIENT_FEATURES" value="2" enum="Tracking_status">
|
||||
<constant name="XR_INSUFFICIENT_FEATURES" value="2" enum="Tracking_status">
|
||||
Tracking is hindered by insufficient features, it's too dark (for camera-based tracking), player is blocked, etc.
|
||||
</constant>
|
||||
<constant name="ARVR_UNKNOWN_TRACKING" value="3" enum="Tracking_status">
|
||||
<constant name="XR_UNKNOWN_TRACKING" value="3" enum="Tracking_status">
|
||||
We don't know the status of the tracking or this interface does not provide feedback.
|
||||
</constant>
|
||||
<constant name="ARVR_NOT_TRACKING" value="4" enum="Tracking_status">
|
||||
<constant name="XR_NOT_TRACKING" value="4" enum="Tracking_status">
|
||||
Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.).
|
||||
</constant>
|
||||
</constants>
|
|
@ -1,13 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="ARVROrigin" inherits="Node3D" version="4.0">
|
||||
<class name="XROrigin3D" inherits="Node3D" version="4.0">
|
||||
<brief_description>
|
||||
The origin point in AR/VR.
|
||||
</brief_description>
|
||||
<description>
|
||||
This is a special node within the AR/VR system that maps the physical location of the center of our tracking space to the virtual location within our game world.
|
||||
There should be only one of these nodes in your scene and you must have one. All the ARVRCamera, ARVRController and ARVRAnchor nodes should be direct children of this node for spatial tracking to work correctly.
|
||||
There should be only one of these nodes in your scene and you must have one. All the XRCamera3D, XRController3D and XRAnchor3D nodes should be direct children of this node for spatial tracking to work correctly.
|
||||
It is the position of this node that you update when your character needs to move through your game world while we're not moving in the real world. Movement in the real world is always in relation to this origin point.
|
||||
For example, if your character is driving a car, the ARVROrigin node should be a child node of this car. Or, if you're implementing a teleport system to move your character, you should change the position of this node.
|
||||
For example, if your character is driving a car, the XROrigin3D node should be a child node of this car. Or, if you're implementing a teleport system to move your character, you should change the position of this node.
|
||||
</description>
|
||||
<tutorials>
|
||||
<link>https://docs.godotengine.org/en/latest/tutorials/vr/index.html</link>
|
||||
|
@ -17,7 +17,7 @@
|
|||
<members>
|
||||
<member name="world_scale" type="float" setter="set_world_scale" getter="get_world_scale" default="1.0">
|
||||
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.
|
||||
[b]Note:[/b] This method is a passthrough to the [ARVRServer] itself.
|
||||
[b]Note:[/b] This method is a passthrough to the [XRServer] itself.
|
||||
</member>
|
||||
</members>
|
||||
<constants>
|
|
@ -1,19 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="ARVRPositionalTracker" inherits="Object" version="4.0">
|
||||
<class name="XRPositionalTracker" inherits="Object" version="4.0">
|
||||
<brief_description>
|
||||
A tracked object.
|
||||
</brief_description>
|
||||
<description>
|
||||
An instance of this object represents a device that is tracked, such as a controller or anchor point. HMDs aren't represented here as they are handled internally.
|
||||
As controllers are turned on and the AR/VR interface detects them, instances of this object are automatically added to this list of active tracking objects accessible through the [ARVRServer].
|
||||
The [ARVRController] and [ARVRAnchor] both consume objects of this type and should be used in your project. The positional trackers are just under-the-hood objects that make this all work. These are mostly exposed so that GDNative-based interfaces can interact with them.
|
||||
As controllers are turned on and the AR/VR interface detects them, instances of this object are automatically added to this list of active tracking objects accessible through the [XRServer].
|
||||
The [XRController3D] and [XRAnchor3D] both consume objects of this type and should be used in your project. The positional trackers are just under-the-hood objects that make this all work. These are mostly exposed so that GDNative-based interfaces can interact with them.
|
||||
</description>
|
||||
<tutorials>
|
||||
<link>https://docs.godotengine.org/en/latest/tutorials/vr/index.html</link>
|
||||
</tutorials>
|
||||
<methods>
|
||||
<method name="get_hand" qualifiers="const">
|
||||
<return type="int" enum="ARVRPositionalTracker.TrackerHand">
|
||||
<return type="int" enum="XRPositionalTracker.TrackerHand">
|
||||
</return>
|
||||
<description>
|
||||
Returns the hand holding this tracker, if known. See [enum TrackerHand] constants.
|
||||
|
@ -58,7 +58,7 @@
|
|||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Returns the internal tracker ID. This uniquely identifies the tracker per tracker type and matches the ID you need to specify for nodes such as the [ARVRController] and [ARVRAnchor] nodes.
|
||||
Returns the internal tracker ID. This uniquely identifies the tracker per tracker type and matches the ID you need to specify for nodes such as the [XRController3D] and [XRAnchor3D] nodes.
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_tracks_orientation" qualifiers="const">
|
||||
|
@ -85,7 +85,7 @@
|
|||
</description>
|
||||
</method>
|
||||
<method name="get_type" qualifiers="const">
|
||||
<return type="int" enum="ARVRServer.TrackerType">
|
||||
<return type="int" enum="XRServer.TrackerType">
|
||||
</return>
|
||||
<description>
|
||||
Returns the tracker's type.
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="ARVRServer" inherits="Object" version="4.0">
|
||||
<class name="XRServer" inherits="Object" version="4.0">
|
||||
<brief_description>
|
||||
Server for AR and VR features.
|
||||
</brief_description>
|
||||
|
@ -13,7 +13,7 @@
|
|||
<method name="center_on_hmd">
|
||||
<return type="void">
|
||||
</return>
|
||||
<argument index="0" name="rotation_mode" type="int" enum="ARVRServer.RotationMode">
|
||||
<argument index="0" name="rotation_mode" type="int" enum="XRServer.RotationMode">
|
||||
</argument>
|
||||
<argument index="1" name="keep_height" type="bool">
|
||||
</argument>
|
||||
|
@ -27,7 +27,7 @@
|
|||
</description>
|
||||
</method>
|
||||
<method name="find_interface" qualifiers="const">
|
||||
<return type="ARVRInterface">
|
||||
<return type="XRInterface">
|
||||
</return>
|
||||
<argument index="0" name="name" type="String">
|
||||
</argument>
|
||||
|
@ -43,7 +43,7 @@
|
|||
</description>
|
||||
</method>
|
||||
<method name="get_interface" qualifiers="const">
|
||||
<return type="ARVRInterface">
|
||||
<return type="XRInterface">
|
||||
</return>
|
||||
<argument index="0" name="idx" type="int">
|
||||
</argument>
|
||||
|
@ -69,7 +69,7 @@
|
|||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Returns the absolute timestamp (in μs) of the last [ARVRServer] commit of the AR/VR eyes to [RenderingServer]. The value comes from an internal call to [method OS.get_ticks_usec].
|
||||
Returns the absolute timestamp (in μs) of the last [XRServer] commit of the AR/VR eyes to [RenderingServer]. The value comes from an internal call to [method OS.get_ticks_usec].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_last_frame_usec">
|
||||
|
@ -83,7 +83,7 @@
|
|||
<return type="int">
|
||||
</return>
|
||||
<description>
|
||||
Returns the absolute timestamp (in μs) of the last [ARVRServer] process callback. The value comes from an internal call to [method OS.get_ticks_usec].
|
||||
Returns the absolute timestamp (in μs) of the last [XRServer] process callback. The value comes from an internal call to [method OS.get_ticks_usec].
|
||||
</description>
|
||||
</method>
|
||||
<method name="get_reference_frame" qualifiers="const">
|
||||
|
@ -94,7 +94,7 @@
|
|||
</description>
|
||||
</method>
|
||||
<method name="get_tracker" qualifiers="const">
|
||||
<return type="ARVRPositionalTracker">
|
||||
<return type="XRPositionalTracker">
|
||||
</return>
|
||||
<argument index="0" name="idx" type="int">
|
||||
</argument>
|
||||
|
@ -111,8 +111,8 @@
|
|||
</method>
|
||||
</methods>
|
||||
<members>
|
||||
<member name="primary_interface" type="ARVRInterface" setter="set_primary_interface" getter="get_primary_interface">
|
||||
The primary [ARVRInterface] currently bound to the [ARVRServer].
|
||||
<member name="primary_interface" type="XRInterface" setter="set_primary_interface" getter="get_primary_interface">
|
||||
The primary [XRInterface] currently bound to the [XRServer].
|
||||
</member>
|
||||
<member name="world_scale" type="float" setter="set_world_scale" getter="get_world_scale" default="1.0">
|
||||
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.
|
||||
|
@ -141,7 +141,7 @@
|
|||
<argument index="2" name="id" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Emitted when a new tracker has been added. If you don't use a fixed number of controllers or if you're using [ARVRAnchor]s for an AR solution, it is important to react to this signal to add the appropriate [ARVRController] or [ARVRAnchor] nodes related to this new tracker.
|
||||
Emitted when a new tracker has been added. If you don't use a fixed number of controllers or if you're using [XRAnchor3D]s for an AR solution, it is important to react to this signal to add the appropriate [XRController3D] or [XRAnchor3D] nodes related to this new tracker.
|
||||
</description>
|
||||
</signal>
|
||||
<signal name="tracker_removed">
|
||||
|
@ -152,7 +152,7 @@
|
|||
<argument index="2" name="id" type="int">
|
||||
</argument>
|
||||
<description>
|
||||
Emitted when a tracker is removed. You should remove any [ARVRController] or [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).
|
||||
Emitted when a tracker is removed. You should remove any [XRController3D] or [XRAnchor3D] 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).
|
||||
</description>
|
||||
</signal>
|
||||
</signals>
|
|
@ -61,7 +61,6 @@
|
|||
#include "scene/main/window.h"
|
||||
#include "scene/register_scene_types.h"
|
||||
#include "scene/resources/packed_scene.h"
|
||||
#include "servers/arvr_server.h"
|
||||
#include "servers/audio_server.h"
|
||||
#include "servers/camera_server.h"
|
||||
#include "servers/display_server.h"
|
||||
|
@ -72,6 +71,7 @@
|
|||
#include "servers/register_server_types.h"
|
||||
#include "servers/rendering/rendering_server_raster.h"
|
||||
#include "servers/rendering/rendering_server_wrap_mt.h"
|
||||
#include "servers/xr_server.h"
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
#include "editor/doc_data.h"
|
||||
|
@ -105,7 +105,7 @@ static AudioServer *audio_server = nullptr;
|
|||
static DisplayServer *display_server = nullptr;
|
||||
static RenderingServer *rendering_server = nullptr;
|
||||
static CameraServer *camera_server = nullptr;
|
||||
static ARVRServer *arvr_server = nullptr;
|
||||
static XRServer *xr_server = nullptr;
|
||||
static PhysicsServer3D *physics_server = nullptr;
|
||||
static PhysicsServer2D *physics_2d_server = nullptr;
|
||||
static NavigationServer3D *navigation_server = nullptr;
|
||||
|
@ -1297,8 +1297,8 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
|
|||
audio_server = memnew(AudioServer);
|
||||
audio_server->init();
|
||||
|
||||
// also init our arvr_server from here
|
||||
arvr_server = memnew(ARVRServer);
|
||||
// also init our xr_server from here
|
||||
xr_server = memnew(XRServer);
|
||||
|
||||
register_core_singletons();
|
||||
|
||||
|
@ -2276,9 +2276,9 @@ void Main::cleanup() {
|
|||
EditorNode::unregister_editor_types();
|
||||
#endif
|
||||
|
||||
if (arvr_server) {
|
||||
if (xr_server) {
|
||||
// cleanup now before we pull the rug from underneath...
|
||||
memdelete(arvr_server);
|
||||
memdelete(xr_server);
|
||||
}
|
||||
|
||||
ImageLoader::cleanup();
|
||||
|
|
|
@ -31,9 +31,9 @@
|
|||
#ifndef ARKIT_INTERFACE_H
|
||||
#define ARKIT_INTERFACE_H
|
||||
|
||||
#include "servers/arvr/arvr_interface.h"
|
||||
#include "servers/arvr/arvr_positional_tracker.h"
|
||||
#include "servers/camera/camera_feed.h"
|
||||
#include "servers/xr/xr_interface.h"
|
||||
#include "servers/xr/xr_positional_tracker.h"
|
||||
|
||||
/**
|
||||
@author Bastiaan Olij <mux213@gmail.com>
|
||||
|
@ -44,8 +44,8 @@
|
|||
// forward declaration for some needed objects
|
||||
class ARKitShader;
|
||||
|
||||
class ARKitInterface : public ARVRInterface {
|
||||
GDCLASS(ARKitInterface, ARVRInterface);
|
||||
class ARKitInterface : public XRInterface {
|
||||
GDCLASS(ARKitInterface, XRInterface);
|
||||
|
||||
private:
|
||||
bool initialized;
|
||||
|
@ -65,7 +65,7 @@ private:
|
|||
Vector<uint8_t> img_data[2];
|
||||
|
||||
struct anchor_map {
|
||||
ARVRPositionalTracker *tracker;
|
||||
XRPositionalTracker *tracker;
|
||||
unsigned char uuid[16];
|
||||
};
|
||||
|
||||
|
@ -73,7 +73,7 @@ private:
|
|||
unsigned int num_anchors;
|
||||
unsigned int max_anchors;
|
||||
anchor_map *anchors;
|
||||
ARVRPositionalTracker *get_anchor_for_uuid(const unsigned char *p_uuid);
|
||||
XRPositionalTracker *get_anchor_for_uuid(const unsigned char *p_uuid);
|
||||
void remove_anchor_for_uuid(const unsigned char *p_uuid);
|
||||
void remove_all_anchors();
|
||||
|
||||
|
@ -108,9 +108,9 @@ public:
|
|||
|
||||
virtual Size2 get_render_targetsize();
|
||||
virtual bool is_stereo();
|
||||
virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
|
||||
virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
|
||||
virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
|
||||
virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform);
|
||||
virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
|
||||
virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
|
||||
|
||||
virtual void process();
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ StringName ARKitInterface::get_name() const {
|
|||
}
|
||||
|
||||
int ARKitInterface::get_capabilities() const {
|
||||
return ARKitInterface::ARVR_MONO + ARKitInterface::ARVR_AR;
|
||||
return ARKitInterface::XR_MONO + ARKitInterface::XR_AR;
|
||||
}
|
||||
|
||||
Array ARKitInterface::raycast(Vector2 p_screen_coord) {
|
||||
|
@ -218,8 +218,8 @@ bool ARKitInterface::is_initialized() const {
|
|||
}
|
||||
|
||||
bool ARKitInterface::initialize() {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, false);
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, false);
|
||||
|
||||
if (!initialized) {
|
||||
print_line("initializing ARKit");
|
||||
|
@ -244,7 +244,7 @@ bool ARKitInterface::initialize() {
|
|||
transform = Transform();
|
||||
|
||||
// make this our primary interface
|
||||
arvr_server->set_primary_interface(this);
|
||||
xr_server->set_primary_interface(this);
|
||||
|
||||
// make sure we have our feed setup
|
||||
if (feed.is_null()) {
|
||||
|
@ -270,10 +270,10 @@ bool ARKitInterface::initialize() {
|
|||
|
||||
void ARKitInterface::uninitialize() {
|
||||
if (initialized) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
if (arvr_server != NULL) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
if (xr_server != NULL) {
|
||||
// no longer our primary interface
|
||||
arvr_server->clear_primary_interface_if(this);
|
||||
xr_server->clear_primary_interface_if(this);
|
||||
}
|
||||
|
||||
if (feed.is_valid()) {
|
||||
|
@ -303,22 +303,22 @@ Size2 ARKitInterface::get_render_targetsize() {
|
|||
return target_size;
|
||||
}
|
||||
|
||||
Transform ARKitInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) {
|
||||
Transform ARKitInterface::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
Transform transform_for_eye;
|
||||
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, transform_for_eye);
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, transform_for_eye);
|
||||
|
||||
if (initialized) {
|
||||
float world_scale = arvr_server->get_world_scale();
|
||||
float world_scale = xr_server->get_world_scale();
|
||||
|
||||
// just scale our origin point of our transform, note that we really shouldn't be using world_scale in ARKit but....
|
||||
transform_for_eye = transform;
|
||||
transform_for_eye.origin *= world_scale;
|
||||
|
||||
transform_for_eye = p_cam_transform * arvr_server->get_reference_frame() * transform_for_eye;
|
||||
transform_for_eye = p_cam_transform * xr_server->get_reference_frame() * transform_for_eye;
|
||||
} else {
|
||||
// huh? well just return what we got....
|
||||
transform_for_eye = p_cam_transform;
|
||||
|
@ -327,7 +327,7 @@ Transform ARKitInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, const
|
|||
return transform_for_eye;
|
||||
}
|
||||
|
||||
CameraMatrix ARKitInterface::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
|
||||
CameraMatrix ARKitInterface::get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
|
||||
// Remember our near and far, it will be used in process when we obtain our projection from our ARKit session.
|
||||
z_near = p_z_near;
|
||||
z_far = p_z_far;
|
||||
|
@ -335,7 +335,7 @@ CameraMatrix ARKitInterface::get_projection_for_eye(ARVRInterface::Eyes p_eye, r
|
|||
return projection;
|
||||
}
|
||||
|
||||
void ARKitInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
|
||||
void ARKitInterface::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
// We must have a valid render target
|
||||
|
@ -356,7 +356,7 @@ void ARKitInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_targ
|
|||
VSG::rasterizer->blit_render_target_to_screen(p_render_target, screen_rect, 0);
|
||||
}
|
||||
|
||||
ARVRPositionalTracker *ARKitInterface::get_anchor_for_uuid(const unsigned char *p_uuid) {
|
||||
XRPositionalTracker *ARKitInterface::get_anchor_for_uuid(const unsigned char *p_uuid) {
|
||||
if (anchors == NULL) {
|
||||
num_anchors = 0;
|
||||
max_anchors = 10;
|
||||
|
@ -377,8 +377,8 @@ ARVRPositionalTracker *ARKitInterface::get_anchor_for_uuid(const unsigned char *
|
|||
ERR_FAIL_NULL_V(anchors, NULL);
|
||||
}
|
||||
|
||||
ARVRPositionalTracker *new_tracker = memnew(ARVRPositionalTracker);
|
||||
new_tracker->set_type(ARVRServer::TRACKER_ANCHOR);
|
||||
XRPositionalTracker *new_tracker = memnew(XRPositionalTracker);
|
||||
new_tracker->set_type(XRServer::TRACKER_ANCHOR);
|
||||
|
||||
char tracker_name[256];
|
||||
sprintf(tracker_name, "Anchor %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", p_uuid[0], p_uuid[1], p_uuid[2], p_uuid[3], p_uuid[4], p_uuid[5], p_uuid[6], p_uuid[7], p_uuid[8], p_uuid[9], p_uuid[10], p_uuid[11], p_uuid[12], p_uuid[13], p_uuid[14], p_uuid[15]);
|
||||
|
@ -388,7 +388,7 @@ ARVRPositionalTracker *ARKitInterface::get_anchor_for_uuid(const unsigned char *
|
|||
new_tracker->set_name(name);
|
||||
|
||||
// add our tracker
|
||||
ARVRServer::get_singleton()->add_tracker(new_tracker);
|
||||
XRServer::get_singleton()->add_tracker(new_tracker);
|
||||
anchors[num_anchors].tracker = new_tracker;
|
||||
memcpy(anchors[num_anchors].uuid, p_uuid, 16);
|
||||
num_anchors++;
|
||||
|
@ -401,7 +401,7 @@ void ARKitInterface::remove_anchor_for_uuid(const unsigned char *p_uuid) {
|
|||
for (unsigned int i = 0; i < num_anchors; i++) {
|
||||
if (memcmp(anchors[i].uuid, p_uuid, 16) == 0) {
|
||||
// remove our tracker
|
||||
ARVRServer::get_singleton()->remove_tracker(anchors[i].tracker);
|
||||
XRServer::get_singleton()->remove_tracker(anchors[i].tracker);
|
||||
memdelete(anchors[i].tracker);
|
||||
|
||||
// bring remaining forward
|
||||
|
@ -421,7 +421,7 @@ void ARKitInterface::remove_all_anchors() {
|
|||
if (anchors != NULL) {
|
||||
for (unsigned int i = 0; i < num_anchors; i++) {
|
||||
// remove our tracker
|
||||
ARVRServer::get_singleton()->remove_tracker(anchors[i].tracker);
|
||||
XRServer::get_singleton()->remove_tracker(anchors[i].tracker);
|
||||
memdelete(anchors[i].tracker);
|
||||
};
|
||||
|
||||
|
@ -582,16 +582,16 @@ void ARKitInterface::process() {
|
|||
// strangely enough we have to states, rolling them up into one
|
||||
if (camera.trackingState == ARTrackingStateNotAvailable) {
|
||||
// no tracking, would be good if we black out the screen or something...
|
||||
tracking_state = ARVRInterface::ARVR_NOT_TRACKING;
|
||||
tracking_state = XRInterface::XR_NOT_TRACKING;
|
||||
} else {
|
||||
if (camera.trackingState == ARTrackingStateNormal) {
|
||||
tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING;
|
||||
tracking_state = XRInterface::XR_NORMAL_TRACKING;
|
||||
} else if (camera.trackingStateReason == ARTrackingStateReasonExcessiveMotion) {
|
||||
tracking_state = ARVRInterface::ARVR_EXCESSIVE_MOTION;
|
||||
tracking_state = XRInterface::XR_EXCESSIVE_MOTION;
|
||||
} else if (camera.trackingStateReason == ARTrackingStateReasonInsufficientFeatures) {
|
||||
tracking_state = ARVRInterface::ARVR_INSUFFICIENT_FEATURES;
|
||||
tracking_state = XRInterface::XR_INSUFFICIENT_FEATURES;
|
||||
} else {
|
||||
tracking_state = ARVRInterface::ARVR_UNKNOWN_TRACKING;
|
||||
tracking_state = XRInterface::XR_UNKNOWN_TRACKING;
|
||||
}
|
||||
|
||||
// copy our current frame transform
|
||||
|
@ -665,7 +665,7 @@ void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
|
|||
unsigned char uuid[16];
|
||||
[anchor.identifier getUUIDBytes:uuid];
|
||||
|
||||
ARVRPositionalTracker *tracker = get_anchor_for_uuid(uuid);
|
||||
XRPositionalTracker *tracker = get_anchor_for_uuid(uuid);
|
||||
if (tracker != NULL) {
|
||||
// lets update our mesh! (using Arjens code as is for now)
|
||||
// we should also probably limit how often we do this...
|
||||
|
@ -695,7 +695,7 @@ void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
|
|||
}
|
||||
|
||||
// Note, this also contains a scale factor which gives us an idea of the size of the anchor
|
||||
// We may extract that in our ARVRAnchor class
|
||||
// We may extract that in our XRAnchor class
|
||||
Basis b;
|
||||
matrix_float4x4 m44 = anchor.transform;
|
||||
b.elements[0].x = m44.columns[0][0];
|
||||
|
|
|
@ -37,7 +37,7 @@ void register_arkit_types() {
|
|||
|
||||
Ref<ARKitInterface> arkit_interface;
|
||||
arkit_interface.instance();
|
||||
ARVRServer::get_singleton()->add_interface(arkit_interface);
|
||||
XRServer::get_singleton()->add_interface(arkit_interface);
|
||||
}
|
||||
|
||||
void unregister_arkit_types() {
|
||||
|
|
|
@ -17,7 +17,7 @@ env_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"])
|
|||
Export("env_gdnative")
|
||||
|
||||
SConscript("net/SCsub")
|
||||
SConscript("arvr/SCsub")
|
||||
SConscript("xr/SCsub")
|
||||
SConscript("pluginscript/SCsub")
|
||||
SConscript("videodecoder/SCsub")
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ def configure(env):
|
|||
def get_doc_classes():
|
||||
return [
|
||||
"@NativeScript",
|
||||
"ARVRInterfaceGDNative",
|
||||
"XRInterfaceGDNative",
|
||||
"GDNative",
|
||||
"GDNativeLibrary",
|
||||
"MultiplayerPeerGDNative",
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" version="4.0">
|
||||
<brief_description>
|
||||
GDNative wrapper for an ARVR interface.
|
||||
</brief_description>
|
||||
<description>
|
||||
This is a wrapper class for GDNative implementations of the ARVR interface. To use a GDNative ARVR interface, simply instantiate this object and set your GDNative library containing the ARVR interface implementation.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
|
@ -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 [ARVRInterfaceGDNative]. 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>https://docs.godotengine.org/en/latest/tutorials/plugins/gdnative/gdnative-c-example.html</link>
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="XRInterfaceGDNative" inherits="XRInterface" version="4.0">
|
||||
<brief_description>
|
||||
GDNative wrapper for an XR interface.
|
||||
</brief_description>
|
||||
<description>
|
||||
This is a wrapper class for GDNative implementations of the XR interface. To use a GDNative XR interface, simply instantiate this object and set your GDNative library containing the XR interface implementation.
|
||||
</description>
|
||||
<tutorials>
|
||||
</tutorials>
|
||||
<methods>
|
||||
</methods>
|
||||
<constants>
|
||||
</constants>
|
||||
</class>
|
|
@ -5935,8 +5935,8 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "arvr",
|
||||
"type": "ARVR",
|
||||
"name": "xr",
|
||||
"type": "XR",
|
||||
"version": {
|
||||
"major": 1,
|
||||
"minor": 1
|
||||
|
@ -5944,24 +5944,24 @@
|
|||
"next": null,
|
||||
"api": [
|
||||
{
|
||||
"name": "godot_arvr_register_interface",
|
||||
"name": "godot_xr_register_interface",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["const godot_arvr_interface_gdnative *", "p_interface"]
|
||||
["const godot_xr_interface_gdnative *", "p_interface"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_get_worldscale",
|
||||
"name": "godot_xr_get_worldscale",
|
||||
"return_type": "godot_real",
|
||||
"arguments": []
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_get_reference_frame",
|
||||
"name": "godot_xr_get_reference_frame",
|
||||
"return_type": "godot_transform",
|
||||
"arguments": []
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_blit",
|
||||
"name": "godot_xr_blit",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_int", "p_eye"],
|
||||
|
@ -5970,14 +5970,14 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_get_texid",
|
||||
"name": "godot_xr_get_texid",
|
||||
"return_type": "godot_int",
|
||||
"arguments": [
|
||||
["godot_rid *", "p_render_target"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_add_controller",
|
||||
"name": "godot_xr_add_controller",
|
||||
"return_type": "godot_int",
|
||||
"arguments": [
|
||||
["char *", "p_device_name"],
|
||||
|
@ -5987,14 +5987,14 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_remove_controller",
|
||||
"name": "godot_xr_remove_controller",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_int", "p_controller_id"]
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_set_controller_transform",
|
||||
"name": "godot_xr_set_controller_transform",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_int", "p_controller_id"],
|
||||
|
@ -6004,7 +6004,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_set_controller_button",
|
||||
"name": "godot_xr_set_controller_button",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_int", "p_controller_id"],
|
||||
|
@ -6013,7 +6013,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_set_controller_axis",
|
||||
"name": "godot_xr_set_controller_axis",
|
||||
"return_type": "void",
|
||||
"arguments": [
|
||||
["godot_int", "p_controller_id"],
|
||||
|
@ -6023,7 +6023,7 @@
|
|||
]
|
||||
},
|
||||
{
|
||||
"name": "godot_arvr_get_controller_rumble",
|
||||
"name": "godot_xr_get_controller_rumble",
|
||||
"return_type": "godot_real",
|
||||
"arguments": [
|
||||
["godot_int", "p_controller_id"]
|
||||
|
|
|
@ -19,7 +19,7 @@ def _build_gdnative_api_struct_header(api):
|
|||
"",
|
||||
"#include <gdnative/gdnative.h>",
|
||||
"#include <android/godot_android.h>",
|
||||
"#include <arvr/godot_arvr.h>",
|
||||
"#include <xr/godot_xr.h>",
|
||||
"#include <nativescript/godot_nativescript.h>",
|
||||
"#include <net/godot_net.h>",
|
||||
"#include <pluginscript/godot_pluginscript.h>",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* godot_arvr.h */
|
||||
/* godot_xr.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,8 +28,8 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef GODOT_NATIVEARVR_H
|
||||
#define GODOT_NATIVEARVR_H
|
||||
#ifndef GODOT_NATIVEXR_H
|
||||
#define GODOT_NATIVEXR_H
|
||||
|
||||
#include <gdnative/gdnative.h>
|
||||
|
||||
|
@ -61,32 +61,31 @@ typedef struct {
|
|||
void (*fill_projection_for_eye)(void *, godot_real *, godot_int, godot_real, godot_real, godot_real);
|
||||
void (*commit_for_eye)(void *, godot_int, godot_rid *, godot_rect2 *);
|
||||
void (*process)(void *);
|
||||
// only in 1.1 onwards
|
||||
godot_int (*get_external_texture_for_eye)(void *, godot_int);
|
||||
void (*notification)(void *, godot_int);
|
||||
godot_int (*get_camera_feed_id)(void *);
|
||||
} godot_arvr_interface_gdnative;
|
||||
} godot_xr_interface_gdnative;
|
||||
|
||||
void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_interface);
|
||||
void GDAPI godot_xr_register_interface(const godot_xr_interface_gdnative *p_interface);
|
||||
|
||||
// helper functions to access ARVRServer data
|
||||
godot_real GDAPI godot_arvr_get_worldscale();
|
||||
godot_transform GDAPI godot_arvr_get_reference_frame();
|
||||
// helper functions to access XRServer data
|
||||
godot_real GDAPI godot_xr_get_worldscale();
|
||||
godot_transform GDAPI godot_xr_get_reference_frame();
|
||||
|
||||
// helper functions for rendering
|
||||
void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect);
|
||||
godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target);
|
||||
void GDAPI godot_xr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect);
|
||||
godot_int GDAPI godot_xr_get_texid(godot_rid *p_render_target);
|
||||
|
||||
// helper functions for updating ARVR controllers
|
||||
godot_int GDAPI godot_arvr_add_controller(char *p_device_name, godot_int p_hand, godot_bool p_tracks_orientation, godot_bool p_tracks_position);
|
||||
void GDAPI godot_arvr_remove_controller(godot_int p_controller_id);
|
||||
void GDAPI godot_arvr_set_controller_transform(godot_int p_controller_id, godot_transform *p_transform, godot_bool p_tracks_orientation, godot_bool p_tracks_position);
|
||||
void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed);
|
||||
void GDAPI godot_arvr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative);
|
||||
godot_real GDAPI godot_arvr_get_controller_rumble(godot_int p_controller_id);
|
||||
// helper functions for updating XR controllers
|
||||
godot_int GDAPI godot_xr_add_controller(char *p_device_name, godot_int p_hand, godot_bool p_tracks_orientation, godot_bool p_tracks_position);
|
||||
void GDAPI godot_xr_remove_controller(godot_int p_controller_id);
|
||||
void GDAPI godot_xr_set_controller_transform(godot_int p_controller_id, godot_transform *p_transform, godot_bool p_tracks_orientation, godot_bool p_tracks_position);
|
||||
void GDAPI godot_xr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed);
|
||||
void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative);
|
||||
godot_real GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !GODOT_NATIVEARVR_H */
|
||||
#endif /* !GODOT_NATIVEXR_H */
|
|
@ -34,11 +34,11 @@
|
|||
|
||||
#include "gdnative.h"
|
||||
|
||||
#include "arvr/register_types.h"
|
||||
#include "nativescript/register_types.h"
|
||||
#include "net/register_types.h"
|
||||
#include "pluginscript/register_types.h"
|
||||
#include "videodecoder/register_types.h"
|
||||
#include "xr/register_types.h"
|
||||
|
||||
#include "core/engine.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
|
@ -240,7 +240,7 @@ void register_gdnative_types() {
|
|||
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
|
||||
|
||||
register_net_types();
|
||||
register_arvr_types();
|
||||
register_xr_types();
|
||||
register_nativescript_types();
|
||||
register_pluginscript_types();
|
||||
register_videodecoder_types();
|
||||
|
@ -305,7 +305,7 @@ void unregister_gdnative_types() {
|
|||
unregister_videodecoder_types();
|
||||
unregister_pluginscript_types();
|
||||
unregister_nativescript_types();
|
||||
unregister_arvr_types();
|
||||
unregister_xr_types();
|
||||
unregister_net_types();
|
||||
|
||||
memdelete(GDNativeCallRegistry::singleton);
|
||||
|
|
|
@ -29,11 +29,12 @@
|
|||
/*************************************************************************/
|
||||
|
||||
#include "register_types.h"
|
||||
#include "arvr_interface_gdnative.h"
|
||||
#include "xr_interface_gdnative.h"
|
||||
|
||||
void register_arvr_types() {
|
||||
ClassDB::register_class<ARVRInterfaceGDNative>();
|
||||
void register_xr_types() {
|
||||
ClassDB::register_class<XRInterfaceGDNative>();
|
||||
ClassDB::add_compatibility_class("ARVRInterfaceGDNative", "XRInterfaceGDNative");
|
||||
}
|
||||
|
||||
void unregister_arvr_types() {
|
||||
void unregister_xr_types() {
|
||||
}
|
|
@ -28,10 +28,10 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef ARVR_REGISTER_TYPES_H
|
||||
#define ARVR_REGISTER_TYPES_H
|
||||
#ifndef XR_REGISTER_TYPES_H
|
||||
#define XR_REGISTER_TYPES_H
|
||||
|
||||
void register_arvr_types();
|
||||
void unregister_arvr_types();
|
||||
void register_xr_types();
|
||||
void unregister_xr_types();
|
||||
|
||||
#endif // ARVR_REGISTER_TYPES_H
|
||||
#endif // XR_REGISTER_TYPES_H
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_interface_gdnative.cpp */
|
||||
/* xr_interface_gdnative.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,17 +28,17 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "arvr_interface_gdnative.h"
|
||||
#include "xr_interface_gdnative.h"
|
||||
#include "core/input/input_filter.h"
|
||||
#include "servers/arvr/arvr_positional_tracker.h"
|
||||
#include "servers/rendering/rendering_server_globals.h"
|
||||
#include "servers/xr/xr_positional_tracker.h"
|
||||
|
||||
void ARVRInterfaceGDNative::_bind_methods() {
|
||||
void XRInterfaceGDNative::_bind_methods() {
|
||||
ADD_PROPERTY_DEFAULT("interface_is_initialized", false);
|
||||
ADD_PROPERTY_DEFAULT("ar_is_anchor_detection_enabled", false);
|
||||
}
|
||||
|
||||
ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
|
||||
XRInterfaceGDNative::XRInterfaceGDNative() {
|
||||
print_verbose("Construct gdnative interface\n");
|
||||
|
||||
// we won't have our data pointer until our library gets set
|
||||
|
@ -47,7 +47,7 @@ ARVRInterfaceGDNative::ARVRInterfaceGDNative() {
|
|||
interface = nullptr;
|
||||
}
|
||||
|
||||
ARVRInterfaceGDNative::~ARVRInterfaceGDNative() {
|
||||
XRInterfaceGDNative::~XRInterfaceGDNative() {
|
||||
print_verbose("Destruct gdnative interface\n");
|
||||
|
||||
if (interface != nullptr && is_initialized()) {
|
||||
|
@ -58,7 +58,7 @@ ARVRInterfaceGDNative::~ARVRInterfaceGDNative() {
|
|||
cleanup();
|
||||
}
|
||||
|
||||
void ARVRInterfaceGDNative::cleanup() {
|
||||
void XRInterfaceGDNative::cleanup() {
|
||||
if (interface != nullptr) {
|
||||
interface->destructor(data);
|
||||
data = nullptr;
|
||||
|
@ -66,7 +66,7 @@ void ARVRInterfaceGDNative::cleanup() {
|
|||
}
|
||||
}
|
||||
|
||||
void ARVRInterfaceGDNative::set_interface(const godot_arvr_interface_gdnative *p_interface) {
|
||||
void XRInterfaceGDNative::set_interface(const godot_xr_interface_gdnative *p_interface) {
|
||||
// this should only be called once, just being paranoid..
|
||||
if (interface) {
|
||||
cleanup();
|
||||
|
@ -79,7 +79,7 @@ void ARVRInterfaceGDNative::set_interface(const godot_arvr_interface_gdnative *p
|
|||
data = interface->constructor((godot_object *)this);
|
||||
}
|
||||
|
||||
StringName ARVRInterfaceGDNative::get_name() const {
|
||||
StringName XRInterfaceGDNative::get_name() const {
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, StringName());
|
||||
|
||||
|
@ -92,7 +92,7 @@ StringName ARVRInterfaceGDNative::get_name() const {
|
|||
return name;
|
||||
}
|
||||
|
||||
int ARVRInterfaceGDNative::get_capabilities() const {
|
||||
int XRInterfaceGDNative::get_capabilities() const {
|
||||
int capabilities;
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, 0); // 0 = None
|
||||
|
@ -102,32 +102,28 @@ int ARVRInterfaceGDNative::get_capabilities() const {
|
|||
return capabilities;
|
||||
}
|
||||
|
||||
bool ARVRInterfaceGDNative::get_anchor_detection_is_enabled() const {
|
||||
bool XRInterfaceGDNative::get_anchor_detection_is_enabled() const {
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, false);
|
||||
|
||||
return interface->get_anchor_detection_is_enabled(data);
|
||||
}
|
||||
|
||||
void ARVRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
|
||||
void XRInterfaceGDNative::set_anchor_detection_is_enabled(bool p_enable) {
|
||||
|
||||
ERR_FAIL_COND(interface == nullptr);
|
||||
|
||||
interface->set_anchor_detection_is_enabled(data, p_enable);
|
||||
}
|
||||
|
||||
int ARVRInterfaceGDNative::get_camera_feed_id() {
|
||||
int XRInterfaceGDNative::get_camera_feed_id() {
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, 0);
|
||||
|
||||
if ((interface->version.major > 1) || ((interface->version.major) == 1 && (interface->version.minor >= 1))) {
|
||||
return (unsigned int)interface->get_camera_feed_id(data);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool ARVRInterfaceGDNative::is_stereo() {
|
||||
bool XRInterfaceGDNative::is_stereo() {
|
||||
bool stereo;
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, false);
|
||||
|
@ -137,14 +133,14 @@ bool ARVRInterfaceGDNative::is_stereo() {
|
|||
return stereo;
|
||||
}
|
||||
|
||||
bool ARVRInterfaceGDNative::is_initialized() const {
|
||||
bool XRInterfaceGDNative::is_initialized() const {
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, false);
|
||||
|
||||
return interface->is_initialized(data);
|
||||
}
|
||||
|
||||
bool ARVRInterfaceGDNative::initialize() {
|
||||
bool XRInterfaceGDNative::initialize() {
|
||||
ERR_FAIL_COND_V(interface == nullptr, false);
|
||||
|
||||
bool initialized = interface->initialize(data);
|
||||
|
@ -152,28 +148,28 @@ bool ARVRInterfaceGDNative::initialize() {
|
|||
if (initialized) {
|
||||
// if we successfully initialize our interface and we don't have a primary interface yet, this becomes our primary interface
|
||||
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
if ((arvr_server != nullptr) && (arvr_server->get_primary_interface() == nullptr)) {
|
||||
arvr_server->set_primary_interface(this);
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
if ((xr_server != nullptr) && (xr_server->get_primary_interface() == nullptr)) {
|
||||
xr_server->set_primary_interface(this);
|
||||
};
|
||||
};
|
||||
|
||||
return initialized;
|
||||
}
|
||||
|
||||
void ARVRInterfaceGDNative::uninitialize() {
|
||||
void XRInterfaceGDNative::uninitialize() {
|
||||
ERR_FAIL_COND(interface == nullptr);
|
||||
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
if (arvr_server != nullptr) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
if (xr_server != nullptr) {
|
||||
// Whatever happens, make sure this is no longer our primary interface
|
||||
arvr_server->clear_primary_interface_if(this);
|
||||
xr_server->clear_primary_interface_if(this);
|
||||
}
|
||||
|
||||
interface->uninitialize(data);
|
||||
}
|
||||
|
||||
Size2 ARVRInterfaceGDNative::get_render_targetsize() {
|
||||
Size2 XRInterfaceGDNative::get_render_targetsize() {
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, Size2());
|
||||
|
||||
|
@ -183,7 +179,7 @@ Size2 ARVRInterfaceGDNative::get_render_targetsize() {
|
|||
return *vec;
|
||||
}
|
||||
|
||||
Transform ARVRInterfaceGDNative::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) {
|
||||
Transform XRInterfaceGDNative::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) {
|
||||
Transform *ret;
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, Transform());
|
||||
|
@ -195,7 +191,7 @@ Transform ARVRInterfaceGDNative::get_transform_for_eye(ARVRInterface::Eyes p_eye
|
|||
return *ret;
|
||||
}
|
||||
|
||||
CameraMatrix ARVRInterfaceGDNative::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
|
||||
CameraMatrix XRInterfaceGDNative::get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
|
||||
CameraMatrix cm;
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, CameraMatrix());
|
||||
|
@ -205,68 +201,61 @@ CameraMatrix ARVRInterfaceGDNative::get_projection_for_eye(ARVRInterface::Eyes p
|
|||
return cm;
|
||||
}
|
||||
|
||||
unsigned int ARVRInterfaceGDNative::get_external_texture_for_eye(ARVRInterface::Eyes p_eye) {
|
||||
unsigned int XRInterfaceGDNative::get_external_texture_for_eye(XRInterface::Eyes p_eye) {
|
||||
|
||||
ERR_FAIL_COND_V(interface == nullptr, 0);
|
||||
|
||||
if ((interface->version.major > 1) || ((interface->version.major) == 1 && (interface->version.minor >= 1))) {
|
||||
return (unsigned int)interface->get_external_texture_for_eye(data, (godot_int)p_eye);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ARVRInterfaceGDNative::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
|
||||
void XRInterfaceGDNative::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
|
||||
|
||||
ERR_FAIL_COND(interface == nullptr);
|
||||
|
||||
interface->commit_for_eye(data, (godot_int)p_eye, (godot_rid *)&p_render_target, (godot_rect2 *)&p_screen_rect);
|
||||
}
|
||||
|
||||
void ARVRInterfaceGDNative::process() {
|
||||
void XRInterfaceGDNative::process() {
|
||||
ERR_FAIL_COND(interface == nullptr);
|
||||
|
||||
interface->process(data);
|
||||
}
|
||||
|
||||
void ARVRInterfaceGDNative::notification(int p_what) {
|
||||
void XRInterfaceGDNative::notification(int p_what) {
|
||||
ERR_FAIL_COND(interface == nullptr);
|
||||
|
||||
// this is only available in interfaces that implement 1.1 or later
|
||||
if ((interface->version.major > 1) || ((interface->version.major == 1) && (interface->version.minor > 0))) {
|
||||
interface->notification(data, p_what);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
// some helper callbacks
|
||||
|
||||
extern "C" {
|
||||
|
||||
void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_interface) {
|
||||
// If our major version is 0 or bigger then 10, we're likely looking at our constructor pointer from an older plugin
|
||||
ERR_FAIL_COND_MSG((p_interface->version.major == 0) || (p_interface->version.major > 10), "GDNative ARVR interfaces build for Godot 3.0 are not supported.");
|
||||
void GDAPI godot_xr_register_interface(const godot_xr_interface_gdnative *p_interface) {
|
||||
// Must be on a version 4 plugin
|
||||
ERR_FAIL_COND_MSG(p_interface->version.major < 4, "GDNative XR interfaces build for Godot 3.x are not supported.");
|
||||
|
||||
Ref<ARVRInterfaceGDNative> new_interface;
|
||||
Ref<XRInterfaceGDNative> new_interface;
|
||||
new_interface.instance();
|
||||
new_interface->set_interface((const godot_arvr_interface_gdnative *)p_interface);
|
||||
ARVRServer::get_singleton()->add_interface(new_interface);
|
||||
new_interface->set_interface((const godot_xr_interface_gdnative *)p_interface);
|
||||
XRServer::get_singleton()->add_interface(new_interface);
|
||||
}
|
||||
|
||||
godot_real GDAPI godot_arvr_get_worldscale() {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, 1.0);
|
||||
godot_real GDAPI godot_xr_get_worldscale() {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, 1.0);
|
||||
|
||||
return arvr_server->get_world_scale();
|
||||
return xr_server->get_world_scale();
|
||||
}
|
||||
|
||||
godot_transform GDAPI godot_arvr_get_reference_frame() {
|
||||
godot_transform GDAPI godot_xr_get_reference_frame() {
|
||||
godot_transform reference_frame;
|
||||
Transform *reference_frame_ptr = (Transform *)&reference_frame;
|
||||
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
if (arvr_server != nullptr) {
|
||||
*reference_frame_ptr = arvr_server->get_reference_frame();
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
if (xr_server != nullptr) {
|
||||
*reference_frame_ptr = xr_server->get_reference_frame();
|
||||
} else {
|
||||
godot_transform_new_identity(&reference_frame);
|
||||
}
|
||||
|
@ -274,17 +263,17 @@ godot_transform GDAPI godot_arvr_get_reference_frame() {
|
|||
return reference_frame;
|
||||
}
|
||||
|
||||
void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect) {
|
||||
void GDAPI godot_xr_blit(godot_int p_eye, godot_rid *p_render_target, godot_rect2 *p_rect) {
|
||||
// blits out our texture as is, handy for preview display of one of the eyes that is already rendered with lens distortion on an external HMD
|
||||
ARVRInterface::Eyes eye = (ARVRInterface::Eyes)p_eye;
|
||||
XRInterface::Eyes eye = (XRInterface::Eyes)p_eye;
|
||||
#if 0
|
||||
RID *render_target = (RID *)p_render_target;
|
||||
#endif
|
||||
Rect2 screen_rect = *(Rect2 *)p_rect;
|
||||
|
||||
if (eye == ARVRInterface::EYE_LEFT) {
|
||||
if (eye == XRInterface::EYE_LEFT) {
|
||||
screen_rect.size.x /= 2.0;
|
||||
} else if (p_eye == ARVRInterface::EYE_RIGHT) {
|
||||
} else if (p_eye == XRInterface::EYE_RIGHT) {
|
||||
screen_rect.size.x /= 2.0;
|
||||
screen_rect.position.x += screen_rect.size.x;
|
||||
}
|
||||
|
@ -296,7 +285,7 @@ void GDAPI godot_arvr_blit(godot_int p_eye, godot_rid *p_render_target, godot_re
|
|||
#endif
|
||||
}
|
||||
|
||||
godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) {
|
||||
godot_int GDAPI godot_xr_get_texid(godot_rid *p_render_target) {
|
||||
// In order to send off our textures to display on our hardware we need the opengl texture ID instead of the render target RID
|
||||
// This is a handy function to expose that.
|
||||
#if 0
|
||||
|
@ -313,20 +302,20 @@ godot_int GDAPI godot_arvr_get_texid(godot_rid *p_render_target) {
|
|||
return texid;
|
||||
}
|
||||
|
||||
godot_int GDAPI godot_arvr_add_controller(char *p_device_name, godot_int p_hand, godot_bool p_tracks_orientation, godot_bool p_tracks_position) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, 0);
|
||||
godot_int GDAPI godot_xr_add_controller(char *p_device_name, godot_int p_hand, godot_bool p_tracks_orientation, godot_bool p_tracks_position) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, 0);
|
||||
|
||||
InputFilter *input = InputFilter::get_singleton();
|
||||
ERR_FAIL_NULL_V(input, 0);
|
||||
|
||||
ARVRPositionalTracker *new_tracker = memnew(ARVRPositionalTracker);
|
||||
XRPositionalTracker *new_tracker = memnew(XRPositionalTracker);
|
||||
new_tracker->set_name(p_device_name);
|
||||
new_tracker->set_type(ARVRServer::TRACKER_CONTROLLER);
|
||||
new_tracker->set_type(XRServer::TRACKER_CONTROLLER);
|
||||
if (p_hand == 1) {
|
||||
new_tracker->set_hand(ARVRPositionalTracker::TRACKER_LEFT_HAND);
|
||||
new_tracker->set_hand(XRPositionalTracker::TRACKER_LEFT_HAND);
|
||||
} else if (p_hand == 2) {
|
||||
new_tracker->set_hand(ARVRPositionalTracker::TRACKER_RIGHT_HAND);
|
||||
new_tracker->set_hand(XRPositionalTracker::TRACKER_RIGHT_HAND);
|
||||
}
|
||||
|
||||
// also register as joystick...
|
||||
|
@ -346,20 +335,20 @@ godot_int GDAPI godot_arvr_add_controller(char *p_device_name, godot_int p_hand,
|
|||
}
|
||||
|
||||
// add our tracker to our server and remember its pointer
|
||||
arvr_server->add_tracker(new_tracker);
|
||||
xr_server->add_tracker(new_tracker);
|
||||
|
||||
// note, this ID is only unique within controllers!
|
||||
return new_tracker->get_tracker_id();
|
||||
}
|
||||
|
||||
void GDAPI godot_arvr_remove_controller(godot_int p_controller_id) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
void GDAPI godot_xr_remove_controller(godot_int p_controller_id) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
InputFilter *input = InputFilter::get_singleton();
|
||||
ERR_FAIL_NULL(input);
|
||||
|
||||
ARVRPositionalTracker *remove_tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
XRPositionalTracker *remove_tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
if (remove_tracker != nullptr) {
|
||||
// unset our joystick if applicable
|
||||
int joyid = remove_tracker->get_joy_id();
|
||||
|
@ -369,16 +358,16 @@ void GDAPI godot_arvr_remove_controller(godot_int p_controller_id) {
|
|||
}
|
||||
|
||||
// remove our tracker from our server
|
||||
arvr_server->remove_tracker(remove_tracker);
|
||||
xr_server->remove_tracker(remove_tracker);
|
||||
memdelete(remove_tracker);
|
||||
}
|
||||
}
|
||||
|
||||
void GDAPI godot_arvr_set_controller_transform(godot_int p_controller_id, godot_transform *p_transform, godot_bool p_tracks_orientation, godot_bool p_tracks_position) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
void GDAPI godot_xr_set_controller_transform(godot_int p_controller_id, godot_transform *p_transform, godot_bool p_tracks_orientation, godot_bool p_tracks_position) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
if (tracker != nullptr) {
|
||||
Transform *transform = (Transform *)p_transform;
|
||||
if (p_tracks_orientation) {
|
||||
|
@ -390,14 +379,14 @@ void GDAPI godot_arvr_set_controller_transform(godot_int p_controller_id, godot_
|
|||
}
|
||||
}
|
||||
|
||||
void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
void GDAPI godot_xr_set_controller_button(godot_int p_controller_id, godot_int p_button, godot_bool p_is_pressed) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
InputFilter *input = InputFilter::get_singleton();
|
||||
ERR_FAIL_NULL(input);
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
if (tracker != nullptr) {
|
||||
int joyid = tracker->get_joy_id();
|
||||
if (joyid != -1) {
|
||||
|
@ -406,14 +395,14 @@ void GDAPI godot_arvr_set_controller_button(godot_int p_controller_id, godot_int
|
|||
}
|
||||
}
|
||||
|
||||
void GDAPI godot_arvr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
void GDAPI godot_xr_set_controller_axis(godot_int p_controller_id, godot_int p_axis, godot_real p_value, godot_bool p_can_be_negative) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
InputFilter *input = InputFilter::get_singleton();
|
||||
ERR_FAIL_NULL(input);
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
if (tracker != nullptr) {
|
||||
int joyid = tracker->get_joy_id();
|
||||
if (joyid != -1) {
|
||||
|
@ -425,11 +414,11 @@ void GDAPI godot_arvr_set_controller_axis(godot_int p_controller_id, godot_int p
|
|||
}
|
||||
}
|
||||
|
||||
godot_real GDAPI godot_arvr_get_controller_rumble(godot_int p_controller_id) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, 0.0);
|
||||
godot_real GDAPI godot_xr_get_controller_rumble(godot_int p_controller_id) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, 0.0);
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, p_controller_id);
|
||||
if (tracker != nullptr) {
|
||||
return tracker->get_rumble();
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_interface_gdnative.h */
|
||||
/* xr_interface_gdnative.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,11 +28,11 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef ARVR_INTERFACE_GDNATIVE_H
|
||||
#define ARVR_INTERFACE_GDNATIVE_H
|
||||
#ifndef XR_INTERFACE_GDNATIVE_H
|
||||
#define XR_INTERFACE_GDNATIVE_H
|
||||
|
||||
#include "modules/gdnative/gdnative.h"
|
||||
#include "servers/arvr/arvr_interface.h"
|
||||
#include "servers/xr/xr_interface.h"
|
||||
|
||||
/**
|
||||
@authors Hinsbart & Karroffel & Mux213
|
||||
|
@ -40,23 +40,23 @@
|
|||
This subclass of our AR/VR interface forms a bridge to GDNative.
|
||||
*/
|
||||
|
||||
class ARVRInterfaceGDNative : public ARVRInterface {
|
||||
GDCLASS(ARVRInterfaceGDNative, ARVRInterface);
|
||||
class XRInterfaceGDNative : public XRInterface {
|
||||
GDCLASS(XRInterfaceGDNative, XRInterface);
|
||||
|
||||
void cleanup();
|
||||
|
||||
protected:
|
||||
const godot_arvr_interface_gdnative *interface;
|
||||
const godot_xr_interface_gdnative *interface;
|
||||
void *data;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
/** general interface information **/
|
||||
ARVRInterfaceGDNative();
|
||||
~ARVRInterfaceGDNative();
|
||||
XRInterfaceGDNative();
|
||||
~XRInterfaceGDNative();
|
||||
|
||||
void set_interface(const godot_arvr_interface_gdnative *p_interface);
|
||||
void set_interface(const godot_xr_interface_gdnative *p_interface);
|
||||
|
||||
virtual StringName get_name() const;
|
||||
virtual int get_capabilities() const;
|
||||
|
@ -73,19 +73,19 @@ public:
|
|||
/** rendering and internal **/
|
||||
virtual Size2 get_render_targetsize();
|
||||
virtual bool is_stereo();
|
||||
virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
|
||||
virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform);
|
||||
|
||||
// we expose a Vector<float> version of this function to GDNative
|
||||
Vector<float> _get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
|
||||
Vector<float> _get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
|
||||
|
||||
// and a CameraMatrix version to ARVRServer
|
||||
virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
|
||||
// and a CameraMatrix version to XRServer
|
||||
virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
|
||||
|
||||
virtual unsigned int get_external_texture_for_eye(ARVRInterface::Eyes p_eye);
|
||||
virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
|
||||
virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye);
|
||||
virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
|
||||
|
||||
virtual void process();
|
||||
virtual void notification(int p_what);
|
||||
};
|
||||
|
||||
#endif // ARVR_INTERFACE_GDNATIVE_H
|
||||
#endif // XR_INTERFACE_GDNATIVE_H
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<class name="MobileVRInterface" inherits="ARVRInterface" version="4.0">
|
||||
<class name="MobileVRInterface" inherits="XRInterface" version="4.0">
|
||||
<brief_description>
|
||||
Generic mobile VR implementation.
|
||||
</brief_description>
|
||||
|
@ -8,9 +8,9 @@
|
|||
Note that even though there is no positional tracking, the camera will assume the headset is at a height of 1.85 meters. You can change this by setting [member eye_height].
|
||||
You can initialise this interface as follows:
|
||||
[codeblock]
|
||||
var interface = ARVRServer.find_interface("Native mobile")
|
||||
var interface = XRServer.find_interface("Native mobile")
|
||||
if interface and interface.initialize():
|
||||
get_viewport().arvr = true
|
||||
get_viewport().xr = true
|
||||
[/codeblock]
|
||||
</description>
|
||||
<tutorials>
|
||||
|
@ -25,7 +25,7 @@
|
|||
The width of the display in centimeters.
|
||||
</member>
|
||||
<member name="eye_height" type="float" setter="set_eye_height" getter="get_eye_height" default="1.85">
|
||||
The height at which the camera is placed in relation to the ground (i.e. [ARVROrigin] node).
|
||||
The height at which the camera is placed in relation to the ground (i.e. [XROrigin3D] node).
|
||||
</member>
|
||||
<member name="iod" type="float" setter="set_iod" getter="get_iod" default="6.0">
|
||||
The interocular distance, also known as the interpupillary distance. The distance between the pupils of the left and right eye.
|
||||
|
|
|
@ -39,7 +39,7 @@ StringName MobileVRInterface::get_name() const {
|
|||
};
|
||||
|
||||
int MobileVRInterface::get_capabilities() const {
|
||||
return ARVRInterface::ARVR_STEREO;
|
||||
return XRInterface::XR_STEREO;
|
||||
};
|
||||
|
||||
Vector3 MobileVRInterface::scale_magneto(const Vector3 &p_magnetometer) {
|
||||
|
@ -165,7 +165,7 @@ void MobileVRInterface::set_position_from_sensors() {
|
|||
rotate.rotate(orientation.get_axis(2), gyro.z * delta_time);
|
||||
orientation = rotate * orientation;
|
||||
|
||||
tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING;
|
||||
tracking_state = XRInterface::XR_NORMAL_TRACKING;
|
||||
};
|
||||
|
||||
///@TODO improve this, the magnetometer is very fidgity sometimes flipping the axis for no apparent reason (probably a bug on my part)
|
||||
|
@ -177,7 +177,7 @@ void MobileVRInterface::set_position_from_sensors() {
|
|||
transform_quat = transform_quat.slerp(acc_mag_quat, 0.1);
|
||||
orientation = Basis(transform_quat);
|
||||
|
||||
tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING;
|
||||
tracking_state = XRInterface::XR_NORMAL_TRACKING;
|
||||
} else if (has_grav) {
|
||||
// use gravity vector to make sure down is down...
|
||||
// transform gravity into our world space
|
||||
|
@ -297,8 +297,8 @@ bool MobileVRInterface::is_initialized() const {
|
|||
};
|
||||
|
||||
bool MobileVRInterface::initialize() {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, false);
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, false);
|
||||
|
||||
if (!initialized) {
|
||||
// reset our sensor data and orientation
|
||||
|
@ -314,7 +314,7 @@ bool MobileVRInterface::initialize() {
|
|||
orientation = Basis();
|
||||
|
||||
// make this our primary interface
|
||||
arvr_server->set_primary_interface(this);
|
||||
xr_server->set_primary_interface(this);
|
||||
|
||||
last_ticks = OS::get_singleton()->get_ticks_usec();
|
||||
|
||||
|
@ -326,10 +326,10 @@ bool MobileVRInterface::initialize() {
|
|||
|
||||
void MobileVRInterface::uninitialize() {
|
||||
if (initialized) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
if (arvr_server != nullptr) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
if (xr_server != nullptr) {
|
||||
// no longer our primary interface
|
||||
arvr_server->clear_primary_interface_if(this);
|
||||
xr_server->clear_primary_interface_if(this);
|
||||
}
|
||||
|
||||
initialized = false;
|
||||
|
@ -348,22 +348,22 @@ Size2 MobileVRInterface::get_render_targetsize() {
|
|||
return target_size;
|
||||
};
|
||||
|
||||
Transform MobileVRInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) {
|
||||
Transform MobileVRInterface::get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
Transform transform_for_eye;
|
||||
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, transform_for_eye);
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, transform_for_eye);
|
||||
|
||||
if (initialized) {
|
||||
float world_scale = arvr_server->get_world_scale();
|
||||
float world_scale = xr_server->get_world_scale();
|
||||
|
||||
// we don't need to check for the existence of our HMD, doesn't effect our values...
|
||||
// note * 0.01 to convert cm to m and * 0.5 as we're moving half in each direction...
|
||||
if (p_eye == ARVRInterface::EYE_LEFT) {
|
||||
if (p_eye == XRInterface::EYE_LEFT) {
|
||||
transform_for_eye.origin.x = -(intraocular_dist * 0.01 * 0.5 * world_scale);
|
||||
} else if (p_eye == ARVRInterface::EYE_RIGHT) {
|
||||
} else if (p_eye == XRInterface::EYE_RIGHT) {
|
||||
transform_for_eye.origin.x = intraocular_dist * 0.01 * 0.5 * world_scale;
|
||||
} else {
|
||||
// for mono we don't reposition, we want our center position.
|
||||
|
@ -374,7 +374,7 @@ Transform MobileVRInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, co
|
|||
hmd_transform.basis = orientation;
|
||||
hmd_transform.origin = Vector3(0.0, eye_height * world_scale, 0.0);
|
||||
|
||||
transform_for_eye = p_cam_transform * (arvr_server->get_reference_frame()) * hmd_transform * transform_for_eye;
|
||||
transform_for_eye = p_cam_transform * (xr_server->get_reference_frame()) * hmd_transform * transform_for_eye;
|
||||
} else {
|
||||
// huh? well just return what we got....
|
||||
transform_for_eye = p_cam_transform;
|
||||
|
@ -383,12 +383,12 @@ Transform MobileVRInterface::get_transform_for_eye(ARVRInterface::Eyes p_eye, co
|
|||
return transform_for_eye;
|
||||
};
|
||||
|
||||
CameraMatrix MobileVRInterface::get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
|
||||
CameraMatrix MobileVRInterface::get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
CameraMatrix eye;
|
||||
|
||||
if (p_eye == ARVRInterface::EYE_MONO) {
|
||||
if (p_eye == XRInterface::EYE_MONO) {
|
||||
///@TODO for now hardcode some of this, what is really needed here is that this needs to be in sync with the real cameras properties
|
||||
// which probably means implementing a specific class for iOS and Android. For now this is purely here as an example.
|
||||
// Note also that if you use a normal viewport with AR/VR turned off you can still use the tracker output of this interface
|
||||
|
@ -396,13 +396,13 @@ CameraMatrix MobileVRInterface::get_projection_for_eye(ARVRInterface::Eyes p_eye
|
|||
// This will make more sense when we implement ARkit on iOS (probably a separate interface).
|
||||
eye.set_perspective(60.0, p_aspect, p_z_near, p_z_far, false);
|
||||
} else {
|
||||
eye.set_for_hmd(p_eye == ARVRInterface::EYE_LEFT ? 1 : 2, p_aspect, intraocular_dist, display_width, display_to_lens, oversample, p_z_near, p_z_far);
|
||||
eye.set_for_hmd(p_eye == XRInterface::EYE_LEFT ? 1 : 2, p_aspect, intraocular_dist, display_width, display_to_lens, oversample, p_z_near, p_z_far);
|
||||
};
|
||||
|
||||
return eye;
|
||||
};
|
||||
|
||||
void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
|
||||
void MobileVRInterface::commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
// We must have a valid render target
|
||||
|
@ -417,9 +417,9 @@ void MobileVRInterface::commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_t
|
|||
// we output half a screen
|
||||
dest.size.x *= 0.5;
|
||||
|
||||
if (p_eye == ARVRInterface::EYE_LEFT) {
|
||||
if (p_eye == XRInterface::EYE_LEFT) {
|
||||
eye_center.x = ((-intraocular_dist / 2.0) + (display_width / 4.0)) / (display_width / 2.0);
|
||||
} else if (p_eye == ARVRInterface::EYE_RIGHT) {
|
||||
} else if (p_eye == XRInterface::EYE_RIGHT) {
|
||||
dest.position.x = dest.size.x;
|
||||
eye_center.x = ((intraocular_dist / 2.0) - (display_width / 4.0)) / (display_width / 2.0);
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
#ifndef MOBILE_VR_INTERFACE_H
|
||||
#define MOBILE_VR_INTERFACE_H
|
||||
|
||||
#include "servers/arvr/arvr_interface.h"
|
||||
#include "servers/arvr/arvr_positional_tracker.h"
|
||||
#include "servers/xr/xr_interface.h"
|
||||
#include "servers/xr/xr_positional_tracker.h"
|
||||
|
||||
/**
|
||||
@author Bastiaan Olij <mux213@gmail.com>
|
||||
|
@ -47,8 +47,8 @@
|
|||
more advanced interfaces.
|
||||
*/
|
||||
|
||||
class MobileVRInterface : public ARVRInterface {
|
||||
GDCLASS(MobileVRInterface, ARVRInterface);
|
||||
class MobileVRInterface : public XRInterface {
|
||||
GDCLASS(MobileVRInterface, XRInterface);
|
||||
|
||||
private:
|
||||
bool initialized;
|
||||
|
@ -137,9 +137,9 @@ public:
|
|||
|
||||
virtual Size2 get_render_targetsize();
|
||||
virtual bool is_stereo();
|
||||
virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform);
|
||||
virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
|
||||
virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
|
||||
virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform);
|
||||
virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far);
|
||||
virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect);
|
||||
|
||||
virtual void process();
|
||||
virtual void notification(int p_what);
|
||||
|
|
|
@ -37,7 +37,7 @@ void register_mobile_vr_types() {
|
|||
|
||||
Ref<MobileVRInterface> mobile_vr;
|
||||
mobile_vr.instance();
|
||||
ARVRServer::get_singleton()->add_interface(mobile_vr);
|
||||
XRServer::get_singleton()->add_interface(mobile_vr);
|
||||
}
|
||||
|
||||
void unregister_mobile_vr_types() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_nodes.cpp */
|
||||
/* xr_nodes.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,25 +28,25 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "arvr_nodes.h"
|
||||
#include "xr_nodes.h"
|
||||
#include "core/input/input_filter.h"
|
||||
#include "servers/arvr/arvr_interface.h"
|
||||
#include "servers/arvr_server.h"
|
||||
#include "servers/xr/xr_interface.h"
|
||||
#include "servers/xr_server.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ARVRCamera::_notification(int p_what) {
|
||||
void XRCamera3D::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
// need to find our ARVROrigin parent and let it know we're its camera!
|
||||
ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
|
||||
// need to find our XROrigin3D parent and let it know we're its camera!
|
||||
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
|
||||
if (origin != nullptr) {
|
||||
origin->set_tracked_camera(this);
|
||||
}
|
||||
}; break;
|
||||
case NOTIFICATION_EXIT_TREE: {
|
||||
// need to find our ARVROrigin parent and let it know we're no longer its camera!
|
||||
ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
|
||||
// need to find our XROrigin3D parent and let it know we're no longer its camera!
|
||||
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
|
||||
if (origin != nullptr) {
|
||||
origin->clear_tracked_camera_if(this);
|
||||
}
|
||||
|
@ -54,26 +54,26 @@ void ARVRCamera::_notification(int p_what) {
|
|||
};
|
||||
};
|
||||
|
||||
String ARVRCamera::get_configuration_warning() const {
|
||||
String XRCamera3D::get_configuration_warning() const {
|
||||
if (!is_visible() || !is_inside_tree())
|
||||
return String();
|
||||
|
||||
// must be child node of ARVROrigin!
|
||||
ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
|
||||
// must be child node of XROrigin3D!
|
||||
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
|
||||
if (origin == nullptr) {
|
||||
return TTR("ARVRCamera must have an ARVROrigin node as its parent.");
|
||||
return TTR("XRCamera3D must have an XROrigin3D node as its parent.");
|
||||
};
|
||||
|
||||
return String();
|
||||
};
|
||||
|
||||
Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, Vector3());
|
||||
Vector3 XRCamera3D::project_local_ray_normal(const Point2 &p_pos) const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, Vector3());
|
||||
|
||||
Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
|
||||
if (arvr_interface.is_null()) {
|
||||
Ref<XRInterface> xr_interface = xr_server->get_primary_interface();
|
||||
if (xr_interface.is_null()) {
|
||||
// we might be in the editor or have VR turned off, just call superclass
|
||||
return Camera3D::project_local_ray_normal(p_pos);
|
||||
}
|
||||
|
@ -84,20 +84,20 @@ Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const {
|
|||
Vector2 cpos = get_viewport()->get_camera_coords(p_pos);
|
||||
Vector3 ray;
|
||||
|
||||
CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
Vector2 screen_he = cm.get_viewport_half_extents();
|
||||
ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_he.x, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_he.y, -get_znear()).normalized();
|
||||
|
||||
return ray;
|
||||
};
|
||||
|
||||
Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, Vector2());
|
||||
Point2 XRCamera3D::unproject_position(const Vector3 &p_pos) const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, Vector2());
|
||||
|
||||
Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
|
||||
if (arvr_interface.is_null()) {
|
||||
Ref<XRInterface> xr_interface = xr_server->get_primary_interface();
|
||||
if (xr_interface.is_null()) {
|
||||
// we might be in the editor or have VR turned off, just call superclass
|
||||
return Camera3D::unproject_position(p_pos);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const {
|
|||
|
||||
Size2 viewport_size = get_viewport()->get_visible_rect().size;
|
||||
|
||||
CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
|
||||
Plane p(get_camera_transform().xform_inv(p_pos), 1.0);
|
||||
|
||||
|
@ -120,13 +120,13 @@ Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const {
|
|||
return res;
|
||||
};
|
||||
|
||||
Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, Vector3());
|
||||
Vector3 XRCamera3D::project_position(const Point2 &p_point, float p_z_depth) const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, Vector3());
|
||||
|
||||
Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
|
||||
if (arvr_interface.is_null()) {
|
||||
Ref<XRInterface> xr_interface = xr_server->get_primary_interface();
|
||||
if (xr_interface.is_null()) {
|
||||
// we might be in the editor or have VR turned off, just call superclass
|
||||
return Camera3D::project_position(p_point, p_z_depth);
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) con
|
|||
|
||||
Size2 viewport_size = get_viewport()->get_visible_rect().size;
|
||||
|
||||
CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
|
||||
Vector2 vp_he = cm.get_viewport_half_extents();
|
||||
|
||||
|
@ -149,13 +149,13 @@ Vector3 ARVRCamera::project_position(const Point2 &p_point, float p_z_depth) con
|
|||
return get_camera_transform().xform(p);
|
||||
};
|
||||
|
||||
Vector<Plane> ARVRCamera::get_frustum() const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, Vector<Plane>());
|
||||
Vector<Plane> XRCamera3D::get_frustum() const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, Vector<Plane>());
|
||||
|
||||
Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
|
||||
if (arvr_interface.is_null()) {
|
||||
Ref<XRInterface> xr_interface = xr_server->get_primary_interface();
|
||||
if (xr_interface.is_null()) {
|
||||
// we might be in the editor or have VR turned off, just call superclass
|
||||
return Camera3D::get_frustum();
|
||||
}
|
||||
|
@ -163,21 +163,21 @@ Vector<Plane> ARVRCamera::get_frustum() const {
|
|||
ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>());
|
||||
|
||||
Size2 viewport_size = get_viewport()->get_visible_rect().size;
|
||||
CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
CameraMatrix cm = xr_interface->get_projection_for_eye(XRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar());
|
||||
return cm.get_projection_planes(get_camera_transform());
|
||||
};
|
||||
|
||||
ARVRCamera::ARVRCamera(){
|
||||
XRCamera3D::XRCamera3D(){
|
||||
// nothing to do here yet for now..
|
||||
};
|
||||
|
||||
ARVRCamera::~ARVRCamera(){
|
||||
XRCamera3D::~XRCamera3D(){
|
||||
// nothing to do here yet for now..
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ARVRController::_notification(int p_what) {
|
||||
void XRController3D::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
set_process_internal(true);
|
||||
|
@ -186,12 +186,12 @@ void ARVRController::_notification(int p_what) {
|
|||
set_process_internal(false);
|
||||
}; break;
|
||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
// find the tracker for our controller
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id);
|
||||
if (tracker == nullptr) {
|
||||
// this controller is currently turned off
|
||||
is_active = false;
|
||||
|
@ -236,49 +236,49 @@ void ARVRController::_notification(int p_what) {
|
|||
};
|
||||
};
|
||||
|
||||
void ARVRController::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &ARVRController::set_controller_id);
|
||||
ClassDB::bind_method(D_METHOD("get_controller_id"), &ARVRController::get_controller_id);
|
||||
void XRController3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_controller_id", "controller_id"), &XRController3D::set_controller_id);
|
||||
ClassDB::bind_method(D_METHOD("get_controller_id"), &XRController3D::get_controller_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "controller_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_controller_id", "get_controller_id");
|
||||
ClassDB::bind_method(D_METHOD("get_controller_name"), &ARVRController::get_controller_name);
|
||||
ClassDB::bind_method(D_METHOD("get_controller_name"), &XRController3D::get_controller_name);
|
||||
|
||||
// passthroughs to information about our related joystick
|
||||
ClassDB::bind_method(D_METHOD("get_joystick_id"), &ARVRController::get_joystick_id);
|
||||
ClassDB::bind_method(D_METHOD("is_button_pressed", "button"), &ARVRController::is_button_pressed);
|
||||
ClassDB::bind_method(D_METHOD("get_joystick_axis", "axis"), &ARVRController::get_joystick_axis);
|
||||
ClassDB::bind_method(D_METHOD("get_joystick_id"), &XRController3D::get_joystick_id);
|
||||
ClassDB::bind_method(D_METHOD("is_button_pressed", "button"), &XRController3D::is_button_pressed);
|
||||
ClassDB::bind_method(D_METHOD("get_joystick_axis", "axis"), &XRController3D::get_joystick_axis);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRController::get_is_active);
|
||||
ClassDB::bind_method(D_METHOD("get_hand"), &ARVRController::get_hand);
|
||||
ClassDB::bind_method(D_METHOD("get_is_active"), &XRController3D::get_is_active);
|
||||
ClassDB::bind_method(D_METHOD("get_hand"), &XRController3D::get_hand);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_rumble"), &ARVRController::get_rumble);
|
||||
ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRController::set_rumble);
|
||||
ClassDB::bind_method(D_METHOD("get_rumble"), &XRController3D::get_rumble);
|
||||
ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &XRController3D::set_rumble);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rumble", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_rumble", "get_rumble");
|
||||
ADD_PROPERTY_DEFAULT("rumble", 0.0);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRController::get_mesh);
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &XRController3D::get_mesh);
|
||||
|
||||
ADD_SIGNAL(MethodInfo("button_pressed", PropertyInfo(Variant::INT, "button")));
|
||||
ADD_SIGNAL(MethodInfo("button_release", PropertyInfo(Variant::INT, "button")));
|
||||
ADD_SIGNAL(MethodInfo("mesh_updated", PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh")));
|
||||
};
|
||||
|
||||
void ARVRController::set_controller_id(int p_controller_id) {
|
||||
void XRController3D::set_controller_id(int p_controller_id) {
|
||||
// We don't check any bounds here, this controller may not yet be active and just be a place holder until it is.
|
||||
// Note that setting this to 0 means this node is not bound to a controller yet.
|
||||
controller_id = p_controller_id;
|
||||
update_configuration_warning();
|
||||
};
|
||||
|
||||
int ARVRController::get_controller_id(void) const {
|
||||
int XRController3D::get_controller_id(void) const {
|
||||
return controller_id;
|
||||
};
|
||||
|
||||
String ARVRController::get_controller_name(void) const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, String());
|
||||
String XRController3D::get_controller_name(void) const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, String());
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id);
|
||||
if (tracker == nullptr) {
|
||||
return String("Not connected");
|
||||
};
|
||||
|
@ -286,12 +286,12 @@ String ARVRController::get_controller_name(void) const {
|
|||
return tracker->get_name();
|
||||
};
|
||||
|
||||
int ARVRController::get_joystick_id() const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, 0);
|
||||
int XRController3D::get_joystick_id() const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, 0);
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id);
|
||||
if (tracker == nullptr) {
|
||||
// No tracker? no joystick id... (0 is our first joystick)
|
||||
return -1;
|
||||
|
@ -300,7 +300,7 @@ int ARVRController::get_joystick_id() const {
|
|||
return tracker->get_joy_id();
|
||||
};
|
||||
|
||||
bool ARVRController::is_button_pressed(int p_button) const {
|
||||
bool XRController3D::is_button_pressed(int p_button) const {
|
||||
int joy_id = get_joystick_id();
|
||||
if (joy_id == -1) {
|
||||
return false;
|
||||
|
@ -309,7 +309,7 @@ bool ARVRController::is_button_pressed(int p_button) const {
|
|||
return InputFilter::get_singleton()->is_joy_button_pressed(joy_id, p_button);
|
||||
};
|
||||
|
||||
float ARVRController::get_joystick_axis(int p_axis) const {
|
||||
float XRController3D::get_joystick_axis(int p_axis) const {
|
||||
int joy_id = get_joystick_id();
|
||||
if (joy_id == -1) {
|
||||
return 0.0;
|
||||
|
@ -318,12 +318,12 @@ float ARVRController::get_joystick_axis(int p_axis) const {
|
|||
return InputFilter::get_singleton()->get_joy_axis(joy_id, p_axis);
|
||||
};
|
||||
|
||||
real_t ARVRController::get_rumble() const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, 0.0);
|
||||
real_t XRController3D::get_rumble() const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, 0.0);
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id);
|
||||
if (tracker == nullptr) {
|
||||
return 0.0;
|
||||
};
|
||||
|
@ -331,46 +331,46 @@ real_t ARVRController::get_rumble() const {
|
|||
return tracker->get_rumble();
|
||||
};
|
||||
|
||||
void ARVRController::set_rumble(real_t p_rumble) {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
void XRController3D::set_rumble(real_t p_rumble) {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id);
|
||||
if (tracker != nullptr) {
|
||||
tracker->set_rumble(p_rumble);
|
||||
};
|
||||
};
|
||||
|
||||
Ref<Mesh> ARVRController::get_mesh() const {
|
||||
Ref<Mesh> XRController3D::get_mesh() const {
|
||||
return mesh;
|
||||
}
|
||||
|
||||
bool ARVRController::get_is_active() const {
|
||||
bool XRController3D::get_is_active() const {
|
||||
return is_active;
|
||||
};
|
||||
|
||||
ARVRPositionalTracker::TrackerHand ARVRController::get_hand() const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, ARVRPositionalTracker::TRACKER_HAND_UNKNOWN);
|
||||
XRPositionalTracker::TrackerHand XRController3D::get_hand() const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, XRPositionalTracker::TRACKER_HAND_UNKNOWN);
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_CONTROLLER, controller_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_CONTROLLER, controller_id);
|
||||
if (tracker == nullptr) {
|
||||
return ARVRPositionalTracker::TRACKER_HAND_UNKNOWN;
|
||||
return XRPositionalTracker::TRACKER_HAND_UNKNOWN;
|
||||
};
|
||||
|
||||
return tracker->get_hand();
|
||||
};
|
||||
|
||||
String ARVRController::get_configuration_warning() const {
|
||||
String XRController3D::get_configuration_warning() const {
|
||||
if (!is_visible() || !is_inside_tree())
|
||||
return String();
|
||||
|
||||
// must be child node of ARVROrigin!
|
||||
ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
|
||||
// must be child node of XROrigin!
|
||||
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
|
||||
if (origin == nullptr) {
|
||||
return TTR("ARVRController must have an ARVROrigin node as its parent.");
|
||||
return TTR("XRController3D must have an XROrigin3D node as its parent.");
|
||||
};
|
||||
|
||||
if (controller_id == 0) {
|
||||
|
@ -380,19 +380,19 @@ String ARVRController::get_configuration_warning() const {
|
|||
return String();
|
||||
};
|
||||
|
||||
ARVRController::ARVRController() {
|
||||
XRController3D::XRController3D() {
|
||||
controller_id = 1;
|
||||
is_active = true;
|
||||
button_states = 0;
|
||||
};
|
||||
|
||||
ARVRController::~ARVRController(){
|
||||
XRController3D::~XRController3D(){
|
||||
// nothing to do here yet for now..
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ARVRAnchor::_notification(int p_what) {
|
||||
void XRAnchor3D::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
set_process_internal(true);
|
||||
|
@ -401,12 +401,12 @@ void ARVRAnchor::_notification(int p_what) {
|
|||
set_process_internal(false);
|
||||
}; break;
|
||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
// find the tracker for our anchor
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_ANCHOR, anchor_id);
|
||||
if (tracker == nullptr) {
|
||||
// this anchor is currently not available
|
||||
is_active = false;
|
||||
|
@ -415,7 +415,7 @@ void ARVRAnchor::_notification(int p_what) {
|
|||
Transform transform;
|
||||
|
||||
// we'll need our world_scale
|
||||
real_t world_scale = arvr_server->get_world_scale();
|
||||
real_t world_scale = xr_server->get_world_scale();
|
||||
|
||||
// get our info from our tracker
|
||||
transform.basis = tracker->get_orientation();
|
||||
|
@ -427,7 +427,7 @@ void ARVRAnchor::_notification(int p_what) {
|
|||
transform.basis.orthonormalize();
|
||||
|
||||
// apply our reference frame and set our transform
|
||||
set_transform(arvr_server->get_reference_frame() * transform);
|
||||
set_transform(xr_server->get_reference_frame() * transform);
|
||||
|
||||
// check for an updated mesh
|
||||
Ref<Mesh> trackerMesh = tracker->get_mesh();
|
||||
|
@ -442,43 +442,43 @@ void ARVRAnchor::_notification(int p_what) {
|
|||
};
|
||||
};
|
||||
|
||||
void ARVRAnchor::_bind_methods() {
|
||||
void XRAnchor3D::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &ARVRAnchor::set_anchor_id);
|
||||
ClassDB::bind_method(D_METHOD("get_anchor_id"), &ARVRAnchor::get_anchor_id);
|
||||
ClassDB::bind_method(D_METHOD("set_anchor_id", "anchor_id"), &XRAnchor3D::set_anchor_id);
|
||||
ClassDB::bind_method(D_METHOD("get_anchor_id"), &XRAnchor3D::get_anchor_id);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "anchor_id", PROPERTY_HINT_RANGE, "0,32,1"), "set_anchor_id", "get_anchor_id");
|
||||
ClassDB::bind_method(D_METHOD("get_anchor_name"), &ARVRAnchor::get_anchor_name);
|
||||
ClassDB::bind_method(D_METHOD("get_anchor_name"), &XRAnchor3D::get_anchor_name);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRAnchor::get_is_active);
|
||||
ClassDB::bind_method(D_METHOD("get_size"), &ARVRAnchor::get_size);
|
||||
ClassDB::bind_method(D_METHOD("get_is_active"), &XRAnchor3D::get_is_active);
|
||||
ClassDB::bind_method(D_METHOD("get_size"), &XRAnchor3D::get_size);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_plane"), &ARVRAnchor::get_plane);
|
||||
ClassDB::bind_method(D_METHOD("get_plane"), &XRAnchor3D::get_plane);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRAnchor::get_mesh);
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &XRAnchor3D::get_mesh);
|
||||
ADD_SIGNAL(MethodInfo("mesh_updated", PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh")));
|
||||
};
|
||||
|
||||
void ARVRAnchor::set_anchor_id(int p_anchor_id) {
|
||||
void XRAnchor3D::set_anchor_id(int p_anchor_id) {
|
||||
// We don't check any bounds here, this anchor may not yet be active and just be a place holder until it is.
|
||||
// Note that setting this to 0 means this node is not bound to an anchor yet.
|
||||
anchor_id = p_anchor_id;
|
||||
update_configuration_warning();
|
||||
};
|
||||
|
||||
int ARVRAnchor::get_anchor_id(void) const {
|
||||
int XRAnchor3D::get_anchor_id(void) const {
|
||||
return anchor_id;
|
||||
};
|
||||
|
||||
Vector3 ARVRAnchor::get_size() const {
|
||||
Vector3 XRAnchor3D::get_size() const {
|
||||
return size;
|
||||
};
|
||||
|
||||
String ARVRAnchor::get_anchor_name(void) const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, String());
|
||||
String XRAnchor3D::get_anchor_name(void) const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, String());
|
||||
|
||||
ARVRPositionalTracker *tracker = arvr_server->find_by_type_and_id(ARVRServer::TRACKER_ANCHOR, anchor_id);
|
||||
XRPositionalTracker *tracker = xr_server->find_by_type_and_id(XRServer::TRACKER_ANCHOR, anchor_id);
|
||||
if (tracker == nullptr) {
|
||||
return String("Not connected");
|
||||
};
|
||||
|
@ -486,18 +486,18 @@ String ARVRAnchor::get_anchor_name(void) const {
|
|||
return tracker->get_name();
|
||||
};
|
||||
|
||||
bool ARVRAnchor::get_is_active() const {
|
||||
bool XRAnchor3D::get_is_active() const {
|
||||
return is_active;
|
||||
};
|
||||
|
||||
String ARVRAnchor::get_configuration_warning() const {
|
||||
String XRAnchor3D::get_configuration_warning() const {
|
||||
if (!is_visible() || !is_inside_tree())
|
||||
return String();
|
||||
|
||||
// must be child node of ARVROrigin!
|
||||
ARVROrigin *origin = Object::cast_to<ARVROrigin>(get_parent());
|
||||
// must be child node of XROrigin3D!
|
||||
XROrigin3D *origin = Object::cast_to<XROrigin3D>(get_parent());
|
||||
if (origin == nullptr) {
|
||||
return TTR("ARVRAnchor must have an ARVROrigin node as its parent.");
|
||||
return TTR("XRAnchor3D must have an XROrigin3D node as its parent.");
|
||||
};
|
||||
|
||||
if (anchor_id == 0) {
|
||||
|
@ -507,7 +507,7 @@ String ARVRAnchor::get_configuration_warning() const {
|
|||
return String();
|
||||
};
|
||||
|
||||
Plane ARVRAnchor::get_plane() const {
|
||||
Plane XRAnchor3D::get_plane() const {
|
||||
Vector3 location = get_translation();
|
||||
Basis orientation = get_transform().basis;
|
||||
|
||||
|
@ -516,67 +516,67 @@ Plane ARVRAnchor::get_plane() const {
|
|||
return plane;
|
||||
};
|
||||
|
||||
Ref<Mesh> ARVRAnchor::get_mesh() const {
|
||||
Ref<Mesh> XRAnchor3D::get_mesh() const {
|
||||
return mesh;
|
||||
}
|
||||
|
||||
ARVRAnchor::ARVRAnchor() {
|
||||
XRAnchor3D::XRAnchor3D() {
|
||||
anchor_id = 1;
|
||||
is_active = true;
|
||||
};
|
||||
|
||||
ARVRAnchor::~ARVRAnchor(){
|
||||
XRAnchor3D::~XRAnchor3D(){
|
||||
// nothing to do here yet for now..
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
String ARVROrigin::get_configuration_warning() const {
|
||||
String XROrigin3D::get_configuration_warning() const {
|
||||
if (!is_visible() || !is_inside_tree())
|
||||
return String();
|
||||
|
||||
if (tracked_camera == nullptr)
|
||||
return TTR("ARVROrigin requires an ARVRCamera child node.");
|
||||
return TTR("XROrigin3D requires an XRCamera3D child node.");
|
||||
|
||||
return String();
|
||||
};
|
||||
|
||||
void ARVROrigin::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_world_scale", "world_scale"), &ARVROrigin::set_world_scale);
|
||||
ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVROrigin::get_world_scale);
|
||||
void XROrigin3D::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_world_scale", "world_scale"), &XROrigin3D::set_world_scale);
|
||||
ClassDB::bind_method(D_METHOD("get_world_scale"), &XROrigin3D::get_world_scale);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "world_scale"), "set_world_scale", "get_world_scale");
|
||||
};
|
||||
|
||||
void ARVROrigin::set_tracked_camera(ARVRCamera *p_tracked_camera) {
|
||||
void XROrigin3D::set_tracked_camera(XRCamera3D *p_tracked_camera) {
|
||||
tracked_camera = p_tracked_camera;
|
||||
};
|
||||
|
||||
void ARVROrigin::clear_tracked_camera_if(ARVRCamera *p_tracked_camera) {
|
||||
void XROrigin3D::clear_tracked_camera_if(XRCamera3D *p_tracked_camera) {
|
||||
if (tracked_camera == p_tracked_camera) {
|
||||
tracked_camera = nullptr;
|
||||
};
|
||||
};
|
||||
|
||||
float ARVROrigin::get_world_scale() const {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, 1.0);
|
||||
float XROrigin3D::get_world_scale() const {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, 1.0);
|
||||
|
||||
return arvr_server->get_world_scale();
|
||||
return xr_server->get_world_scale();
|
||||
};
|
||||
|
||||
void ARVROrigin::set_world_scale(float p_world_scale) {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
void XROrigin3D::set_world_scale(float p_world_scale) {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
arvr_server->set_world_scale(p_world_scale);
|
||||
xr_server->set_world_scale(p_world_scale);
|
||||
};
|
||||
|
||||
void ARVROrigin::_notification(int p_what) {
|
||||
// get our ARVRServer
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
void XROrigin3D::_notification(int p_what) {
|
||||
// get our XRServer
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
|
@ -587,13 +587,13 @@ void ARVROrigin::_notification(int p_what) {
|
|||
}; break;
|
||||
case NOTIFICATION_INTERNAL_PROCESS: {
|
||||
// set our world origin to our node transform
|
||||
arvr_server->set_world_origin(get_global_transform());
|
||||
xr_server->set_world_origin(get_global_transform());
|
||||
|
||||
// check if we have a primary interface
|
||||
Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface();
|
||||
if (arvr_interface.is_valid() && tracked_camera != nullptr) {
|
||||
Ref<XRInterface> xr_interface = xr_server->get_primary_interface();
|
||||
if (xr_interface.is_valid() && tracked_camera != nullptr) {
|
||||
// get our positioning transform for our headset
|
||||
Transform t = arvr_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform());
|
||||
Transform t = xr_interface->get_transform_for_eye(XRInterface::EYE_MONO, Transform());
|
||||
|
||||
// now apply this to our camera
|
||||
tracked_camera->set_transform(t);
|
||||
|
@ -603,19 +603,19 @@ void ARVROrigin::_notification(int p_what) {
|
|||
break;
|
||||
};
|
||||
|
||||
// send our notification to all active ARVR interfaces, they may need to react to it also
|
||||
for (int i = 0; i < arvr_server->get_interface_count(); i++) {
|
||||
Ref<ARVRInterface> interface = arvr_server->get_interface(i);
|
||||
// send our notification to all active XE interfaces, they may need to react to it also
|
||||
for (int i = 0; i < xr_server->get_interface_count(); i++) {
|
||||
Ref<XRInterface> interface = xr_server->get_interface(i);
|
||||
if (interface.is_valid() && interface->is_initialized()) {
|
||||
interface->notification(p_what);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ARVROrigin::ARVROrigin() {
|
||||
XROrigin3D::XROrigin3D() {
|
||||
tracked_camera = nullptr;
|
||||
};
|
||||
|
||||
ARVROrigin::~ARVROrigin(){
|
||||
XROrigin3D::~XROrigin3D(){
|
||||
// nothing to do here yet for now..
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_nodes.h */
|
||||
/* xr_nodes.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,24 +28,24 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef ARVR_NODES_H
|
||||
#define ARVR_NODES_H
|
||||
#ifndef XR_NODES_H
|
||||
#define XR_NODES_H
|
||||
|
||||
#include "scene/3d/camera_3d.h"
|
||||
#include "scene/3d/node_3d.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
#include "servers/arvr/arvr_positional_tracker.h"
|
||||
#include "servers/xr/xr_positional_tracker.h"
|
||||
|
||||
/**
|
||||
@author Bastiaan Olij <mux213@gmail.com>
|
||||
**/
|
||||
|
||||
/*
|
||||
ARVRCamera is a subclass of camera which will register itself with its parent ARVROrigin and as a result is automatically positioned
|
||||
XRCamera is a subclass of camera which will register itself with its parent XROrigin and as a result is automatically positioned
|
||||
*/
|
||||
class ARVRCamera : public Camera3D {
|
||||
class XRCamera3D : public Camera3D {
|
||||
|
||||
GDCLASS(ARVRCamera, Camera3D);
|
||||
GDCLASS(XRCamera3D, Camera3D);
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
@ -58,19 +58,19 @@ public:
|
|||
virtual Vector3 project_position(const Point2 &p_point, float p_z_depth) const;
|
||||
virtual Vector<Plane> get_frustum() const;
|
||||
|
||||
ARVRCamera();
|
||||
~ARVRCamera();
|
||||
XRCamera3D();
|
||||
~XRCamera3D();
|
||||
};
|
||||
|
||||
/*
|
||||
ARVRController is a helper node that automatically updates its position based on tracker data.
|
||||
XRController3D is a helper node that automatically updates its position based on tracker data.
|
||||
|
||||
It must be a child node of our ARVROrigin node
|
||||
It must be a child node of our XROrigin node
|
||||
*/
|
||||
|
||||
class ARVRController : public Node3D {
|
||||
class XRController3D : public Node3D {
|
||||
|
||||
GDCLASS(ARVRController, Node3D);
|
||||
GDCLASS(XRController3D, Node3D);
|
||||
|
||||
private:
|
||||
int controller_id;
|
||||
|
@ -95,23 +95,23 @@ public:
|
|||
void set_rumble(real_t p_rumble);
|
||||
|
||||
bool get_is_active() const;
|
||||
ARVRPositionalTracker::TrackerHand get_hand() const;
|
||||
XRPositionalTracker::TrackerHand get_hand() const;
|
||||
|
||||
Ref<Mesh> get_mesh(void) const;
|
||||
|
||||
String get_configuration_warning() const;
|
||||
|
||||
ARVRController();
|
||||
~ARVRController();
|
||||
XRController3D();
|
||||
~XRController3D();
|
||||
};
|
||||
|
||||
/*
|
||||
ARVRAnchor is a helper node that automatically updates its position based on anchor data, it represents a real world location.
|
||||
It must be a child node of our ARVROrigin node
|
||||
XRAnchor3D is a helper node that automatically updates its position based on anchor data, it represents a real world location.
|
||||
It must be a child node of our XROrigin3D node
|
||||
*/
|
||||
|
||||
class ARVRAnchor : public Node3D {
|
||||
GDCLASS(ARVRAnchor, Node3D);
|
||||
class XRAnchor3D : public Node3D {
|
||||
GDCLASS(XRAnchor3D, Node3D);
|
||||
|
||||
private:
|
||||
int anchor_id;
|
||||
|
@ -137,24 +137,24 @@ public:
|
|||
|
||||
String get_configuration_warning() const;
|
||||
|
||||
ARVRAnchor();
|
||||
~ARVRAnchor();
|
||||
XRAnchor3D();
|
||||
~XRAnchor3D();
|
||||
};
|
||||
|
||||
/*
|
||||
ARVROrigin is special spatial node that acts as our origin point mapping our real world center of our tracking volume into our virtual world.
|
||||
XROrigin3D is special spatial node that acts as our origin point mapping our real world center of our tracking volume into our virtual world.
|
||||
|
||||
It is this point that you will move around the world as the player 'moves while standing still', i.e. the player moves through teleporting or controller inputs as opposed to physically moving.
|
||||
|
||||
Our camera and controllers will always be child nodes and thus place relative to this origin point.
|
||||
This node will automatically locate any camera child nodes and update its position while our ARVRController node will handle tracked controllers.
|
||||
This node will automatically locate any camera child nodes and update its position while our XRController3D node will handle tracked controllers.
|
||||
*/
|
||||
class ARVROrigin : public Node3D {
|
||||
class XROrigin3D : public Node3D {
|
||||
|
||||
GDCLASS(ARVROrigin, Node3D);
|
||||
GDCLASS(XROrigin3D, Node3D);
|
||||
|
||||
private:
|
||||
ARVRCamera *tracked_camera;
|
||||
XRCamera3D *tracked_camera;
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
@ -163,14 +163,14 @@ protected:
|
|||
public:
|
||||
String get_configuration_warning() const;
|
||||
|
||||
void set_tracked_camera(ARVRCamera *p_tracked_camera);
|
||||
void clear_tracked_camera_if(ARVRCamera *p_tracked_camera);
|
||||
void set_tracked_camera(XRCamera3D *p_tracked_camera);
|
||||
void clear_tracked_camera_if(XRCamera3D *p_tracked_camera);
|
||||
|
||||
float get_world_scale() const;
|
||||
void set_world_scale(float p_world_scale);
|
||||
|
||||
ARVROrigin();
|
||||
~ARVROrigin();
|
||||
XROrigin3D();
|
||||
~XROrigin3D();
|
||||
};
|
||||
|
||||
#endif /* ARVR_NODES_H */
|
||||
#endif /* XR_NODES_H */
|
|
@ -3615,13 +3615,14 @@ Viewport::~Viewport() {
|
|||
|
||||
/////////////////////////////////
|
||||
|
||||
void SubViewport::set_use_arvr(bool p_use_arvr) {
|
||||
arvr = p_use_arvr;
|
||||
void SubViewport::set_use_xr(bool p_use_xr) {
|
||||
xr = p_use_xr;
|
||||
|
||||
RS::get_singleton()->viewport_set_use_arvr(get_viewport_rid(), arvr);
|
||||
RS::get_singleton()->viewport_set_use_xr(get_viewport_rid(), xr);
|
||||
}
|
||||
bool SubViewport::is_using_arvr() {
|
||||
return arvr;
|
||||
|
||||
bool SubViewport::is_using_xr() {
|
||||
return xr;
|
||||
}
|
||||
|
||||
void SubViewport::set_size(const Size2i &p_size) {
|
||||
|
@ -3701,8 +3702,8 @@ void SubViewport::_notification(int p_what) {
|
|||
}
|
||||
|
||||
void SubViewport::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_use_arvr", "use"), &SubViewport::set_use_arvr);
|
||||
ClassDB::bind_method(D_METHOD("is_using_arvr"), &SubViewport::is_using_arvr);
|
||||
ClassDB::bind_method(D_METHOD("set_use_xr", "use"), &SubViewport::set_use_xr);
|
||||
ClassDB::bind_method(D_METHOD("is_using_xr"), &SubViewport::is_using_xr);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_size", "size"), &SubViewport::set_size);
|
||||
ClassDB::bind_method(D_METHOD("get_size"), &SubViewport::get_size);
|
||||
|
@ -3719,7 +3720,7 @@ void SubViewport::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_clear_mode", "mode"), &SubViewport::set_clear_mode);
|
||||
ClassDB::bind_method(D_METHOD("get_clear_mode"), &SubViewport::get_clear_mode);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "arvr"), "set_use_arvr", "is_using_arvr");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "xr"), "set_use_xr", "is_using_xr");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size_2d_override"), "set_size_2d_override", "get_size_2d_override");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "size_2d_override_stretch"), "set_size_2d_override_stretch", "is_size_2d_override_stretch_enabled");
|
||||
|
@ -3739,7 +3740,7 @@ void SubViewport::_bind_methods() {
|
|||
}
|
||||
|
||||
SubViewport::SubViewport() {
|
||||
arvr = false;
|
||||
xr = false;
|
||||
size_2d_override_stretch = false;
|
||||
update_mode = UPDATE_WHEN_VISIBLE;
|
||||
clear_mode = CLEAR_MODE_ALWAYS;
|
||||
|
|
|
@ -590,7 +590,7 @@ public:
|
|||
private:
|
||||
UpdateMode update_mode;
|
||||
ClearMode clear_mode;
|
||||
bool arvr;
|
||||
bool xr;
|
||||
bool size_2d_override_stretch;
|
||||
|
||||
protected:
|
||||
|
@ -606,8 +606,8 @@ public:
|
|||
void set_size_2d_override(const Size2i &p_size);
|
||||
Size2i get_size_2d_override() const;
|
||||
|
||||
void set_use_arvr(bool p_use_arvr);
|
||||
bool is_using_arvr();
|
||||
void set_use_xr(bool p_use_xr);
|
||||
bool is_using_xr();
|
||||
|
||||
void set_size_2d_override_stretch(bool p_enable);
|
||||
bool is_size_2d_override_stretch_enabled() const;
|
||||
|
|
|
@ -179,7 +179,6 @@
|
|||
|
||||
#ifndef _3D_DISABLED
|
||||
#include "scene/3d/area_3d.h"
|
||||
#include "scene/3d/arvr_nodes.h"
|
||||
#include "scene/3d/audio_stream_player_3d.h"
|
||||
#include "scene/3d/baked_lightmap.h"
|
||||
#include "scene/3d/bone_attachment_3d.h"
|
||||
|
@ -213,6 +212,7 @@
|
|||
#include "scene/3d/vehicle_body_3d.h"
|
||||
#include "scene/3d/visibility_notifier_3d.h"
|
||||
#include "scene/3d/world_environment.h"
|
||||
#include "scene/3d/xr_nodes.h"
|
||||
#include "scene/resources/environment.h"
|
||||
#include "scene/resources/mesh_library.h"
|
||||
#endif
|
||||
|
@ -410,10 +410,10 @@ void register_scene_types() {
|
|||
ClassDB::register_class<Camera3D>();
|
||||
ClassDB::register_class<ClippedCamera3D>();
|
||||
ClassDB::register_class<Listener3D>();
|
||||
ClassDB::register_class<ARVRCamera>();
|
||||
ClassDB::register_class<ARVRController>();
|
||||
ClassDB::register_class<ARVRAnchor>();
|
||||
ClassDB::register_class<ARVROrigin>();
|
||||
ClassDB::register_class<XRCamera3D>();
|
||||
ClassDB::register_class<XRController3D>();
|
||||
ClassDB::register_class<XRAnchor3D>();
|
||||
ClassDB::register_class<XROrigin3D>();
|
||||
ClassDB::register_class<MeshInstance3D>();
|
||||
ClassDB::register_class<ImmediateGeometry3D>();
|
||||
ClassDB::register_virtual_class<SpriteBase3D>();
|
||||
|
@ -853,6 +853,10 @@ void register_scene_types() {
|
|||
ClassDB::add_compatibility_class("World", "World3D");
|
||||
ClassDB::add_compatibility_class("ProceduralSky", "Sky");
|
||||
ClassDB::add_compatibility_class("PanoramaSky", "Sky");
|
||||
ClassDB::add_compatibility_class("ARVRCamera", "XRCamera3D");
|
||||
ClassDB::add_compatibility_class("ARVROrigin", "XROrigin3D");
|
||||
ClassDB::add_compatibility_class("ARVRController", "XRController3D");
|
||||
ClassDB::add_compatibility_class("ARVRAnchor", "XRAnchor3D");
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ Import("env")
|
|||
env.servers_sources = []
|
||||
env.add_source_files(env.servers_sources, "*.cpp")
|
||||
|
||||
SConscript("arvr/SCsub")
|
||||
SConscript("xr/SCsub")
|
||||
SConscript("camera/SCsub")
|
||||
SConscript("physics_3d/SCsub")
|
||||
SConscript("physics_2d/SCsub")
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
#include "core/engine.h"
|
||||
#include "core/project_settings.h"
|
||||
|
||||
#include "arvr/arvr_interface.h"
|
||||
#include "arvr/arvr_positional_tracker.h"
|
||||
#include "arvr_server.h"
|
||||
#include "audio/audio_effect.h"
|
||||
#include "audio/audio_stream.h"
|
||||
#include "audio/effects/audio_effect_amplify.h"
|
||||
|
@ -67,6 +64,9 @@
|
|||
#include "physics_server_3d.h"
|
||||
#include "rendering_server.h"
|
||||
#include "servers/rendering/shader_types.h"
|
||||
#include "xr/xr_interface.h"
|
||||
#include "xr/xr_positional_tracker.h"
|
||||
#include "xr_server.h"
|
||||
|
||||
ShaderTypes *shader_types = nullptr;
|
||||
|
||||
|
@ -102,11 +102,15 @@ void register_server_types() {
|
|||
ClassDB::register_class<AudioServer>();
|
||||
ClassDB::register_virtual_class<PhysicsServer3D>();
|
||||
ClassDB::register_virtual_class<PhysicsServer2D>();
|
||||
ClassDB::register_class<ARVRServer>();
|
||||
ClassDB::register_class<XRServer>();
|
||||
ClassDB::register_class<CameraServer>();
|
||||
|
||||
ClassDB::register_virtual_class<ARVRInterface>();
|
||||
ClassDB::register_class<ARVRPositionalTracker>();
|
||||
ClassDB::register_virtual_class<XRInterface>();
|
||||
ClassDB::register_class<XRPositionalTracker>();
|
||||
|
||||
ClassDB::add_compatibility_class("ARVRServer", "XRServer");
|
||||
ClassDB::add_compatibility_class("ARVRInterface", "XRInterface");
|
||||
ClassDB::add_compatibility_class("ARVRPositionalTracker", "XRPositionalTracker");
|
||||
|
||||
ClassDB::register_virtual_class<AudioStream>();
|
||||
ClassDB::register_virtual_class<AudioStreamPlayback>();
|
||||
|
@ -198,6 +202,6 @@ void register_server_singletons() {
|
|||
Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer3D", PhysicsServer3D::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer2D", NavigationServer2D::get_singleton_mut()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer3D", NavigationServer3D::get_singleton_mut()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("ARVRServer", ARVRServer::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("XRServer", XRServer::get_singleton()));
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton()));
|
||||
}
|
||||
|
|
|
@ -456,7 +456,7 @@ public:
|
|||
|
||||
BIND0R(RID, viewport_create)
|
||||
|
||||
BIND2(viewport_set_use_arvr, RID, bool)
|
||||
BIND2(viewport_set_use_xr, RID, bool)
|
||||
BIND3(viewport_set_size, RID, int, int)
|
||||
|
||||
BIND2(viewport_set_active, RID, bool)
|
||||
|
|
|
@ -1883,7 +1883,7 @@ void RenderingServerScene::render_camera(RID p_render_buffers, RID p_camera, RID
|
|||
#endif
|
||||
}
|
||||
|
||||
void RenderingServerScene::render_camera(RID p_render_buffers, Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
|
||||
void RenderingServerScene::render_camera(RID p_render_buffers, Ref<XRInterface> &p_interface, XRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas) {
|
||||
// render for AR/VR interface
|
||||
|
||||
Camera *camera = camera_owner.getornull(p_camera);
|
||||
|
@ -1895,16 +1895,14 @@ void RenderingServerScene::render_camera(RID p_render_buffers, Ref<ARVRInterface
|
|||
|
||||
// We also ignore our camera position, it will have been positioned with a slightly old tracking position.
|
||||
// Instead we take our origin point and have our ar/vr interface add fresh tracking data! Whoohoo!
|
||||
Transform world_origin = ARVRServer::get_singleton()->get_world_origin();
|
||||
Transform world_origin = XRServer::get_singleton()->get_world_origin();
|
||||
Transform cam_transform = p_interface->get_transform_for_eye(p_eye, world_origin);
|
||||
|
||||
// For stereo render we only prepare for our left eye and then reuse the outcome for our right eye
|
||||
if (p_eye == ARVRInterface::EYE_LEFT) {
|
||||
///@TODO possibly move responsibility for this into our ARVRServer or ARVRInterface?
|
||||
|
||||
if (p_eye == XRInterface::EYE_LEFT) {
|
||||
// Center our transform, we assume basis is equal.
|
||||
Transform mono_transform = cam_transform;
|
||||
Transform right_transform = p_interface->get_transform_for_eye(ARVRInterface::EYE_RIGHT, world_origin);
|
||||
Transform right_transform = p_interface->get_transform_for_eye(XRInterface::EYE_RIGHT, world_origin);
|
||||
mono_transform.origin += right_transform.origin;
|
||||
mono_transform.origin *= 0.5;
|
||||
|
||||
|
@ -1958,7 +1956,7 @@ void RenderingServerScene::render_camera(RID p_render_buffers, Ref<ARVRInterface
|
|||
|
||||
// now prepare our scene with our adjusted transform projection matrix
|
||||
_prepare_scene(mono_transform, combined_matrix, false, false, camera->env, camera->effects, camera->visible_layers, p_scenario, p_shadow_atlas, RID());
|
||||
} else if (p_eye == ARVRInterface::EYE_MONO) {
|
||||
} else if (p_eye == XRInterface::EYE_MONO) {
|
||||
// For mono render, prepare as per usual
|
||||
_prepare_scene(cam_transform, camera_matrix, false, false, camera->env, camera->effects, camera->visible_layers, p_scenario, p_shadow_atlas, RID());
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
#include "core/os/thread.h"
|
||||
#include "core/rid_owner.h"
|
||||
#include "core/self_list.h"
|
||||
#include "servers/arvr/arvr_interface.h"
|
||||
#include "servers/xr/xr_interface.h"
|
||||
|
||||
class RenderingServerScene {
|
||||
public:
|
||||
|
@ -426,7 +426,7 @@ public:
|
|||
void render_empty_scene(RID p_render_buffers, RID p_scenario, RID p_shadow_atlas);
|
||||
|
||||
void render_camera(RID p_render_buffers, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
|
||||
void render_camera(RID p_render_buffers, Ref<ARVRInterface> &p_interface, ARVRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
|
||||
void render_camera(RID p_render_buffers, Ref<XRInterface> &p_interface, XRInterface::Eyes p_eye, RID p_camera, RID p_scenario, Size2 p_viewport_size, RID p_shadow_atlas);
|
||||
void update_dirty_instances();
|
||||
|
||||
void render_probes();
|
||||
|
|
|
@ -62,24 +62,24 @@ static Transform2D _canvas_get_transform(RenderingServerViewport::Viewport *p_vi
|
|||
return xf;
|
||||
}
|
||||
|
||||
void RenderingServerViewport::_draw_3d(Viewport *p_viewport, ARVRInterface::Eyes p_eye) {
|
||||
void RenderingServerViewport::_draw_3d(Viewport *p_viewport, XRInterface::Eyes p_eye) {
|
||||
|
||||
RENDER_TIMESTAMP(">Begin Rendering 3D Scene");
|
||||
|
||||
Ref<ARVRInterface> arvr_interface;
|
||||
if (ARVRServer::get_singleton() != nullptr) {
|
||||
arvr_interface = ARVRServer::get_singleton()->get_primary_interface();
|
||||
Ref<XRInterface> xr_interface;
|
||||
if (XRServer::get_singleton() != nullptr) {
|
||||
xr_interface = XRServer::get_singleton()->get_primary_interface();
|
||||
}
|
||||
|
||||
if (p_viewport->use_arvr && arvr_interface.is_valid()) {
|
||||
RSG::scene->render_camera(p_viewport->render_buffers, arvr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
|
||||
if (p_viewport->use_xr && xr_interface.is_valid()) {
|
||||
RSG::scene->render_camera(p_viewport->render_buffers, xr_interface, p_eye, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
|
||||
} else {
|
||||
RSG::scene->render_camera(p_viewport->render_buffers, p_viewport->camera, p_viewport->scenario, p_viewport->size, p_viewport->shadow_atlas);
|
||||
}
|
||||
RENDER_TIMESTAMP("<End Rendering 3D Scene");
|
||||
}
|
||||
|
||||
void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::Eyes p_eye) {
|
||||
void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, XRInterface::Eyes p_eye) {
|
||||
|
||||
/* Camera should always be BEFORE any other 3D */
|
||||
|
||||
|
@ -293,17 +293,15 @@ void RenderingServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface
|
|||
|
||||
void RenderingServerViewport::draw_viewports() {
|
||||
|
||||
#if 0
|
||||
// get our arvr interface in case we need it
|
||||
Ref<ARVRInterface> arvr_interface;
|
||||
// get our xr interface in case we need it
|
||||
Ref<XRInterface> xr_interface;
|
||||
|
||||
if (ARVRServer::get_singleton() != nullptr) {
|
||||
arvr_interface = ARVRServer::get_singleton()->get_primary_interface();
|
||||
if (XRServer::get_singleton() != nullptr) {
|
||||
xr_interface = XRServer::get_singleton()->get_primary_interface();
|
||||
|
||||
// process all our active interfaces
|
||||
ARVRServer::get_singleton()->_process();
|
||||
XRServer::get_singleton()->_process();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (Engine::get_singleton()->is_editor_hint()) {
|
||||
set_default_clear_color(GLOBAL_GET("rendering/environment/default_clear_color"));
|
||||
|
@ -367,38 +365,41 @@ void RenderingServerViewport::draw_viewports() {
|
|||
|
||||
RSG::storage->render_target_set_as_unused(vp->render_target);
|
||||
#if 0
|
||||
if (vp->use_arvr && arvr_interface.is_valid()) {
|
||||
// TODO fix up this code after we change our commit_for_eye to accept our new render targets
|
||||
|
||||
if (vp->use_xr && xr_interface.is_valid()) {
|
||||
// override our size, make sure it matches our required size
|
||||
vp->size = arvr_interface->get_render_targetsize();
|
||||
vp->size = xr_interface->get_render_targetsize();
|
||||
RSG::storage->render_target_set_size(vp->render_target, vp->size.x, vp->size.y);
|
||||
|
||||
// render mono or left eye first
|
||||
ARVRInterface::Eyes leftOrMono = arvr_interface->is_stereo() ? ARVRInterface::EYE_LEFT : ARVRInterface::EYE_MONO;
|
||||
XRInterface::Eyes leftOrMono = xr_interface->is_stereo() ? XRInterface::EYE_LEFT : XRInterface::EYE_MONO;
|
||||
|
||||
// check for an external texture destination for our left eye/mono
|
||||
RSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(leftOrMono));
|
||||
// TODO investigate how we're going to make external textures work
|
||||
RSG::storage->render_target_set_external_texture(vp->render_target, xr_interface->get_external_texture_for_eye(leftOrMono));
|
||||
|
||||
// set our render target as current
|
||||
RSG::rasterizer->set_current_render_target(vp->render_target);
|
||||
|
||||
// and draw left eye/mono
|
||||
_draw_viewport(vp, leftOrMono);
|
||||
arvr_interface->commit_for_eye(leftOrMono, vp->render_target, vp->viewport_to_screen_rect);
|
||||
xr_interface->commit_for_eye(leftOrMono, vp->render_target, vp->viewport_to_screen_rect);
|
||||
|
||||
// render right eye
|
||||
if (leftOrMono == ARVRInterface::EYE_LEFT) {
|
||||
if (leftOrMono == XRInterface::EYE_LEFT) {
|
||||
// check for an external texture destination for our right eye
|
||||
RSG::storage->render_target_set_external_texture(vp->render_target, arvr_interface->get_external_texture_for_eye(ARVRInterface::EYE_RIGHT));
|
||||
RSG::storage->render_target_set_external_texture(vp->render_target, xr_interface->get_external_texture_for_eye(XRInterface::EYE_RIGHT));
|
||||
|
||||
// commit for eye may have changed the render target
|
||||
RSG::rasterizer->set_current_render_target(vp->render_target);
|
||||
|
||||
_draw_viewport(vp, ARVRInterface::EYE_RIGHT);
|
||||
arvr_interface->commit_for_eye(ARVRInterface::EYE_RIGHT, vp->render_target, vp->viewport_to_screen_rect);
|
||||
_draw_viewport(vp, XRInterface::EYE_RIGHT);
|
||||
xr_interface->commit_for_eye(XRInterface::EYE_RIGHT, vp->render_target, vp->viewport_to_screen_rect);
|
||||
}
|
||||
|
||||
// and for our frame timing, mark when we've finished committing our eyes
|
||||
ARVRServer::get_singleton()->_mark_commit();
|
||||
XRServer::get_singleton()->_mark_commit();
|
||||
} else {
|
||||
#endif
|
||||
{
|
||||
|
@ -470,11 +471,11 @@ RID RenderingServerViewport::viewport_create() {
|
|||
return rid;
|
||||
}
|
||||
|
||||
void RenderingServerViewport::viewport_set_use_arvr(RID p_viewport, bool p_use_arvr) {
|
||||
void RenderingServerViewport::viewport_set_use_xr(RID p_viewport, bool p_use_xr) {
|
||||
Viewport *viewport = viewport_owner.getornull(p_viewport);
|
||||
ERR_FAIL_COND(!viewport);
|
||||
|
||||
viewport->use_arvr = p_use_arvr;
|
||||
viewport->use_xr = p_use_xr;
|
||||
}
|
||||
|
||||
void RenderingServerViewport::viewport_set_size(RID p_viewport, int p_width, int p_height) {
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
#include "core/rid_owner.h"
|
||||
#include "core/self_list.h"
|
||||
#include "rasterizer.h"
|
||||
#include "servers/arvr/arvr_interface.h"
|
||||
#include "servers/rendering_server.h"
|
||||
#include "servers/xr/xr_interface.h"
|
||||
|
||||
class RenderingServerViewport {
|
||||
public:
|
||||
|
@ -47,7 +47,7 @@ public:
|
|||
RID self;
|
||||
RID parent;
|
||||
|
||||
bool use_arvr; /* use arvr interface to override camera positioning and projection matrices and control output */
|
||||
bool use_xr; /* use xr interface to override camera positioning and projection matrices and control output */
|
||||
|
||||
Size2i size;
|
||||
RID camera;
|
||||
|
@ -127,7 +127,7 @@ public:
|
|||
for (int i = 0; i < RS::VIEWPORT_RENDER_INFO_MAX; i++) {
|
||||
render_info[i] = 0;
|
||||
}
|
||||
use_arvr = false;
|
||||
use_xr = false;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -152,13 +152,13 @@ public:
|
|||
Vector<Viewport *> active_viewports;
|
||||
|
||||
private:
|
||||
void _draw_3d(Viewport *p_viewport, ARVRInterface::Eyes p_eye);
|
||||
void _draw_viewport(Viewport *p_viewport, ARVRInterface::Eyes p_eye = ARVRInterface::EYE_MONO);
|
||||
void _draw_3d(Viewport *p_viewport, XRInterface::Eyes p_eye);
|
||||
void _draw_viewport(Viewport *p_viewport, XRInterface::Eyes p_eye = XRInterface::EYE_MONO);
|
||||
|
||||
public:
|
||||
RID viewport_create();
|
||||
|
||||
void viewport_set_use_arvr(RID p_viewport, bool p_use_arvr);
|
||||
void viewport_set_use_xr(RID p_viewport, bool p_use_xr);
|
||||
|
||||
void viewport_set_size(RID p_viewport, int p_width, int p_height);
|
||||
|
||||
|
|
|
@ -370,7 +370,7 @@ public:
|
|||
|
||||
FUNCRID(viewport)
|
||||
|
||||
FUNC2(viewport_set_use_arvr, RID, bool)
|
||||
FUNC2(viewport_set_use_xr, RID, bool)
|
||||
|
||||
FUNC3(viewport_set_size, RID, int, int)
|
||||
|
||||
|
|
|
@ -1766,7 +1766,7 @@ void RenderingServer::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("camera_set_use_vertical_aspect", "camera", "enable"), &RenderingServer::camera_set_use_vertical_aspect);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("viewport_create"), &RenderingServer::viewport_create);
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_use_arvr", "viewport", "use_arvr"), &RenderingServer::viewport_set_use_arvr);
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_use_xr", "viewport", "use_xr"), &RenderingServer::viewport_set_use_xr);
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_size", "viewport", "width", "height"), &RenderingServer::viewport_set_size);
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_active", "viewport", "active"), &RenderingServer::viewport_set_active);
|
||||
ClassDB::bind_method(D_METHOD("viewport_set_parent_viewport", "viewport", "parent_viewport"), &RenderingServer::viewport_set_parent_viewport);
|
||||
|
|
|
@ -580,7 +580,7 @@ public:
|
|||
|
||||
virtual RID viewport_create() = 0;
|
||||
|
||||
virtual void viewport_set_use_arvr(RID p_viewport, bool p_use_arvr) = 0;
|
||||
virtual void viewport_set_use_xr(RID p_viewport, bool p_use_xr) = 0;
|
||||
virtual void viewport_set_size(RID p_viewport, int p_width, int p_height) = 0;
|
||||
virtual void viewport_set_active(RID p_viewport, bool p_active) = 0;
|
||||
virtual void viewport_set_parent_viewport(RID p_viewport, RID p_parent_viewport) = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_interface.cpp */
|
||||
/* xr_interface.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,24 +28,24 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "arvr_interface.h"
|
||||
#include "xr_interface.h"
|
||||
|
||||
void ARVRInterface::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_name"), &ARVRInterface::get_name);
|
||||
ClassDB::bind_method(D_METHOD("get_capabilities"), &ARVRInterface::get_capabilities);
|
||||
void XRInterface::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_name"), &XRInterface::get_name);
|
||||
ClassDB::bind_method(D_METHOD("get_capabilities"), &XRInterface::get_capabilities);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_primary"), &ARVRInterface::is_primary);
|
||||
ClassDB::bind_method(D_METHOD("set_is_primary", "enable"), &ARVRInterface::set_is_primary);
|
||||
ClassDB::bind_method(D_METHOD("is_primary"), &XRInterface::is_primary);
|
||||
ClassDB::bind_method(D_METHOD("set_is_primary", "enable"), &XRInterface::set_is_primary);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_initialized"), &ARVRInterface::is_initialized);
|
||||
ClassDB::bind_method(D_METHOD("set_is_initialized", "initialized"), &ARVRInterface::set_is_initialized);
|
||||
ClassDB::bind_method(D_METHOD("initialize"), &ARVRInterface::initialize);
|
||||
ClassDB::bind_method(D_METHOD("uninitialize"), &ARVRInterface::uninitialize);
|
||||
ClassDB::bind_method(D_METHOD("is_initialized"), &XRInterface::is_initialized);
|
||||
ClassDB::bind_method(D_METHOD("set_is_initialized", "initialized"), &XRInterface::set_is_initialized);
|
||||
ClassDB::bind_method(D_METHOD("initialize"), &XRInterface::initialize);
|
||||
ClassDB::bind_method(D_METHOD("uninitialize"), &XRInterface::uninitialize);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_tracking_status"), &ARVRInterface::get_tracking_status);
|
||||
ClassDB::bind_method(D_METHOD("get_tracking_status"), &XRInterface::get_tracking_status);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_render_targetsize"), &ARVRInterface::get_render_targetsize);
|
||||
ClassDB::bind_method(D_METHOD("is_stereo"), &ARVRInterface::is_stereo);
|
||||
ClassDB::bind_method(D_METHOD("get_render_targetsize"), &XRInterface::get_render_targetsize);
|
||||
ClassDB::bind_method(D_METHOD("is_stereo"), &XRInterface::is_stereo);
|
||||
|
||||
ADD_GROUP("Interface", "interface_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interface_is_primary"), "set_is_primary", "is_primary");
|
||||
|
@ -54,55 +54,55 @@ void ARVRInterface::_bind_methods() {
|
|||
// we don't have any properties specific to VR yet....
|
||||
|
||||
// but we do have properties specific to AR....
|
||||
ClassDB::bind_method(D_METHOD("get_anchor_detection_is_enabled"), &ARVRInterface::get_anchor_detection_is_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_anchor_detection_is_enabled", "enable"), &ARVRInterface::set_anchor_detection_is_enabled);
|
||||
ClassDB::bind_method(D_METHOD("get_camera_feed_id"), &ARVRInterface::get_camera_feed_id);
|
||||
ClassDB::bind_method(D_METHOD("get_anchor_detection_is_enabled"), &XRInterface::get_anchor_detection_is_enabled);
|
||||
ClassDB::bind_method(D_METHOD("set_anchor_detection_is_enabled", "enable"), &XRInterface::set_anchor_detection_is_enabled);
|
||||
ClassDB::bind_method(D_METHOD("get_camera_feed_id"), &XRInterface::get_camera_feed_id);
|
||||
|
||||
ADD_GROUP("AR", "ar_");
|
||||
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ar_is_anchor_detection_enabled"), "set_anchor_detection_is_enabled", "get_anchor_detection_is_enabled");
|
||||
|
||||
BIND_ENUM_CONSTANT(ARVR_NONE);
|
||||
BIND_ENUM_CONSTANT(ARVR_MONO);
|
||||
BIND_ENUM_CONSTANT(ARVR_STEREO);
|
||||
BIND_ENUM_CONSTANT(ARVR_AR);
|
||||
BIND_ENUM_CONSTANT(ARVR_EXTERNAL);
|
||||
BIND_ENUM_CONSTANT(XR_NONE);
|
||||
BIND_ENUM_CONSTANT(XR_MONO);
|
||||
BIND_ENUM_CONSTANT(XR_STEREO);
|
||||
BIND_ENUM_CONSTANT(XR_AR);
|
||||
BIND_ENUM_CONSTANT(XR_EXTERNAL);
|
||||
|
||||
BIND_ENUM_CONSTANT(EYE_MONO);
|
||||
BIND_ENUM_CONSTANT(EYE_LEFT);
|
||||
BIND_ENUM_CONSTANT(EYE_RIGHT);
|
||||
|
||||
BIND_ENUM_CONSTANT(ARVR_NORMAL_TRACKING);
|
||||
BIND_ENUM_CONSTANT(ARVR_EXCESSIVE_MOTION);
|
||||
BIND_ENUM_CONSTANT(ARVR_INSUFFICIENT_FEATURES);
|
||||
BIND_ENUM_CONSTANT(ARVR_UNKNOWN_TRACKING);
|
||||
BIND_ENUM_CONSTANT(ARVR_NOT_TRACKING);
|
||||
BIND_ENUM_CONSTANT(XR_NORMAL_TRACKING);
|
||||
BIND_ENUM_CONSTANT(XR_EXCESSIVE_MOTION);
|
||||
BIND_ENUM_CONSTANT(XR_INSUFFICIENT_FEATURES);
|
||||
BIND_ENUM_CONSTANT(XR_UNKNOWN_TRACKING);
|
||||
BIND_ENUM_CONSTANT(XR_NOT_TRACKING);
|
||||
};
|
||||
|
||||
StringName ARVRInterface::get_name() const {
|
||||
StringName XRInterface::get_name() const {
|
||||
return "Unknown";
|
||||
};
|
||||
|
||||
bool ARVRInterface::is_primary() {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, false);
|
||||
bool XRInterface::is_primary() {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, false);
|
||||
|
||||
return arvr_server->get_primary_interface() == this;
|
||||
return xr_server->get_primary_interface() == this;
|
||||
};
|
||||
|
||||
void ARVRInterface::set_is_primary(bool p_is_primary) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
void XRInterface::set_is_primary(bool p_is_primary) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
if (p_is_primary) {
|
||||
ERR_FAIL_COND(!is_initialized());
|
||||
|
||||
arvr_server->set_primary_interface(this);
|
||||
xr_server->set_primary_interface(this);
|
||||
} else {
|
||||
arvr_server->clear_primary_interface_if(this);
|
||||
xr_server->clear_primary_interface_if(this);
|
||||
};
|
||||
};
|
||||
|
||||
void ARVRInterface::set_is_initialized(bool p_initialized) {
|
||||
void XRInterface::set_is_initialized(bool p_initialized) {
|
||||
if (p_initialized) {
|
||||
if (!is_initialized()) {
|
||||
initialize();
|
||||
|
@ -114,31 +114,31 @@ void ARVRInterface::set_is_initialized(bool p_initialized) {
|
|||
};
|
||||
};
|
||||
|
||||
ARVRInterface::Tracking_status ARVRInterface::get_tracking_status() const {
|
||||
XRInterface::Tracking_status XRInterface::get_tracking_status() const {
|
||||
return tracking_state;
|
||||
};
|
||||
|
||||
ARVRInterface::ARVRInterface() {
|
||||
tracking_state = ARVR_UNKNOWN_TRACKING;
|
||||
XRInterface::XRInterface() {
|
||||
tracking_state = XR_UNKNOWN_TRACKING;
|
||||
};
|
||||
|
||||
ARVRInterface::~ARVRInterface(){};
|
||||
XRInterface::~XRInterface(){};
|
||||
|
||||
// optional render to external texture which enhances performance on those platforms that require us to submit our end result into special textures.
|
||||
unsigned int ARVRInterface::get_external_texture_for_eye(ARVRInterface::Eyes p_eye) {
|
||||
unsigned int XRInterface::get_external_texture_for_eye(XRInterface::Eyes p_eye) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
/** these will only be implemented on AR interfaces, so we want dummies for VR **/
|
||||
bool ARVRInterface::get_anchor_detection_is_enabled() const {
|
||||
bool XRInterface::get_anchor_detection_is_enabled() const {
|
||||
return false;
|
||||
};
|
||||
|
||||
void ARVRInterface::set_anchor_detection_is_enabled(bool p_enable){
|
||||
void XRInterface::set_anchor_detection_is_enabled(bool p_enable){
|
||||
// don't do anything here, this needs to be implemented on AR interface to enable/disable things like plane detection etc.
|
||||
};
|
||||
|
||||
int ARVRInterface::get_camera_feed_id() {
|
||||
int XRInterface::get_camera_feed_id() {
|
||||
// don't do anything here, this needs to be implemented on AR interface to enable/disable things like plane detection etc.
|
||||
|
||||
return 0;
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_interface.h */
|
||||
/* xr_interface.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,18 +28,18 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef ARVR_INTERFACE_H
|
||||
#define ARVR_INTERFACE_H
|
||||
#ifndef XR_INTERFACE_H
|
||||
#define XR_INTERFACE_H
|
||||
|
||||
#include "core/math/camera_matrix.h"
|
||||
#include "core/os/thread_safe.h"
|
||||
#include "scene/main/window.h"
|
||||
#include "servers/arvr_server.h"
|
||||
#include "servers/xr_server.h"
|
||||
|
||||
/**
|
||||
@author Bastiaan Olij <mux213@gmail.com>
|
||||
|
||||
The ARVR interface is a template class ontop of which we build interface to different AR, VR and tracking SDKs.
|
||||
The XR interface is a template class ontop of which we build interface to different AR, VR and tracking SDKs.
|
||||
The idea is that we subclass this class, implement the logic, and then instantiate a singleton of each interface
|
||||
when Godot starts. These instances do not initialize themselves but register themselves with the AR/VR server.
|
||||
|
||||
|
@ -48,16 +48,16 @@
|
|||
Note that we may make this into a fully instantiable class for GDNative support.
|
||||
*/
|
||||
|
||||
class ARVRInterface : public Reference {
|
||||
GDCLASS(ARVRInterface, Reference);
|
||||
class XRInterface : public Reference {
|
||||
GDCLASS(XRInterface, Reference);
|
||||
|
||||
public:
|
||||
enum Capabilities { /* purely meta data, provides some info about what this interface supports */
|
||||
ARVR_NONE = 0, /* no capabilities */
|
||||
ARVR_MONO = 1, /* can be used with mono output */
|
||||
ARVR_STEREO = 2, /* can be used with stereo output */
|
||||
ARVR_AR = 4, /* offers a camera feed for AR */
|
||||
ARVR_EXTERNAL = 8 /* renders to external device */
|
||||
XR_NONE = 0, /* no capabilities */
|
||||
XR_MONO = 1, /* can be used with mono output */
|
||||
XR_STEREO = 2, /* can be used with stereo output */
|
||||
XR_AR = 4, /* offers a camera feed for AR */
|
||||
XR_EXTERNAL = 8 /* renders to external device */
|
||||
};
|
||||
|
||||
enum Eyes {
|
||||
|
@ -67,11 +67,11 @@ public:
|
|||
};
|
||||
|
||||
enum Tracking_status { /* tracking status currently based on AR but we can start doing more with this for VR as well */
|
||||
ARVR_NORMAL_TRACKING,
|
||||
ARVR_EXCESSIVE_MOTION,
|
||||
ARVR_INSUFFICIENT_FEATURES,
|
||||
ARVR_UNKNOWN_TRACKING,
|
||||
ARVR_NOT_TRACKING
|
||||
XR_NORMAL_TRACKING,
|
||||
XR_EXCESSIVE_MOTION,
|
||||
XR_INSUFFICIENT_FEATURES,
|
||||
XR_UNKNOWN_TRACKING,
|
||||
XR_NOT_TRACKING
|
||||
};
|
||||
|
||||
protected:
|
||||
|
@ -107,20 +107,20 @@ public:
|
|||
|
||||
virtual Size2 get_render_targetsize() = 0; /* returns the recommended render target size per eye for this device */
|
||||
virtual bool is_stereo() = 0; /* returns true if this interface requires stereo rendering (for VR HMDs) or mono rendering (for mobile AR) */
|
||||
virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) = 0; /* get each eyes camera transform, also implement EYE_MONO */
|
||||
virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) = 0; /* get each eyes projection matrix */
|
||||
virtual unsigned int get_external_texture_for_eye(ARVRInterface::Eyes p_eye); /* if applicable return external texture to render to */
|
||||
virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) = 0; /* output the left or right eye */
|
||||
virtual Transform get_transform_for_eye(XRInterface::Eyes p_eye, const Transform &p_cam_transform) = 0; /* get each eyes camera transform, also implement EYE_MONO */
|
||||
virtual CameraMatrix get_projection_for_eye(XRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) = 0; /* get each eyes projection matrix */
|
||||
virtual unsigned int get_external_texture_for_eye(XRInterface::Eyes p_eye); /* if applicable return external texture to render to */
|
||||
virtual void commit_for_eye(XRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) = 0; /* output the left or right eye */
|
||||
|
||||
virtual void process() = 0;
|
||||
virtual void notification(int p_what) = 0;
|
||||
|
||||
ARVRInterface();
|
||||
~ARVRInterface();
|
||||
XRInterface();
|
||||
~XRInterface();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(ARVRInterface::Capabilities);
|
||||
VARIANT_ENUM_CAST(ARVRInterface::Eyes);
|
||||
VARIANT_ENUM_CAST(ARVRInterface::Tracking_status);
|
||||
VARIANT_ENUM_CAST(XRInterface::Capabilities);
|
||||
VARIANT_ENUM_CAST(XRInterface::Eyes);
|
||||
VARIANT_ENUM_CAST(XRInterface::Tracking_status);
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_positional_tracker.cpp */
|
||||
/* xr_positional_tracker.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,192 +28,192 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "arvr_positional_tracker.h"
|
||||
#include "xr_positional_tracker.h"
|
||||
#include "core/input/input_filter.h"
|
||||
|
||||
void ARVRPositionalTracker::_bind_methods() {
|
||||
void XRPositionalTracker::_bind_methods() {
|
||||
BIND_ENUM_CONSTANT(TRACKER_HAND_UNKNOWN);
|
||||
BIND_ENUM_CONSTANT(TRACKER_LEFT_HAND);
|
||||
BIND_ENUM_CONSTANT(TRACKER_RIGHT_HAND);
|
||||
|
||||
// this class is read only from GDScript, so we only have access to getters..
|
||||
ClassDB::bind_method(D_METHOD("get_type"), &ARVRPositionalTracker::get_type);
|
||||
ClassDB::bind_method(D_METHOD("get_tracker_id"), &ARVRPositionalTracker::get_tracker_id);
|
||||
ClassDB::bind_method(D_METHOD("get_name"), &ARVRPositionalTracker::get_name);
|
||||
ClassDB::bind_method(D_METHOD("get_joy_id"), &ARVRPositionalTracker::get_joy_id);
|
||||
ClassDB::bind_method(D_METHOD("get_tracks_orientation"), &ARVRPositionalTracker::get_tracks_orientation);
|
||||
ClassDB::bind_method(D_METHOD("get_orientation"), &ARVRPositionalTracker::get_orientation);
|
||||
ClassDB::bind_method(D_METHOD("get_tracks_position"), &ARVRPositionalTracker::get_tracks_position);
|
||||
ClassDB::bind_method(D_METHOD("get_position"), &ARVRPositionalTracker::get_position);
|
||||
ClassDB::bind_method(D_METHOD("get_hand"), &ARVRPositionalTracker::get_hand);
|
||||
ClassDB::bind_method(D_METHOD("get_transform", "adjust_by_reference_frame"), &ARVRPositionalTracker::get_transform);
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &ARVRPositionalTracker::get_mesh);
|
||||
ClassDB::bind_method(D_METHOD("get_type"), &XRPositionalTracker::get_type);
|
||||
ClassDB::bind_method(D_METHOD("get_tracker_id"), &XRPositionalTracker::get_tracker_id);
|
||||
ClassDB::bind_method(D_METHOD("get_name"), &XRPositionalTracker::get_name);
|
||||
ClassDB::bind_method(D_METHOD("get_joy_id"), &XRPositionalTracker::get_joy_id);
|
||||
ClassDB::bind_method(D_METHOD("get_tracks_orientation"), &XRPositionalTracker::get_tracks_orientation);
|
||||
ClassDB::bind_method(D_METHOD("get_orientation"), &XRPositionalTracker::get_orientation);
|
||||
ClassDB::bind_method(D_METHOD("get_tracks_position"), &XRPositionalTracker::get_tracks_position);
|
||||
ClassDB::bind_method(D_METHOD("get_position"), &XRPositionalTracker::get_position);
|
||||
ClassDB::bind_method(D_METHOD("get_hand"), &XRPositionalTracker::get_hand);
|
||||
ClassDB::bind_method(D_METHOD("get_transform", "adjust_by_reference_frame"), &XRPositionalTracker::get_transform);
|
||||
ClassDB::bind_method(D_METHOD("get_mesh"), &XRPositionalTracker::get_mesh);
|
||||
|
||||
// these functions we don't want to expose to normal users but do need to be callable from GDNative
|
||||
ClassDB::bind_method(D_METHOD("_set_type", "type"), &ARVRPositionalTracker::set_type);
|
||||
ClassDB::bind_method(D_METHOD("_set_name", "name"), &ARVRPositionalTracker::set_name);
|
||||
ClassDB::bind_method(D_METHOD("_set_joy_id", "joy_id"), &ARVRPositionalTracker::set_joy_id);
|
||||
ClassDB::bind_method(D_METHOD("_set_orientation", "orientation"), &ARVRPositionalTracker::set_orientation);
|
||||
ClassDB::bind_method(D_METHOD("_set_rw_position", "rw_position"), &ARVRPositionalTracker::set_rw_position);
|
||||
ClassDB::bind_method(D_METHOD("_set_mesh", "mesh"), &ARVRPositionalTracker::set_mesh);
|
||||
ClassDB::bind_method(D_METHOD("get_rumble"), &ARVRPositionalTracker::get_rumble);
|
||||
ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &ARVRPositionalTracker::set_rumble);
|
||||
ClassDB::bind_method(D_METHOD("_set_type", "type"), &XRPositionalTracker::set_type);
|
||||
ClassDB::bind_method(D_METHOD("_set_name", "name"), &XRPositionalTracker::set_name);
|
||||
ClassDB::bind_method(D_METHOD("_set_joy_id", "joy_id"), &XRPositionalTracker::set_joy_id);
|
||||
ClassDB::bind_method(D_METHOD("_set_orientation", "orientation"), &XRPositionalTracker::set_orientation);
|
||||
ClassDB::bind_method(D_METHOD("_set_rw_position", "rw_position"), &XRPositionalTracker::set_rw_position);
|
||||
ClassDB::bind_method(D_METHOD("_set_mesh", "mesh"), &XRPositionalTracker::set_mesh);
|
||||
ClassDB::bind_method(D_METHOD("get_rumble"), &XRPositionalTracker::get_rumble);
|
||||
ClassDB::bind_method(D_METHOD("set_rumble", "rumble"), &XRPositionalTracker::set_rumble);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "rumble"), "set_rumble", "get_rumble");
|
||||
};
|
||||
|
||||
void ARVRPositionalTracker::set_type(ARVRServer::TrackerType p_type) {
|
||||
void XRPositionalTracker::set_type(XRServer::TrackerType p_type) {
|
||||
if (type != p_type) {
|
||||
type = p_type;
|
||||
hand = ARVRPositionalTracker::TRACKER_HAND_UNKNOWN;
|
||||
hand = XRPositionalTracker::TRACKER_HAND_UNKNOWN;
|
||||
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
// get a tracker id for our type
|
||||
// note if this is a controller this will be 3 or higher but we may change it later.
|
||||
tracker_id = arvr_server->get_free_tracker_id_for_type(p_type);
|
||||
tracker_id = xr_server->get_free_tracker_id_for_type(p_type);
|
||||
};
|
||||
};
|
||||
|
||||
ARVRServer::TrackerType ARVRPositionalTracker::get_type() const {
|
||||
XRServer::TrackerType XRPositionalTracker::get_type() const {
|
||||
return type;
|
||||
};
|
||||
|
||||
void ARVRPositionalTracker::set_name(const String &p_name) {
|
||||
void XRPositionalTracker::set_name(const String &p_name) {
|
||||
name = p_name;
|
||||
};
|
||||
|
||||
StringName ARVRPositionalTracker::get_name() const {
|
||||
StringName XRPositionalTracker::get_name() const {
|
||||
return name;
|
||||
};
|
||||
|
||||
int ARVRPositionalTracker::get_tracker_id() const {
|
||||
int XRPositionalTracker::get_tracker_id() const {
|
||||
return tracker_id;
|
||||
};
|
||||
|
||||
void ARVRPositionalTracker::set_joy_id(int p_joy_id) {
|
||||
void XRPositionalTracker::set_joy_id(int p_joy_id) {
|
||||
joy_id = p_joy_id;
|
||||
};
|
||||
|
||||
int ARVRPositionalTracker::get_joy_id() const {
|
||||
int XRPositionalTracker::get_joy_id() const {
|
||||
return joy_id;
|
||||
};
|
||||
|
||||
bool ARVRPositionalTracker::get_tracks_orientation() const {
|
||||
bool XRPositionalTracker::get_tracks_orientation() const {
|
||||
return tracks_orientation;
|
||||
};
|
||||
|
||||
void ARVRPositionalTracker::set_orientation(const Basis &p_orientation) {
|
||||
void XRPositionalTracker::set_orientation(const Basis &p_orientation) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
tracks_orientation = true; // obviously we have this
|
||||
orientation = p_orientation;
|
||||
};
|
||||
|
||||
Basis ARVRPositionalTracker::get_orientation() const {
|
||||
Basis XRPositionalTracker::get_orientation() const {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
return orientation;
|
||||
};
|
||||
|
||||
bool ARVRPositionalTracker::get_tracks_position() const {
|
||||
bool XRPositionalTracker::get_tracks_position() const {
|
||||
return tracks_position;
|
||||
};
|
||||
|
||||
void ARVRPositionalTracker::set_position(const Vector3 &p_position) {
|
||||
void XRPositionalTracker::set_position(const Vector3 &p_position) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
real_t world_scale = arvr_server->get_world_scale();
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
real_t world_scale = xr_server->get_world_scale();
|
||||
ERR_FAIL_COND(world_scale == 0);
|
||||
|
||||
tracks_position = true; // obviously we have this
|
||||
rw_position = p_position / world_scale;
|
||||
};
|
||||
|
||||
Vector3 ARVRPositionalTracker::get_position() const {
|
||||
Vector3 XRPositionalTracker::get_position() const {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, rw_position);
|
||||
real_t world_scale = arvr_server->get_world_scale();
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, rw_position);
|
||||
real_t world_scale = xr_server->get_world_scale();
|
||||
|
||||
return rw_position * world_scale;
|
||||
};
|
||||
|
||||
void ARVRPositionalTracker::set_rw_position(const Vector3 &p_rw_position) {
|
||||
void XRPositionalTracker::set_rw_position(const Vector3 &p_rw_position) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
tracks_position = true; // obviously we have this
|
||||
rw_position = p_rw_position;
|
||||
};
|
||||
|
||||
Vector3 ARVRPositionalTracker::get_rw_position() const {
|
||||
Vector3 XRPositionalTracker::get_rw_position() const {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
return rw_position;
|
||||
};
|
||||
|
||||
void ARVRPositionalTracker::set_mesh(const Ref<Mesh> &p_mesh) {
|
||||
void XRPositionalTracker::set_mesh(const Ref<Mesh> &p_mesh) {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
mesh = p_mesh;
|
||||
};
|
||||
|
||||
Ref<Mesh> ARVRPositionalTracker::get_mesh() const {
|
||||
Ref<Mesh> XRPositionalTracker::get_mesh() const {
|
||||
_THREAD_SAFE_METHOD_
|
||||
|
||||
return mesh;
|
||||
};
|
||||
|
||||
ARVRPositionalTracker::TrackerHand ARVRPositionalTracker::get_hand() const {
|
||||
XRPositionalTracker::TrackerHand XRPositionalTracker::get_hand() const {
|
||||
return hand;
|
||||
};
|
||||
|
||||
void ARVRPositionalTracker::set_hand(const ARVRPositionalTracker::TrackerHand p_hand) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL(arvr_server);
|
||||
void XRPositionalTracker::set_hand(const XRPositionalTracker::TrackerHand p_hand) {
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL(xr_server);
|
||||
|
||||
if (hand != p_hand) {
|
||||
// we can only set this if we've previously set this to be a controller!!
|
||||
ERR_FAIL_COND((type != ARVRServer::TRACKER_CONTROLLER) && (p_hand != ARVRPositionalTracker::TRACKER_HAND_UNKNOWN));
|
||||
ERR_FAIL_COND((type != XRServer::TRACKER_CONTROLLER) && (p_hand != XRPositionalTracker::TRACKER_HAND_UNKNOWN));
|
||||
|
||||
hand = p_hand;
|
||||
if (hand == ARVRPositionalTracker::TRACKER_LEFT_HAND) {
|
||||
if (!arvr_server->is_tracker_id_in_use_for_type(type, 1)) {
|
||||
if (hand == XRPositionalTracker::TRACKER_LEFT_HAND) {
|
||||
if (!xr_server->is_tracker_id_in_use_for_type(type, 1)) {
|
||||
tracker_id = 1;
|
||||
};
|
||||
} else if (hand == ARVRPositionalTracker::TRACKER_RIGHT_HAND) {
|
||||
if (!arvr_server->is_tracker_id_in_use_for_type(type, 2)) {
|
||||
} else if (hand == XRPositionalTracker::TRACKER_RIGHT_HAND) {
|
||||
if (!xr_server->is_tracker_id_in_use_for_type(type, 2)) {
|
||||
tracker_id = 2;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Transform ARVRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const {
|
||||
Transform XRPositionalTracker::get_transform(bool p_adjust_by_reference_frame) const {
|
||||
Transform new_transform;
|
||||
|
||||
new_transform.basis = get_orientation();
|
||||
new_transform.origin = get_position();
|
||||
|
||||
if (p_adjust_by_reference_frame) {
|
||||
ARVRServer *arvr_server = ARVRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(arvr_server, new_transform);
|
||||
XRServer *xr_server = XRServer::get_singleton();
|
||||
ERR_FAIL_NULL_V(xr_server, new_transform);
|
||||
|
||||
new_transform = arvr_server->get_reference_frame() * new_transform;
|
||||
new_transform = xr_server->get_reference_frame() * new_transform;
|
||||
};
|
||||
|
||||
return new_transform;
|
||||
};
|
||||
|
||||
real_t ARVRPositionalTracker::get_rumble() const {
|
||||
real_t XRPositionalTracker::get_rumble() const {
|
||||
return rumble;
|
||||
};
|
||||
|
||||
void ARVRPositionalTracker::set_rumble(real_t p_rumble) {
|
||||
void XRPositionalTracker::set_rumble(real_t p_rumble) {
|
||||
if (p_rumble > 0.0) {
|
||||
rumble = p_rumble;
|
||||
} else {
|
||||
|
@ -221,8 +221,8 @@ void ARVRPositionalTracker::set_rumble(real_t p_rumble) {
|
|||
};
|
||||
};
|
||||
|
||||
ARVRPositionalTracker::ARVRPositionalTracker() {
|
||||
type = ARVRServer::TRACKER_UNKNOWN;
|
||||
XRPositionalTracker::XRPositionalTracker() {
|
||||
type = XRServer::TRACKER_UNKNOWN;
|
||||
name = "Unknown";
|
||||
joy_id = -1;
|
||||
tracker_id = 0;
|
||||
|
@ -232,6 +232,6 @@ ARVRPositionalTracker::ARVRPositionalTracker() {
|
|||
rumble = 0.0;
|
||||
};
|
||||
|
||||
ARVRPositionalTracker::~ARVRPositionalTracker(){
|
||||
XRPositionalTracker::~XRPositionalTracker(){
|
||||
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_positional_tracker.h */
|
||||
/* xr_positional_tracker.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,12 +28,12 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef ARVR_POSITIONAL_TRACKER_H
|
||||
#define ARVR_POSITIONAL_TRACKER_H
|
||||
#ifndef XR_POSITIONAL_TRACKER_H
|
||||
#define XR_POSITIONAL_TRACKER_H
|
||||
|
||||
#include "core/os/thread_safe.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
#include "servers/arvr_server.h"
|
||||
#include "servers/xr_server.h"
|
||||
|
||||
/**
|
||||
@author Bastiaan Olij <mux213@gmail.com>
|
||||
|
@ -43,8 +43,8 @@
|
|||
This is where potentially additional AR/VR interfaces may be active as there are AR/VR SDKs that solely deal with positional tracking.
|
||||
*/
|
||||
|
||||
class ARVRPositionalTracker : public Object {
|
||||
GDCLASS(ARVRPositionalTracker, Object);
|
||||
class XRPositionalTracker : public Object {
|
||||
GDCLASS(XRPositionalTracker, Object);
|
||||
_THREAD_SAFE_CLASS_
|
||||
|
||||
public:
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
ARVRServer::TrackerType type; // type of tracker
|
||||
XRServer::TrackerType type; // type of tracker
|
||||
StringName name; // (unique) name of the tracker
|
||||
int tracker_id; // tracker index id that is unique per type
|
||||
int joy_id; // if we also have a related joystick entity, the id of the joystick
|
||||
|
@ -65,14 +65,14 @@ private:
|
|||
Vector3 rw_position; // our position "in the real world, so without world_scale applied"
|
||||
Ref<Mesh> mesh; // when available, a mesh that can be used to render this tracker
|
||||
TrackerHand hand; // if known, the hand this tracker is held in
|
||||
real_t rumble; // rumble strength, 0.0 is off, 1.0 is maximum, note that we only record here, arvr_interface is responsible for execution
|
||||
real_t rumble; // rumble strength, 0.0 is off, 1.0 is maximum, note that we only record here, xr_interface is responsible for execution
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
void set_type(ARVRServer::TrackerType p_type);
|
||||
ARVRServer::TrackerType get_type() const;
|
||||
void set_type(XRServer::TrackerType p_type);
|
||||
XRServer::TrackerType get_type() const;
|
||||
void set_name(const String &p_name);
|
||||
StringName get_name() const;
|
||||
int get_tracker_id() const;
|
||||
|
@ -86,8 +86,8 @@ public:
|
|||
Vector3 get_position() const; // get position with world_scale applied
|
||||
void set_rw_position(const Vector3 &p_rw_position);
|
||||
Vector3 get_rw_position() const;
|
||||
ARVRPositionalTracker::TrackerHand get_hand() const;
|
||||
void set_hand(const ARVRPositionalTracker::TrackerHand p_hand);
|
||||
XRPositionalTracker::TrackerHand get_hand() const;
|
||||
void set_hand(const XRPositionalTracker::TrackerHand p_hand);
|
||||
real_t get_rumble() const;
|
||||
void set_rumble(real_t p_rumble);
|
||||
void set_mesh(const Ref<Mesh> &p_mesh);
|
||||
|
@ -95,10 +95,10 @@ public:
|
|||
|
||||
Transform get_transform(bool p_adjust_by_reference_frame) const;
|
||||
|
||||
ARVRPositionalTracker();
|
||||
~ARVRPositionalTracker();
|
||||
XRPositionalTracker();
|
||||
~XRPositionalTracker();
|
||||
};
|
||||
|
||||
VARIANT_ENUM_CAST(ARVRPositionalTracker::TrackerHand);
|
||||
VARIANT_ENUM_CAST(XRPositionalTracker::TrackerHand);
|
||||
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_server.cpp */
|
||||
/* xr_server.cpp */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,41 +28,41 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#include "arvr_server.h"
|
||||
#include "arvr/arvr_interface.h"
|
||||
#include "arvr/arvr_positional_tracker.h"
|
||||
#include "xr_server.h"
|
||||
#include "core/project_settings.h"
|
||||
#include "xr/xr_interface.h"
|
||||
#include "xr/xr_positional_tracker.h"
|
||||
|
||||
ARVRServer *ARVRServer::singleton = nullptr;
|
||||
XRServer *XRServer::singleton = nullptr;
|
||||
|
||||
ARVRServer *ARVRServer::get_singleton() {
|
||||
XRServer *XRServer::get_singleton() {
|
||||
return singleton;
|
||||
};
|
||||
|
||||
void ARVRServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVRServer::get_world_scale);
|
||||
ClassDB::bind_method(D_METHOD("set_world_scale"), &ARVRServer::set_world_scale);
|
||||
ClassDB::bind_method(D_METHOD("get_reference_frame"), &ARVRServer::get_reference_frame);
|
||||
ClassDB::bind_method(D_METHOD("center_on_hmd", "rotation_mode", "keep_height"), &ARVRServer::center_on_hmd);
|
||||
ClassDB::bind_method(D_METHOD("get_hmd_transform"), &ARVRServer::get_hmd_transform);
|
||||
void XRServer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_world_scale"), &XRServer::get_world_scale);
|
||||
ClassDB::bind_method(D_METHOD("set_world_scale"), &XRServer::set_world_scale);
|
||||
ClassDB::bind_method(D_METHOD("get_reference_frame"), &XRServer::get_reference_frame);
|
||||
ClassDB::bind_method(D_METHOD("center_on_hmd", "rotation_mode", "keep_height"), &XRServer::center_on_hmd);
|
||||
ClassDB::bind_method(D_METHOD("get_hmd_transform"), &XRServer::get_hmd_transform);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "world_scale"), "set_world_scale", "get_world_scale");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_interface_count"), &ARVRServer::get_interface_count);
|
||||
ClassDB::bind_method(D_METHOD("get_interface", "idx"), &ARVRServer::get_interface);
|
||||
ClassDB::bind_method(D_METHOD("get_interfaces"), &ARVRServer::get_interfaces);
|
||||
ClassDB::bind_method(D_METHOD("find_interface", "name"), &ARVRServer::find_interface);
|
||||
ClassDB::bind_method(D_METHOD("get_tracker_count"), &ARVRServer::get_tracker_count);
|
||||
ClassDB::bind_method(D_METHOD("get_tracker", "idx"), &ARVRServer::get_tracker);
|
||||
ClassDB::bind_method(D_METHOD("get_interface_count"), &XRServer::get_interface_count);
|
||||
ClassDB::bind_method(D_METHOD("get_interface", "idx"), &XRServer::get_interface);
|
||||
ClassDB::bind_method(D_METHOD("get_interfaces"), &XRServer::get_interfaces);
|
||||
ClassDB::bind_method(D_METHOD("find_interface", "name"), &XRServer::find_interface);
|
||||
ClassDB::bind_method(D_METHOD("get_tracker_count"), &XRServer::get_tracker_count);
|
||||
ClassDB::bind_method(D_METHOD("get_tracker", "idx"), &XRServer::get_tracker);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_primary_interface"), &ARVRServer::get_primary_interface);
|
||||
ClassDB::bind_method(D_METHOD("set_primary_interface", "interface"), &ARVRServer::set_primary_interface);
|
||||
ClassDB::bind_method(D_METHOD("get_primary_interface"), &XRServer::get_primary_interface);
|
||||
ClassDB::bind_method(D_METHOD("set_primary_interface", "interface"), &XRServer::set_primary_interface);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "primary_interface"), "set_primary_interface", "get_primary_interface");
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_last_process_usec"), &ARVRServer::get_last_process_usec);
|
||||
ClassDB::bind_method(D_METHOD("get_last_commit_usec"), &ARVRServer::get_last_commit_usec);
|
||||
ClassDB::bind_method(D_METHOD("get_last_frame_usec"), &ARVRServer::get_last_frame_usec);
|
||||
ClassDB::bind_method(D_METHOD("get_last_process_usec"), &XRServer::get_last_process_usec);
|
||||
ClassDB::bind_method(D_METHOD("get_last_commit_usec"), &XRServer::get_last_commit_usec);
|
||||
ClassDB::bind_method(D_METHOD("get_last_frame_usec"), &XRServer::get_last_frame_usec);
|
||||
|
||||
BIND_ENUM_CONSTANT(TRACKER_CONTROLLER);
|
||||
BIND_ENUM_CONSTANT(TRACKER_BASESTATION);
|
||||
|
@ -82,11 +82,11 @@ void ARVRServer::_bind_methods() {
|
|||
ADD_SIGNAL(MethodInfo("tracker_removed", PropertyInfo(Variant::STRING_NAME, "tracker_name"), PropertyInfo(Variant::INT, "type"), PropertyInfo(Variant::INT, "id")));
|
||||
};
|
||||
|
||||
real_t ARVRServer::get_world_scale() const {
|
||||
real_t XRServer::get_world_scale() const {
|
||||
return world_scale;
|
||||
};
|
||||
|
||||
void ARVRServer::set_world_scale(real_t p_world_scale) {
|
||||
void XRServer::set_world_scale(real_t p_world_scale) {
|
||||
if (p_world_scale < 0.01) {
|
||||
p_world_scale = 0.01;
|
||||
} else if (p_world_scale > 1000.0) {
|
||||
|
@ -96,25 +96,25 @@ void ARVRServer::set_world_scale(real_t p_world_scale) {
|
|||
world_scale = p_world_scale;
|
||||
};
|
||||
|
||||
Transform ARVRServer::get_world_origin() const {
|
||||
Transform XRServer::get_world_origin() const {
|
||||
return world_origin;
|
||||
};
|
||||
|
||||
void ARVRServer::set_world_origin(const Transform &p_world_origin) {
|
||||
void XRServer::set_world_origin(const Transform &p_world_origin) {
|
||||
world_origin = p_world_origin;
|
||||
};
|
||||
|
||||
Transform ARVRServer::get_reference_frame() const {
|
||||
Transform XRServer::get_reference_frame() const {
|
||||
return reference_frame;
|
||||
};
|
||||
|
||||
void ARVRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height) {
|
||||
void XRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height) {
|
||||
if (primary_interface != nullptr) {
|
||||
// clear our current reference frame or we'll end up double adjusting it
|
||||
reference_frame = Transform();
|
||||
|
||||
// requesting our EYE_MONO transform should return our current HMD position
|
||||
Transform new_reference_frame = primary_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, Transform());
|
||||
Transform new_reference_frame = primary_interface->get_transform_for_eye(XRInterface::EYE_MONO, Transform());
|
||||
|
||||
// remove our tilt
|
||||
if (p_rotation_mode == 1) {
|
||||
|
@ -140,15 +140,15 @@ void ARVRServer::center_on_hmd(RotationMode p_rotation_mode, bool p_keep_height)
|
|||
};
|
||||
};
|
||||
|
||||
Transform ARVRServer::get_hmd_transform() {
|
||||
Transform XRServer::get_hmd_transform() {
|
||||
Transform hmd_transform;
|
||||
if (primary_interface != nullptr) {
|
||||
hmd_transform = primary_interface->get_transform_for_eye(ARVRInterface::EYE_MONO, hmd_transform);
|
||||
hmd_transform = primary_interface->get_transform_for_eye(XRInterface::EYE_MONO, hmd_transform);
|
||||
};
|
||||
return hmd_transform;
|
||||
};
|
||||
|
||||
void ARVRServer::add_interface(const Ref<ARVRInterface> &p_interface) {
|
||||
void XRServer::add_interface(const Ref<XRInterface> &p_interface) {
|
||||
ERR_FAIL_COND(p_interface.is_null());
|
||||
|
||||
for (int i = 0; i < interfaces.size(); i++) {
|
||||
|
@ -163,7 +163,7 @@ void ARVRServer::add_interface(const Ref<ARVRInterface> &p_interface) {
|
|||
emit_signal("interface_added", p_interface->get_name());
|
||||
};
|
||||
|
||||
void ARVRServer::remove_interface(const Ref<ARVRInterface> &p_interface) {
|
||||
void XRServer::remove_interface(const Ref<XRInterface> &p_interface) {
|
||||
ERR_FAIL_COND(p_interface.is_null());
|
||||
|
||||
int idx = -1;
|
||||
|
@ -178,23 +178,23 @@ void ARVRServer::remove_interface(const Ref<ARVRInterface> &p_interface) {
|
|||
|
||||
ERR_FAIL_COND(idx == -1);
|
||||
|
||||
print_verbose("ARVR: Removed interface" + p_interface->get_name());
|
||||
print_verbose("XR: Removed interface" + p_interface->get_name());
|
||||
|
||||
emit_signal("interface_removed", p_interface->get_name());
|
||||
interfaces.remove(idx);
|
||||
};
|
||||
|
||||
int ARVRServer::get_interface_count() const {
|
||||
int XRServer::get_interface_count() const {
|
||||
return interfaces.size();
|
||||
};
|
||||
|
||||
Ref<ARVRInterface> ARVRServer::get_interface(int p_index) const {
|
||||
Ref<XRInterface> XRServer::get_interface(int p_index) const {
|
||||
ERR_FAIL_INDEX_V(p_index, interfaces.size(), nullptr);
|
||||
|
||||
return interfaces[p_index];
|
||||
};
|
||||
|
||||
Ref<ARVRInterface> ARVRServer::find_interface(const String &p_name) const {
|
||||
Ref<XRInterface> XRServer::find_interface(const String &p_name) const {
|
||||
int idx = -1;
|
||||
for (int i = 0; i < interfaces.size(); i++) {
|
||||
|
||||
|
@ -210,7 +210,7 @@ Ref<ARVRInterface> ARVRServer::find_interface(const String &p_name) const {
|
|||
return interfaces[idx];
|
||||
};
|
||||
|
||||
Array ARVRServer::get_interfaces() const {
|
||||
Array XRServer::get_interfaces() const {
|
||||
Array ret;
|
||||
|
||||
for (int i = 0; i < interfaces.size(); i++) {
|
||||
|
@ -238,7 +238,7 @@ Array ARVRServer::get_interfaces() const {
|
|||
- using this approach the shield disappears or is no longer tracked, but the gun stays firmly in your right hand because that is still controller 2, further more, if controller 1 is replaced the shield will return.
|
||||
*/
|
||||
|
||||
bool ARVRServer::is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const {
|
||||
bool XRServer::is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const {
|
||||
for (int i = 0; i < trackers.size(); i++) {
|
||||
if (trackers[i]->get_type() == p_tracker_type && trackers[i]->get_tracker_id() == p_tracker_id) {
|
||||
return true;
|
||||
|
@ -249,13 +249,13 @@ bool ARVRServer::is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p
|
|||
return false;
|
||||
};
|
||||
|
||||
int ARVRServer::get_free_tracker_id_for_type(TrackerType p_tracker_type) {
|
||||
int XRServer::get_free_tracker_id_for_type(TrackerType p_tracker_type) {
|
||||
// We start checking at 1, 0 means that it's not a controller..
|
||||
// Note that for controller we reserve:
|
||||
// - 1 for the left hand controller and
|
||||
// - 2 for the right hand controller
|
||||
// so we start at 3 :)
|
||||
int tracker_id = p_tracker_type == ARVRServer::TRACKER_CONTROLLER ? 3 : 1;
|
||||
int tracker_id = p_tracker_type == XRServer::TRACKER_CONTROLLER ? 3 : 1;
|
||||
|
||||
while (is_tracker_id_in_use_for_type(p_tracker_type, tracker_id)) {
|
||||
// try the next one
|
||||
|
@ -265,14 +265,14 @@ int ARVRServer::get_free_tracker_id_for_type(TrackerType p_tracker_type) {
|
|||
return tracker_id;
|
||||
};
|
||||
|
||||
void ARVRServer::add_tracker(ARVRPositionalTracker *p_tracker) {
|
||||
void XRServer::add_tracker(XRPositionalTracker *p_tracker) {
|
||||
ERR_FAIL_NULL(p_tracker);
|
||||
|
||||
trackers.push_back(p_tracker);
|
||||
emit_signal("tracker_added", p_tracker->get_name(), p_tracker->get_type(), p_tracker->get_tracker_id());
|
||||
};
|
||||
|
||||
void ARVRServer::remove_tracker(ARVRPositionalTracker *p_tracker) {
|
||||
void XRServer::remove_tracker(XRPositionalTracker *p_tracker) {
|
||||
ERR_FAIL_NULL(p_tracker);
|
||||
|
||||
int idx = -1;
|
||||
|
@ -291,17 +291,17 @@ void ARVRServer::remove_tracker(ARVRPositionalTracker *p_tracker) {
|
|||
trackers.remove(idx);
|
||||
};
|
||||
|
||||
int ARVRServer::get_tracker_count() const {
|
||||
int XRServer::get_tracker_count() const {
|
||||
return trackers.size();
|
||||
};
|
||||
|
||||
ARVRPositionalTracker *ARVRServer::get_tracker(int p_index) const {
|
||||
XRPositionalTracker *XRServer::get_tracker(int p_index) const {
|
||||
ERR_FAIL_INDEX_V(p_index, trackers.size(), nullptr);
|
||||
|
||||
return trackers[p_index];
|
||||
};
|
||||
|
||||
ARVRPositionalTracker *ARVRServer::find_by_type_and_id(TrackerType p_tracker_type, int p_tracker_id) const {
|
||||
XRPositionalTracker *XRServer::find_by_type_and_id(TrackerType p_tracker_type, int p_tracker_id) const {
|
||||
ERR_FAIL_COND_V(p_tracker_id == 0, nullptr);
|
||||
|
||||
for (int i = 0; i < trackers.size(); i++) {
|
||||
|
@ -313,36 +313,36 @@ ARVRPositionalTracker *ARVRServer::find_by_type_and_id(TrackerType p_tracker_typ
|
|||
return nullptr;
|
||||
};
|
||||
|
||||
Ref<ARVRInterface> ARVRServer::get_primary_interface() const {
|
||||
Ref<XRInterface> XRServer::get_primary_interface() const {
|
||||
return primary_interface;
|
||||
};
|
||||
|
||||
void ARVRServer::set_primary_interface(const Ref<ARVRInterface> &p_primary_interface) {
|
||||
void XRServer::set_primary_interface(const Ref<XRInterface> &p_primary_interface) {
|
||||
primary_interface = p_primary_interface;
|
||||
|
||||
print_verbose("ARVR: Primary interface set to: " + primary_interface->get_name());
|
||||
print_verbose("XR: Primary interface set to: " + primary_interface->get_name());
|
||||
};
|
||||
|
||||
void ARVRServer::clear_primary_interface_if(const Ref<ARVRInterface> &p_primary_interface) {
|
||||
void XRServer::clear_primary_interface_if(const Ref<XRInterface> &p_primary_interface) {
|
||||
if (primary_interface == p_primary_interface) {
|
||||
print_verbose("ARVR: Clearing primary interface");
|
||||
print_verbose("XR: Clearing primary interface");
|
||||
primary_interface.unref();
|
||||
};
|
||||
};
|
||||
|
||||
uint64_t ARVRServer::get_last_process_usec() {
|
||||
uint64_t XRServer::get_last_process_usec() {
|
||||
return last_process_usec;
|
||||
};
|
||||
|
||||
uint64_t ARVRServer::get_last_commit_usec() {
|
||||
uint64_t XRServer::get_last_commit_usec() {
|
||||
return last_commit_usec;
|
||||
};
|
||||
|
||||
uint64_t ARVRServer::get_last_frame_usec() {
|
||||
uint64_t XRServer::get_last_frame_usec() {
|
||||
return last_frame_usec;
|
||||
};
|
||||
|
||||
void ARVRServer::_process() {
|
||||
void XRServer::_process() {
|
||||
/* called from rendering_server_viewport.draw_viewports right before we start drawing our viewports */
|
||||
|
||||
/* mark for our frame timing */
|
||||
|
@ -358,7 +358,7 @@ void ARVRServer::_process() {
|
|||
};
|
||||
};
|
||||
|
||||
void ARVRServer::_mark_commit() {
|
||||
void XRServer::_mark_commit() {
|
||||
/* time this */
|
||||
last_commit_usec = OS::get_singleton()->get_ticks_usec();
|
||||
|
||||
|
@ -366,12 +366,12 @@ void ARVRServer::_mark_commit() {
|
|||
last_frame_usec = last_commit_usec - last_process_usec;
|
||||
};
|
||||
|
||||
ARVRServer::ARVRServer() {
|
||||
XRServer::XRServer() {
|
||||
singleton = this;
|
||||
world_scale = 1.0;
|
||||
};
|
||||
|
||||
ARVRServer::~ARVRServer() {
|
||||
XRServer::~XRServer() {
|
||||
primary_interface.unref();
|
||||
|
||||
while (interfaces.size() > 0) {
|
|
@ -1,5 +1,5 @@
|
|||
/*************************************************************************/
|
||||
/* arvr_server.h */
|
||||
/* xr_server.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
|
@ -28,8 +28,8 @@
|
|||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef ARVR_SERVER_H
|
||||
#define ARVR_SERVER_H
|
||||
#ifndef XR_SERVER_H
|
||||
#define XR_SERVER_H
|
||||
|
||||
#include "core/os/os.h"
|
||||
#include "core/os/thread_safe.h"
|
||||
|
@ -37,16 +37,16 @@
|
|||
#include "core/rid.h"
|
||||
#include "core/variant.h"
|
||||
|
||||
class ARVRInterface;
|
||||
class ARVRPositionalTracker;
|
||||
class XRInterface;
|
||||
class XRPositionalTracker;
|
||||
|
||||
/**
|
||||
@author Bastiaan Olij <mux213@gmail.com>
|
||||
|
||||
The ARVR server is a singleton object that gives access to the various
|
||||
The XR server is a singleton object that gives access to the various
|
||||
objects and SDKs that are available on the system.
|
||||
Because there can be multiple SDKs active this is exposed as an array
|
||||
and our ARVR server object acts as a pass through
|
||||
and our XR server object acts as a pass through
|
||||
Also each positioning tracker is accessible from here.
|
||||
|
||||
I've added some additional info into this header file that should move
|
||||
|
@ -54,8 +54,8 @@ class ARVRPositionalTracker;
|
|||
or as a separate PR once this has been merged into the master branch.
|
||||
**/
|
||||
|
||||
class ARVRServer : public Object {
|
||||
GDCLASS(ARVRServer, Object);
|
||||
class XRServer : public Object {
|
||||
GDCLASS(XRServer, Object);
|
||||
_THREAD_SAFE_CLASS_
|
||||
|
||||
public:
|
||||
|
@ -76,10 +76,10 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
Vector<Ref<ARVRInterface>> interfaces;
|
||||
Vector<ARVRPositionalTracker *> trackers;
|
||||
Vector<Ref<XRInterface>> interfaces;
|
||||
Vector<XRPositionalTracker *> trackers;
|
||||
|
||||
Ref<ARVRInterface> primary_interface; /* we'll identify one interface as primary, this will be used by our viewports */
|
||||
Ref<XRInterface> primary_interface; /* we'll identify one interface as primary, this will be used by our viewports */
|
||||
|
||||
real_t world_scale; /* scale by which we multiply our tracker positions */
|
||||
Transform world_origin; /* our world origin point, maps a location in our virtual world to the origin point in our real world tracking volume */
|
||||
|
@ -90,12 +90,12 @@ private:
|
|||
uint64_t last_frame_usec; /* time it took between process and committing, we should probably average this over the last x frames */
|
||||
|
||||
protected:
|
||||
static ARVRServer *singleton;
|
||||
static XRServer *singleton;
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
static ARVRServer *get_singleton();
|
||||
static XRServer *get_singleton();
|
||||
|
||||
/*
|
||||
World scale allows you to specify a scale factor that is applied to all positioning vectors in our VR world in essence scaling up, or scaling down the world.
|
||||
|
@ -105,7 +105,7 @@ public:
|
|||
Most VR platforms, and our assumption, is that 1 unit in our virtual world equates to 1 meter in the real mode.
|
||||
This scale basically effects the unit size relationship to real world size.
|
||||
|
||||
I may remove access to this property in GDScript in favour of exposing it on the ARVROrigin node
|
||||
I may remove access to this property in GDScript in favour of exposing it on the XROrigin3D node
|
||||
*/
|
||||
real_t get_world_scale() const;
|
||||
void set_world_scale(real_t p_world_scale);
|
||||
|
@ -116,7 +116,7 @@ public:
|
|||
actions be it straffing, teleporting, etc. Movement of the player by moving through the physical space is always tracked
|
||||
in relation to this point.
|
||||
|
||||
Note that the ARVROrigin spatial node in your scene automatically updates this property and it should be used instead of
|
||||
Note that the XROrigin3D spatial node in your scene automatically updates this property and it should be used instead of
|
||||
direct access to this property and it therefore is not available in GDScript
|
||||
|
||||
Note: this should not be used in AR and should be ignored by an AR based interface as it would throw what you're looking at in the real world
|
||||
|
@ -146,20 +146,20 @@ public:
|
|||
/*
|
||||
Interfaces are objects that 'glue' Godot to an AR or VR SDK such as the Oculus SDK, OpenVR, OpenHMD, etc.
|
||||
*/
|
||||
void add_interface(const Ref<ARVRInterface> &p_interface);
|
||||
void remove_interface(const Ref<ARVRInterface> &p_interface);
|
||||
void add_interface(const Ref<XRInterface> &p_interface);
|
||||
void remove_interface(const Ref<XRInterface> &p_interface);
|
||||
int get_interface_count() const;
|
||||
Ref<ARVRInterface> get_interface(int p_index) const;
|
||||
Ref<ARVRInterface> find_interface(const String &p_name) const;
|
||||
Ref<XRInterface> get_interface(int p_index) const;
|
||||
Ref<XRInterface> find_interface(const String &p_name) const;
|
||||
Array get_interfaces() const;
|
||||
|
||||
/*
|
||||
note, more then one interface can technically be active, especially on mobile, but only one interface is used for
|
||||
rendering. This interface identifies itself by calling set_primary_interface when it is initialized
|
||||
*/
|
||||
Ref<ARVRInterface> get_primary_interface() const;
|
||||
void set_primary_interface(const Ref<ARVRInterface> &p_primary_interface);
|
||||
void clear_primary_interface_if(const Ref<ARVRInterface> &p_primary_interface); /* this is automatically called if an interface destructs */
|
||||
Ref<XRInterface> get_primary_interface() const;
|
||||
void set_primary_interface(const Ref<XRInterface> &p_primary_interface);
|
||||
void clear_primary_interface_if(const Ref<XRInterface> &p_primary_interface); /* this is automatically called if an interface destructs */
|
||||
|
||||
/*
|
||||
Our trackers are objects that expose the orientation and position of physical devices such as controller, anchor points, etc.
|
||||
|
@ -167,11 +167,11 @@ public:
|
|||
*/
|
||||
bool is_tracker_id_in_use_for_type(TrackerType p_tracker_type, int p_tracker_id) const;
|
||||
int get_free_tracker_id_for_type(TrackerType p_tracker_type);
|
||||
void add_tracker(ARVRPositionalTracker *p_tracker);
|
||||
void remove_tracker(ARVRPositionalTracker *p_tracker);
|
||||
void add_tracker(XRPositionalTracker *p_tracker);
|
||||
void remove_tracker(XRPositionalTracker *p_tracker);
|
||||
int get_tracker_count() const;
|
||||
ARVRPositionalTracker *get_tracker(int p_index) const;
|
||||
ARVRPositionalTracker *find_by_type_and_id(TrackerType p_tracker_type, int p_tracker_id) const;
|
||||
XRPositionalTracker *get_tracker(int p_index) const;
|
||||
XRPositionalTracker *find_by_type_and_id(TrackerType p_tracker_type, int p_tracker_id) const;
|
||||
|
||||
uint64_t get_last_process_usec();
|
||||
uint64_t get_last_commit_usec();
|
||||
|
@ -180,13 +180,13 @@ public:
|
|||
void _process();
|
||||
void _mark_commit();
|
||||
|
||||
ARVRServer();
|
||||
~ARVRServer();
|
||||
XRServer();
|
||||
~XRServer();
|
||||
};
|
||||
|
||||
#define ARVR ARVRServer
|
||||
#define XR XRServer
|
||||
|
||||
VARIANT_ENUM_CAST(ARVRServer::TrackerType);
|
||||
VARIANT_ENUM_CAST(ARVRServer::RotationMode);
|
||||
VARIANT_ENUM_CAST(XRServer::TrackerType);
|
||||
VARIANT_ENUM_CAST(XRServer::RotationMode);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue