Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Meta configs for the eye gaze interaction extension #48

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
- Update to the new Godot 4.2 Android plugin packaging format
- Update the plugin to Godot v2 Android plugin
- Update to the Godot 4.2 Android library
- Add warning when multiple loaders are selected
- Add configs for the OpenXR Eye gaze interaction extension

## 1.1.0
- Update Meta OpenXR loader to version 54
Expand Down
17 changes: 17 additions & 0 deletions demo/addons/godotopenxr/.export/globals.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@tool

# Set of supported vendors
const META_VENDOR_NAME = "meta"
const PICO_VENDOR_NAME = "pico"
const LYNX_VENDOR_NAME = "lynx"
const KHRONOS_VENDOR_NAME = "khr"

const VENDORS_LIST = [
META_VENDOR_NAME,
PICO_VENDOR_NAME,
LYNX_VENDOR_NAME,
KHRONOS_VENDOR_NAME,
]

# Set of custom feature tags supported by the plugin
const EYE_GAZE_INTERACTION_FEATURE = "XR_EXT_eye_gaze_interaction"
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@tool
class_name GodotOpenXREditorExportPlugin extends EditorExportPlugin

var globals = preload("globals.gd")

const OPENXR_MODE_VALUE = 1

var _vendor: String
Expand All @@ -26,14 +28,14 @@ func _get_android_maven_central_dependency() -> String:
return "org.godotengine:godot-openxr-loaders-" + _vendor + ":" + _plugin_version


func _get_vendor_toggle_option_name() -> String:
return "xr_features/enable_" + _vendor + "_plugin"
func _get_vendor_toggle_option_name(vendor_name: String = _vendor) -> String:
return "xr_features/enable_" + vendor_name + "_plugin"


func _get_vendor_toggle_option() -> Dictionary:
func _get_vendor_toggle_option(vendor_name: String = _vendor) -> Dictionary:
var toggle_option = {
"option": {
"name": _get_vendor_toggle_option_name(),
"name": _get_vendor_toggle_option_name(vendor_name),
"class_name": "",
"type": TYPE_BOOL,
"hint": PROPERTY_HINT_NONE,
Expand Down Expand Up @@ -69,7 +71,12 @@ func _get_export_option_warning(platform, option) -> String:
if not(_is_openxr_enabled()) and _get_bool_option(option):
return "\"Enable " + _vendor.capitalize() + " Plugin\" requires \"XR Mode\" to be \"OpenXR\".\n"

return ""
if _is_vendor_plugin_enabled():
for vendor_name in globals.VENDORS_LIST:
if (vendor_name != _vendor) and _is_vendor_plugin_enabled(vendor_name):
return "\"Disable " + _vendor.capitalize() + " Plugin before enabling another. Multiple plugins are not supported!\""

return ""


func _supports_platform(platform) -> bool:
Expand All @@ -92,8 +99,8 @@ func _get_int_option(option: String, default_value: int) -> int:
return default_value


func _is_vendor_plugin_enabled() -> bool:
return _get_bool_option(_get_vendor_toggle_option_name())
func _is_vendor_plugin_enabled(vendor_name: String = _vendor) -> bool:
return _get_bool_option(_get_vendor_toggle_option_name(vendor_name))


func _is_android_aar_file_available(debug: bool) -> bool:
Expand Down
10 changes: 6 additions & 4 deletions demo/addons/godotopenxr/.export/godot_openxr_editor_plugin.gd
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@tool
extends EditorPlugin

var globals = preload("globals.gd")

# A class member to hold the export plugin during its lifecycle.
var meta_export_plugin : EditorExportPlugin
var pico_export_plugin : EditorExportPlugin
Expand All @@ -12,10 +14,10 @@ func _enter_tree():
var plugin_version = get_plugin_version()

# Initializing the export plugins
meta_export_plugin = preload("meta/godot_openxr_meta_editor_export_plugin.gd").new("meta", plugin_version)
pico_export_plugin = preload("pico/godot_openxr_pico_editor_export_plugin.gd").new("pico", plugin_version)
lynx_export_plugin = preload("lynx/godot_openxr_lynx_editor_export_plugin.gd").new("lynx", plugin_version)
khr_export_plugin = preload("khr/godot_openxr_khr_editor_export_plugin.gd").new("khr", plugin_version)
meta_export_plugin = preload("meta/godot_openxr_meta_editor_export_plugin.gd").new(globals.META_VENDOR_NAME, plugin_version)
pico_export_plugin = preload("pico/godot_openxr_pico_editor_export_plugin.gd").new(globals.PICO_VENDOR_NAME, plugin_version)
lynx_export_plugin = preload("lynx/godot_openxr_lynx_editor_export_plugin.gd").new(globals.LYNX_VENDOR_NAME, plugin_version)
khr_export_plugin = preload("khr/godot_openxr_khr_editor_export_plugin.gd").new(globals.KHRONOS_VENDOR_NAME, plugin_version)

add_export_plugin(meta_export_plugin)
add_export_plugin(pico_export_plugin)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@tool
extends "../godot_openxr_editor_export_plugin.gd"

const EYE_TRACKING_NONE_VALUE = 0
const EYE_TRACKING_OPTIONAL_VALUE = 1
const EYE_TRACKING_REQUIRED_VALUE = 2

const PASSTHROUGH_NONE_VALUE = 0
const PASSTHROUGH_OPTIONAL_VALUE = 1
const PASSTHROUGH_REQUIRED_VALUE = 2
Expand All @@ -11,7 +15,20 @@ const HAND_TRACKING_REQUIRED_VALUE = 2

const HAND_TRACKING_FREQUENCY_LOW_VALUE = 0
const HAND_TRACKING_FREQUENCY_HIGH_VALUE = 1


const EYE_TRACKING_OPTION = {
"option": {
"name": "meta_xr_features/eye_tracking",
"class_name": "",
"type": TYPE_INT,
"hint": PROPERTY_HINT_ENUM,
"hint_string": "None,Optional,Required",
"usage": PROPERTY_USAGE_DEFAULT,
},
"default_value": EYE_TRACKING_NONE_VALUE,
"update_visibility": false,
}

const HAND_TRACKING_OPTION = {
"option": {
"name": "meta_xr_features/hand_tracking",
Expand Down Expand Up @@ -57,12 +74,35 @@ func _get_export_options(platform) -> Array[Dictionary]:
return []

return [
_get_vendor_toggle_option(),
_get_vendor_toggle_option(),
EYE_TRACKING_OPTION,
HAND_TRACKING_OPTION,
HAND_TRACKING_FREQUENCY_OPTION,
PASSTHROUGH_OPTION,
]



func _is_eye_tracking_enabled() -> bool:
var eye_tracking_project_setting_enabled = ProjectSettings.get_setting_with_override("xr/openxr/extensions/eye_gaze_interaction")
if not(eye_tracking_project_setting_enabled):
return false

var eye_tracking_option_value = _get_int_option("meta_xr_features/eye_tracking", EYE_TRACKING_NONE_VALUE)
return eye_tracking_option_value > EYE_TRACKING_NONE_VALUE


func _get_export_features(platform, debug) -> PackedStringArray:
var features = PackedStringArray()

if not _supports_platform(platform):
return features

# Add the eye tracking feature if necessary
if _is_eye_tracking_enabled():
features.append(globals.EYE_GAZE_INTERACTION_FEATURE)

return features


func _get_export_option_warning(platform, option) -> String:
if not _supports_platform(platform):
Expand All @@ -71,6 +111,12 @@ func _get_export_option_warning(platform, option) -> String:
var warning = ""
var openxr_enabled = _is_openxr_enabled()
match (option):
"meta_xr_features/eye_tracking":
var eye_tracking_project_setting_enabled = ProjectSettings.get_setting_with_override("xr/openxr/extensions/eye_gaze_interaction")
var eye_tracking_option_value = _get_int_option("meta_xr_features/eye_tracking", EYE_TRACKING_NONE_VALUE)
if eye_tracking_option_value > EYE_TRACKING_NONE_VALUE and not(eye_tracking_project_setting_enabled):
warning = "\"Eye Tracking\" project setting must be enabled!\n"

"meta_xr_features/hand_tracking":
if not(openxr_enabled) and _get_int_option(option, HAND_TRACKING_NONE_VALUE) > HAND_TRACKING_NONE_VALUE:
warning = "\"Hand Tracking\" requires \"XR Mode\" to be \"OpenXR\".\n"
Expand All @@ -91,6 +137,17 @@ func _get_android_manifest_element_contents(platform, debug) -> String:

var contents = ""

# Check for eye tracking
if _is_eye_tracking_enabled():
contents += " <uses-permission android:name=\"com.oculus.permission.EYE_TRACKING\" />\n"

var eye_tracking_value = _get_int_option("meta_xr_features/eye_tracking", EYE_TRACKING_NONE_VALUE)
if eye_tracking_value == EYE_TRACKING_OPTIONAL_VALUE:
contents += " <uses-feature android:name=\"oculus.software.eye_tracking\" android:required=\"false\" />\n"
elif eye_tracking_value == EYE_TRACKING_REQUIRED_VALUE:
contents += " <uses-feature android:name=\"oculus.software.eye_tracking\" android:required=\"true\" />\n"


# Check for hand tracking
var hand_tracking_value = _get_int_option("meta_xr_features/hand_tracking", HAND_TRACKING_NONE_VALUE)
if hand_tracking_value > HAND_TRACKING_NONE_VALUE:
Expand Down
2 changes: 2 additions & 0 deletions demo/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ package/app_category=2
package/retain_data_on_uninstall=false
package/exclude_from_recents=false
package/show_in_android_tv=false
package/show_in_app_library=true
package/show_as_launcher_app=false
launcher_icons/main_192x192=""
launcher_icons/adaptive_foreground_432x432=""
Expand Down Expand Up @@ -205,3 +206,4 @@ meta_xr_features/passthrough=1
xr_features/enable_pico_plugin=false
xr_features/enable_lynx_plugin=false
xr_features/enable_khr_plugin=false
meta_xr_features/eye_tracking=1
3 changes: 2 additions & 1 deletion demo/main.gd
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
extends Node3D

var xr_interface : XRInterface = null

# Called when the node enters the scene tree for the first time.
func _ready():
var xr_interface : XRInterface = XRServer.find_interface("OpenXR")
xr_interface = XRServer.find_interface("OpenXR")
if xr_interface and xr_interface.is_initialized():
var vp: Viewport = get_viewport()
vp.use_xr = true
Expand Down
23 changes: 19 additions & 4 deletions demo/main.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=8 format=3 uid="uid://cqsodpswgup8w"]
[gd_scene load_steps=10 format=3 uid="uid://cqsodpswgup8w"]

[ext_resource type="Script" path="res://main.gd" id="1_fsva1"]

Expand All @@ -20,7 +20,14 @@ size = Vector3(0.1, 0.1, 0.1)
[sub_resource type="BoxMesh" id="BoxMesh_ey3x4"]
size = Vector3(0.1, 0.1, 0.1)

[sub_resource type="SphereMesh" id="SphereMesh_5gcab"]
radius = 0.025
height = 0.05

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_k604q"]

[sub_resource type="PlaneMesh" id="PlaneMesh_mjcgt"]
material = SubResource("StandardMaterial3D_k604q")
size = Vector2(10, 10)

[node name="Main" type="Node3D"]
Expand All @@ -39,19 +46,27 @@ shadow_enabled = true
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.352791, 0)

[node name="LeftHand" type="XRController3D" parent="XROrigin3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.460909, 0, -0.241118)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.460909, 0.388594, -0.241118)
tracker = &"left_hand"
pose = &"aim"

[node name="LeftHandMesh" type="MeshInstance3D" parent="XROrigin3D/LeftHand"]
mesh = SubResource("BoxMesh_3kt6b")

[node name="RightHand" type="XRController3D" parent="XROrigin3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.478861, 0, -0.241097)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.478861, 0.468292, -0.241097)
tracker = &"right_hand"

[node name="MeshInstance3D" type="MeshInstance3D" parent="XROrigin3D/RightHand"]
[node name="RightHandMesh" type="MeshInstance3D" parent="XROrigin3D/RightHand"]
mesh = SubResource("BoxMesh_ey3x4")

[node name="EyeGaze" type="XRController3D" parent="XROrigin3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.977669, 0)
tracker = &"/user/eyes_ext"

[node name="EyeGazeMesh" type="MeshInstance3D" parent="XROrigin3D/EyeGaze"]
transform = Transform3D(1, 0, 0, 0, -0.0133513, 0.999911, 0, -0.999911, -0.0133513, 0, 0, -1.18886)
mesh = SubResource("SphereMesh_5gcab")

[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("PlaneMesh_mjcgt")
16 changes: 12 additions & 4 deletions demo/openxr_action_map.tres
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_resource type="OpenXRActionMap" load_steps=197 format=3 uid="uid://b1wdu77pwks8y"]
[gd_resource type="OpenXRActionMap" load_steps=199 format=3 uid="uid://b1wdu77pwks8y"]

[sub_resource type="OpenXRAction" id="OpenXRAction_6v1ja"]
resource_name = "trigger"
Expand Down Expand Up @@ -115,7 +115,7 @@ toplevel_paths = PackedStringArray("/user/hand/left", "/user/hand/right")
resource_name = "default_pose"
localized_name = "Default pose"
action_type = 3
toplevel_paths = PackedStringArray("/user/hand/left", "/user/hand/right", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/keyboard")
toplevel_paths = PackedStringArray("/user/hand/left", "/user/hand/right", "/user/vive_tracker_htcx/role/left_foot", "/user/vive_tracker_htcx/role/right_foot", "/user/vive_tracker_htcx/role/left_shoulder", "/user/vive_tracker_htcx/role/right_shoulder", "/user/vive_tracker_htcx/role/left_elbow", "/user/vive_tracker_htcx/role/right_elbow", "/user/vive_tracker_htcx/role/left_knee", "/user/vive_tracker_htcx/role/right_knee", "/user/vive_tracker_htcx/role/waist", "/user/vive_tracker_htcx/role/chest", "/user/vive_tracker_htcx/role/camera", "/user/vive_tracker_htcx/role/keyboard", "/user/eyes_ext")

[sub_resource type="OpenXRAction" id="OpenXRAction_1vol5"]
resource_name = "aim_pose"
Expand Down Expand Up @@ -455,7 +455,7 @@ action = SubResource("OpenXRAction_0kk6l")
paths = PackedStringArray("/user/hand/left/output/haptic", "/user/hand/right/output/haptic")

[sub_resource type="OpenXRInteractionProfile" id="OpenXRInteractionProfile_ert82"]
interaction_profile_path = "/interaction_profiles/pico/neo3_controller"
interaction_profile_path = "/interaction_profiles/bytedance/pico_neo3_controller"
bindings = [SubResource("OpenXRIPBinding_jwljs"), SubResource("OpenXRIPBinding_ajdja"), SubResource("OpenXRIPBinding_tla6d"), SubResource("OpenXRIPBinding_377i1"), SubResource("OpenXRIPBinding_xa4wm"), SubResource("OpenXRIPBinding_7xuhj"), SubResource("OpenXRIPBinding_03t7v"), SubResource("OpenXRIPBinding_b08bq"), SubResource("OpenXRIPBinding_fxhob"), SubResource("OpenXRIPBinding_661oy"), SubResource("OpenXRIPBinding_vsv5g"), SubResource("OpenXRIPBinding_bxu5n"), SubResource("OpenXRIPBinding_xer3x"), SubResource("OpenXRIPBinding_urrdv"), SubResource("OpenXRIPBinding_e1sbn"), SubResource("OpenXRIPBinding_vmo5c"), SubResource("OpenXRIPBinding_lytd7"), SubResource("OpenXRIPBinding_feotl"), SubResource("OpenXRIPBinding_fxu5d")]

[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_w77tt"]
Expand Down Expand Up @@ -830,6 +830,14 @@ paths = PackedStringArray("/user/vive_tracker_htcx/role/left_foot/output/haptic"
interaction_profile_path = "/interaction_profiles/htc/vive_tracker_htcx"
bindings = [SubResource("OpenXRIPBinding_vke8d"), SubResource("OpenXRIPBinding_3o4hq")]

[sub_resource type="OpenXRIPBinding" id="OpenXRIPBinding_73bb6"]
action = SubResource("OpenXRAction_vk7pf")
paths = PackedStringArray("/user/eyes_ext/input/gaze_ext/pose")

[sub_resource type="OpenXRInteractionProfile" id="OpenXRInteractionProfile_07fna"]
interaction_profile_path = "/interaction_profiles/ext/eye_gaze_interaction"
bindings = [SubResource("OpenXRIPBinding_73bb6")]

[resource]
action_sets = [SubResource("OpenXRActionSet_kd2ms")]
interaction_profiles = [SubResource("OpenXRInteractionProfile_kitsa"), SubResource("OpenXRInteractionProfile_uoohe"), SubResource("OpenXRInteractionProfile_k2llo"), SubResource("OpenXRInteractionProfile_2masb"), SubResource("OpenXRInteractionProfile_ert82"), SubResource("OpenXRInteractionProfile_aq5p3"), SubResource("OpenXRInteractionProfile_4petf"), SubResource("OpenXRInteractionProfile_sd46l"), SubResource("OpenXRInteractionProfile_prh4s"), SubResource("OpenXRInteractionProfile_kk5vf"), SubResource("OpenXRInteractionProfile_wxdsn")]
interaction_profiles = [SubResource("OpenXRInteractionProfile_kitsa"), SubResource("OpenXRInteractionProfile_uoohe"), SubResource("OpenXRInteractionProfile_k2llo"), SubResource("OpenXRInteractionProfile_2masb"), SubResource("OpenXRInteractionProfile_ert82"), SubResource("OpenXRInteractionProfile_aq5p3"), SubResource("OpenXRInteractionProfile_4petf"), SubResource("OpenXRInteractionProfile_sd46l"), SubResource("OpenXRInteractionProfile_prh4s"), SubResource("OpenXRInteractionProfile_kk5vf"), SubResource("OpenXRInteractionProfile_wxdsn"), SubResource("OpenXRInteractionProfile_07fna")]
1 change: 1 addition & 0 deletions demo/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ textures/vram_compression/import_etc2_astc=true
[xr]

openxr/enabled=true
openxr/extensions/eye_gaze_interaction=true
shaders/enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,19 @@ public String getPluginName() {
return "GodotOpenXRMeta";
}

@Override
public boolean supportsFeature(String featureTag) {
if ("PERMISSION_XR_EXT_eye_gaze_interaction".equals(featureTag)) {
String[] grantedPermissions = getGodot().getGrantedPermissions();
if (grantedPermissions != null) {
for (String permission : grantedPermissions) {
if ("com.oculus.permission.EYE_TRACKING".equals(permission)) {
return true;
}
}
}
}
return false;
}

}