diff --git a/example.csharp/addons/tiltfive/T5Def.cs b/example.csharp/addons/tiltfive/T5Def.cs new file mode 100644 index 0000000..b9ce787 --- /dev/null +++ b/example.csharp/addons/tiltfive/T5Def.cs @@ -0,0 +1,28 @@ +using Godot; +using System; + +public static class T5Def { + + public enum GameboardType + { + Unknown = 1, + LE = 2, + XE = 3, + XE_Raised = 4 + } + + // Buttons + public static StringName WAND_BUTTON_A = "button_a"; + public static StringName WAND_BUTTON_B = "button_b"; + public static StringName WAND_BUTTON_X = "button_x"; + public static StringName WAND_BUTTON_Y = "button_y"; + public static StringName WAND_BUTTON_1 = "button_1"; + public static StringName WAND_BUTTON_2 = "button_2"; + public static StringName WAND_BUTTON_STICK = "button_3"; + public static StringName WAND_BUTTON_T5 = "button_t5"; + public static StringName WAND_BUTTON_TRIGGER = "trigger_click"; + // Axis + public static StringName WAND_ANALOG_STICK = "stick"; + public static StringName WAND_ANALOG_TRIGGER = "trigger"; + +} diff --git a/example.csharp/addons/tiltfive/T5Interface.cs b/example.csharp/addons/tiltfive/T5Interface.cs index eed0147..ccf62aa 100644 --- a/example.csharp/addons/tiltfive/T5Interface.cs +++ b/example.csharp/addons/tiltfive/T5Interface.cs @@ -25,14 +25,6 @@ enum GlassesEventType E_GLASSES_STOPPED_ON_ERROR = 9 } - public enum GameboardType - { - Unknown = 1, - LE = 2, - XE = 3, - XE_Raised = 4 - } - // State of a set of glasses. class XRRigState { public bool available = false; @@ -40,7 +32,7 @@ class XRRigState { public bool reserved = false; public T5XRRig rig; - public GameboardType gameboardType; + public T5Def.GameboardType gameboardType; public bool CanAttemptToReserve { get { return available && !attemptingToReserve && !reserved; } } } @@ -196,7 +188,7 @@ void _OnGlassesEvent(String glassesID, int eventNum) case GlassesEventType.E_GLASSES_TRACKING: { GD.Print(glassesID, " E_GLASSES_TRACKING"); - var gbt = xrInterface.Call("get_gameboard_type", glassesID).As(); + var gbt = xrInterface.Call("get_gameboard_type", glassesID).As(); if(xrRigState.gameboardType != gbt) { xrRigState.gameboardType = gbt; diff --git a/example.csharp/addons/tiltfive/T5Manager.cs b/example.csharp/addons/tiltfive/T5Manager.cs index f3d1f81..7c981f2 100644 --- a/example.csharp/addons/tiltfive/T5Manager.cs +++ b/example.csharp/addons/tiltfive/T5Manager.cs @@ -105,7 +105,7 @@ public void ReleaseXRRig(T5XRRig xrRig) xrRig.QueueFree(); } - public void SetGameboardType(T5XRRig rig, T5Interface.GameboardType gameboard_type) + public void SetGameboardType(T5XRRig rig, T5Def.GameboardType gameboard_type) { } } diff --git a/example.csharp/addons/tiltfive/T5ManagerInterface.cs b/example.csharp/addons/tiltfive/T5ManagerInterface.cs index 7ba50d5..08c64ec 100644 --- a/example.csharp/addons/tiltfive/T5ManagerInterface.cs +++ b/example.csharp/addons/tiltfive/T5ManagerInterface.cs @@ -50,6 +50,6 @@ public interface T5ManagerInterface public void ReleaseXRRig(T5XRRig xrRig); // Invoked by the T5Interface to set the gameboard type the Tilt Five glasses detected - public void SetGameboardType(T5XRRig rig, T5Interface.GameboardType gameboard_type); + public void SetGameboardType(T5XRRig rig, T5Def.GameboardType gameboard_type); } diff --git a/example.csharp/addons/tiltfive/scenes/T5XRRig.cs b/example.csharp/addons/tiltfive/scenes/T5XRRig.cs index c119d2a..b7448dd 100644 --- a/example.csharp/addons/tiltfive/scenes/T5XRRig.cs +++ b/example.csharp/addons/tiltfive/scenes/T5XRRig.cs @@ -8,7 +8,7 @@ public partial class T5XRRig : SubViewport T5ControllerCS wand; public string GlassesID { get; set; } - public T5Interface.GameboardType GameboardType { get; set; } + public T5Def.GameboardType GameboardType { get; set; } public Aabb GameboardSize { get; set; } public T5OriginCS Origin { get { return origin; } } public T5CameraCS Camera{ get { return camera; } } diff --git a/example.csharp/project.godot b/example.csharp/project.godot index 68a5fc7..6fb615f 100644 --- a/example.csharp/project.godot +++ b/example.csharp/project.godot @@ -12,7 +12,7 @@ config_version=5 config/name="T5Example.csharp" run/main_scene="res://main.tscn" -config/features=PackedStringArray("4.2", "Forward Plus") +config/features=PackedStringArray("4.2", "C#", "Forward Plus") config/icon="res://icon.png" [autoload] diff --git a/example.gd/addons/tiltfive/T5Interface.gd b/example.gd/addons/tiltfive/T5Interface.gd index 45bc777..d24088d 100644 --- a/example.gd/addons/tiltfive/T5Interface.gd +++ b/example.gd/addons/tiltfive/T5Interface.gd @@ -62,9 +62,9 @@ func _ready(): tilt_five_xr_interface.initialize() func _start_display(glasses_id : StringName, xr_rig : T5XRRig): - tilt_five_xr_interface.start_display(glasses_id, xr_rig, xr_rig.origin) - xr_rig.camera.tracker = "/user/%s/head" % glasses_id - xr_rig.wand.tracker = "/user/%s/wand_1" % glasses_id + tilt_five_xr_interface.start_display(glasses_id, xr_rig, xr_rig.get_origin()) + xr_rig.get_camera().tracker = "/user/%s/head" % glasses_id + xr_rig.get_wand().tracker = "/user/%s/wand_1" % glasses_id func _process_glasses(): for glasses_id in id_to_state: @@ -128,9 +128,9 @@ func _on_glasses_event(glasses_id, event_num): TiltFiveXRInterface.E_GLASSES_TRACKING: var gbt = tilt_five_xr_interface.get_gameboard_type(glasses_id) var xr_rig = xr_rig_state.xr_rig - if xr_rig and xr_rig.gameboard_type != gbt: - xr_rig.gameboard_type = gbt - xr_rig.gameboard_size = tilt_five_xr_interface.get_gameboard_extents(gbt) + if xr_rig and xr_rig._gameboard_type != gbt: + xr_rig._gameboard_type = gbt + xr_rig._gameboard_size = tilt_five_xr_interface.get_gameboard_extents(gbt) t5_manager.set_gameboard_type(xr_rig, gbt) print_verbose(glasses_id, " E_TRACKING, Gameboard size = ", ) diff --git a/example.gd/addons/tiltfive/T5Manager.gd b/example.gd/addons/tiltfive/T5Manager.gd index a27a98a..567ed11 100644 --- a/example.gd/addons/tiltfive/T5Manager.gd +++ b/example.gd/addons/tiltfive/T5Manager.gd @@ -40,9 +40,10 @@ func _ready(): func create_xr_rig(glasses_id : String) -> T5XRRig: var xr_rig = glasses_scene.instantiate() as T5XRRig + xr_rig._glasses_id = glasses_id glasses_node.add_child(xr_rig) if start_location: - var origin := xr_rig.origin as T5Origin3D + var origin := xr_rig.get_origin() origin.transform = start_location.transform origin.gameboard_scale = start_location.content_scale glasses_scene_was_added.emit(xr_rig) diff --git a/example.gd/addons/tiltfive/scenes/T5XRRig.gd b/example.gd/addons/tiltfive/scenes/T5XRRig.gd index bbde4c1..b1a4c9e 100644 --- a/example.gd/addons/tiltfive/scenes/T5XRRig.gd +++ b/example.gd/addons/tiltfive/scenes/T5XRRig.gd @@ -1,28 +1,41 @@ class_name T5XRRig extends SubViewport ## represents a scene with all the components needed for Tilt Five tracked glasses and wand -## An ID attached to a pair of Tilt Five glasses -var glasses_id : StringName +var _glasses_id : StringName +var _gameboard_type := T5Def.GameboardType.Unknown +var _gameboard_size := AABB() +var _origin : T5Origin3D +var _camera : T5Camera3D +var _wand : T5Controller3D + +## Get the ID attached to a pair of Tilt Five glasses +func get_glasses_id() -> StringName: + return _glasses_id ## Type of gameboard that is set up -var gameboard_type := T5Def.GameboardType.Unknown +func get_gameboard_type() -> T5Def.GameboardType: + return _gameboard_type ## size of the gameboard in meters. Raised XE gameboards can have a height -var gameboard_size := AABB() +func get_gameboard_size() -> AABB: + return _gameboard_size ## the node that relates the center of the gameboard to world coordinates -var origin : T5Origin3D +func get_origin() -> T5Origin3D: + return _origin ## the tracked camera -var camera : T5Camera3D +func get_camera() -> T5Camera3D: + return _camera ## the tracked wand controller -var wand : T5Controller3D +func get_wand() -> T5Controller3D: + return _wand func _enter_tree(): - origin = $Origin - camera = $Origin/Camera - wand = $Origin/Wand_1 + _origin = $Origin + _camera = $Origin/Camera + _wand = $Origin/Wand_1 func _process(_delta): - if wand: wand.visible = wand.get_has_tracking_data() + if _wand: _wand.visible = _wand.get_has_tracking_data() diff --git a/example.gd/project.godot b/example.gd/project.godot index 3c486ef..81e86cc 100644 --- a/example.gd/project.godot +++ b/example.gd/project.godot @@ -1,3 +1,11 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + config_version=5 [application]