-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c52e54
commit 2b1886f
Showing
30 changed files
with
784 additions
and
459 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.import/ | ||
.godot/ | ||
build/ | ||
android/build/ | ||
android/.build_version | ||
android/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...oid/plugins/GodotOpenXRLoaders_CHANGES.md → ...godotopenxr/GodotOpenXRLoaders_CHANGES.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
120 changes: 120 additions & 0 deletions
120
addons/godotopenxr/export/godot_openxr_editor_export_plugin.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
@tool | ||
class_name GodotOpenXREditorExportPlugin extends EditorExportPlugin | ||
|
||
const OPENXR_MODE_VALUE = 1 | ||
|
||
var _vendor: String | ||
var _plugin_version: String | ||
|
||
func _init(vendor: String, version: String): | ||
_vendor = vendor | ||
_plugin_version = version | ||
|
||
|
||
func _get_name() -> String: | ||
return "GodotOpenXR" + _vendor.capitalize() | ||
|
||
|
||
# Path to the Android library aar file | ||
# If this is not available, we fall back to the maven central dependency | ||
func _get_android_aar_file_path(debug: bool) -> String: | ||
return "res://addons/godotopenxr/export/" + _vendor + "/godotopenxr" + _vendor + "-" + ("debug.aar" if debug else "release.aar") | ||
|
||
|
||
# Maven central dependency used as fall back when the Android library aar file is not available | ||
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() -> Dictionary: | ||
var toggle_option = { | ||
"option": { | ||
"name": _get_vendor_toggle_option_name(), | ||
"class_name": "", | ||
"type": TYPE_BOOL, | ||
"hint": PROPERTY_HINT_NONE, | ||
"hint_string": "", | ||
"usage": PROPERTY_USAGE_DEFAULT, | ||
}, | ||
"default_value": false, | ||
"update_visibility": false, | ||
} | ||
return toggle_option | ||
|
||
|
||
func _is_openxr_enabled() -> bool: | ||
return _get_int_option("xr_features/xr_mode", 0) == OPENXR_MODE_VALUE | ||
|
||
|
||
func _get_export_options(platform) -> Array[Dictionary]: | ||
if not _supports_platform(platform): | ||
return [] | ||
|
||
return [ | ||
_get_vendor_toggle_option(), | ||
] | ||
|
||
|
||
func _get_export_option_warning(platform, option) -> String: | ||
if not _supports_platform(platform): | ||
return "" | ||
|
||
if option != _get_vendor_toggle_option_name(): | ||
return "" | ||
|
||
if not(_is_openxr_enabled()) and _get_bool_option(option): | ||
return "\"Enable " + _vendor.capitalize() + " Plugin\" requires \"XR Mode\" to be \"OpenXR\".\n" | ||
|
||
return "" | ||
|
||
|
||
func _supports_platform(platform) -> bool: | ||
if platform is EditorExportPlatformAndroid: | ||
return true | ||
return false | ||
|
||
|
||
func _get_bool_option(option: String) -> bool: | ||
var option_enabled = get_option(option) | ||
if option_enabled is bool: | ||
return option_enabled | ||
return false | ||
|
||
|
||
func _get_int_option(option: String, default_value: int) -> int: | ||
var option_value = get_option(option) | ||
if option_value is int: | ||
return option_value | ||
return default_value | ||
|
||
|
||
func _is_vendor_plugin_enabled() -> bool: | ||
return _get_bool_option(_get_vendor_toggle_option_name()) | ||
|
||
|
||
func _is_android_aar_file_available(debug: bool) -> bool: | ||
return FileAccess.file_exists(_get_android_aar_file_path(debug)) | ||
|
||
|
||
func _get_android_dependencies(platform, debug) -> PackedStringArray: | ||
if not _supports_platform(platform): | ||
return PackedStringArray() | ||
|
||
if _is_vendor_plugin_enabled() and not _is_android_aar_file_available(debug): | ||
return PackedStringArray([_get_android_maven_central_dependency()]) | ||
|
||
return PackedStringArray() | ||
|
||
|
||
func _get_android_libraries(platform, debug) -> PackedStringArray: | ||
if not _supports_platform(platform): | ||
return PackedStringArray() | ||
|
||
if _is_vendor_plugin_enabled() and _is_android_aar_file_available(debug): | ||
return PackedStringArray([_get_android_aar_file_path(debug)]) | ||
|
||
return PackedStringArray() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@tool | ||
extends EditorPlugin | ||
|
||
# A class member to hold the export plugin during its lifecycle. | ||
var meta_export_plugin : EditorExportPlugin | ||
var pico_export_plugin : EditorExportPlugin | ||
var lynx_export_plugin : EditorExportPlugin | ||
var khr_export_plugin : EditorExportPlugin | ||
|
||
|
||
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) | ||
|
||
add_export_plugin(meta_export_plugin) | ||
add_export_plugin(pico_export_plugin) | ||
add_export_plugin(lynx_export_plugin) | ||
add_export_plugin(khr_export_plugin) | ||
|
||
|
||
func _exit_tree(): | ||
# Cleaning up the export plugins | ||
remove_export_plugin(meta_export_plugin) | ||
remove_export_plugin(pico_export_plugin) | ||
remove_export_plugin(lynx_export_plugin) | ||
remove_export_plugin(khr_export_plugin) | ||
|
||
meta_export_plugin = null | ||
pico_export_plugin = null | ||
lynx_export_plugin = null | ||
khr_export_plugin = null |
File renamed without changes.
23 changes: 23 additions & 0 deletions
23
addons/godotopenxr/export/khr/godot_openxr_khr_editor_export_plugin.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
@tool | ||
extends "../godot_openxr_editor_export_plugin.gd" | ||
|
||
|
||
func _get_android_manifest_activity_element_contents(platform, debug) -> String: | ||
if not _supports_platform(platform) or not(_is_vendor_plugin_enabled()): | ||
return "" | ||
|
||
var contents = """ | ||
<intent-filter>\n | ||
<action android:name=\"android.intent.action.MAIN\" />\n | ||
<category android:name=\"android.intent.category.LAUNCHER\" />\n | ||
\n | ||
<!-- OpenXR category tag to indicate the activity starts in an immersive OpenXR mode. \n | ||
See https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#android-runtime-category. -->\n | ||
<category android:name=\"org.khronos.openxr.intent.category.IMMERSIVE_HMD\" />\n | ||
\n | ||
<!-- Enable VR access on HTC Vive Focus devices. -->\n | ||
<category android:name=\"com.htc.intent.category.VRAPP\" />\n | ||
</intent-filter>\n | ||
""" | ||
|
||
return contents |
Binary file not shown.
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
addons/godotopenxr/export/lynx/godot_openxr_lynx_editor_export_plugin.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@tool | ||
extends "../godot_openxr_editor_export_plugin.gd" | ||
|
||
|
||
func _get_android_manifest_activity_element_contents(platform, debug) -> String: | ||
if not _supports_platform(platform) or not(_is_vendor_plugin_enabled()): | ||
return "" | ||
|
||
var contents = """ | ||
<intent-filter>\n | ||
<action android:name=\"android.intent.action.MAIN\" />\n | ||
<category android:name=\"android.intent.category.LAUNCHER\" />\n | ||
\n | ||
<!-- OpenXR category tag to indicate the activity starts in an immersive OpenXR mode. \n | ||
See https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#android-runtime-category. -->\n | ||
<category android:name=\"org.khronos.openxr.intent.category.IMMERSIVE_HMD\" />\n | ||
</intent-filter>\n | ||
""" | ||
|
||
return contents |
Binary file not shown.
File renamed without changes.
File renamed without changes.
147 changes: 147 additions & 0 deletions
147
addons/godotopenxr/export/meta/godot_openxr_meta_editor_export_plugin.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
@tool | ||
extends "../godot_openxr_editor_export_plugin.gd" | ||
|
||
const PASSTHROUGH_NONE_VALUE = 0 | ||
const PASSTHROUGH_OPTIONAL_VALUE = 1 | ||
const PASSTHROUGH_REQUIRED_VALUE = 2 | ||
|
||
const HAND_TRACKING_NONE_VALUE = 0 | ||
const HAND_TRACKING_OPTIONAL_VALUE = 1 | ||
const HAND_TRACKING_REQUIRED_VALUE = 2 | ||
|
||
const HAND_TRACKING_FREQUENCY_LOW_VALUE = 0 | ||
const HAND_TRACKING_FREQUENCY_HIGH_VALUE = 1 | ||
|
||
const HAND_TRACKING_OPTION = { | ||
"option": { | ||
"name": "meta_xr_features/hand_tracking", | ||
"class_name": "", | ||
"type": TYPE_INT, | ||
"hint": PROPERTY_HINT_ENUM, | ||
"hint_string": "None,Optional,Required", | ||
"usage": PROPERTY_USAGE_DEFAULT, | ||
}, | ||
"default_value": HAND_TRACKING_NONE_VALUE, | ||
"update_visibility": false, | ||
} | ||
|
||
const HAND_TRACKING_FREQUENCY_OPTION = { | ||
"option": { | ||
"name": "meta_xr_features/hand_tracking_frequency", | ||
"class_name": "", | ||
"type": TYPE_INT, | ||
"hint": PROPERTY_HINT_ENUM, | ||
"hint_string": "Low,High", | ||
"usage": PROPERTY_USAGE_DEFAULT, | ||
}, | ||
"default_value": HAND_TRACKING_FREQUENCY_LOW_VALUE, | ||
"update_visibility": false, | ||
} | ||
|
||
const PASSTHROUGH_OPTION = { | ||
"option": { | ||
"name": "meta_xr_features/passthrough", | ||
"class_name": "", | ||
"type": TYPE_INT, | ||
"hint": PROPERTY_HINT_ENUM, | ||
"hint_string": "None,Optional,Required", | ||
"usage": PROPERTY_USAGE_DEFAULT, | ||
}, | ||
"default_value": PASSTHROUGH_NONE_VALUE, | ||
"update_visibility": false, | ||
} | ||
|
||
|
||
func _get_export_options(platform) -> Array[Dictionary]: | ||
if not _supports_platform(platform): | ||
return [] | ||
|
||
return [ | ||
_get_vendor_toggle_option(), | ||
HAND_TRACKING_OPTION, | ||
HAND_TRACKING_FREQUENCY_OPTION, | ||
PASSTHROUGH_OPTION, | ||
] | ||
|
||
|
||
func _get_export_option_warning(platform, option) -> String: | ||
if not _supports_platform(platform): | ||
return "" | ||
|
||
var warning = "" | ||
var openxr_enabled = _is_openxr_enabled() | ||
match (option): | ||
"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" | ||
|
||
"meta_xr_features/passthrough": | ||
if not(openxr_enabled) and _get_int_option(option, PASSTHROUGH_NONE_VALUE) > PASSTHROUGH_NONE_VALUE: | ||
warning = "\"Passthrough\" requires \"XR Mode\" to be \"OpenXR\".\n" | ||
|
||
_: | ||
warning = super._get_export_option_warning(platform, option) | ||
|
||
return warning | ||
|
||
|
||
func _get_android_manifest_element_contents(platform, debug) -> String: | ||
if not _supports_platform(platform) or not(_is_vendor_plugin_enabled()): | ||
return "" | ||
|
||
var contents = "" | ||
|
||
# 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: | ||
contents += " <uses-permission android:name=\"com.oculus.permission.HAND_TRACKING\" />\n" | ||
if hand_tracking_value == HAND_TRACKING_OPTIONAL_VALUE: | ||
contents += " <uses-feature tools:node=\"replace\" android:name=\"oculus.software.handtracking\" android:required=\"false\" />\n" | ||
elif hand_tracking_value == HAND_TRACKING_REQUIRED_VALUE: | ||
contents += " <uses-feature tools:node=\"replace\" android:name=\"oculus.software.handtracking\" android:required=\"true\" />\n" | ||
|
||
# Check for passthrough | ||
var passthrough_mode = _get_int_option("meta_xr_features/passthrough", PASSTHROUGH_NONE_VALUE) | ||
if passthrough_mode == PASSTHROUGH_OPTIONAL_VALUE: | ||
contents += " <uses-feature tools:node=\"replace\" android:name=\"com.oculus.feature.PASSTHROUGH\" android:required=\"false\" />\n" | ||
elif passthrough_mode == PASSTHROUGH_REQUIRED_VALUE: | ||
contents += " <uses-feature tools:node=\"replace\" android:name=\"com.oculus.feature.PASSTHROUGH\" android:required=\"true\" />\n" | ||
|
||
return contents | ||
|
||
|
||
func _get_android_manifest_application_element_contents(platform, debug) -> String: | ||
if not _supports_platform(platform) or not(_is_vendor_plugin_enabled()): | ||
return "" | ||
|
||
var contents = "" | ||
|
||
var hand_tracking_enabled = _get_int_option("meta_xr_features/hand_tracking", HAND_TRACKING_NONE_VALUE) > HAND_TRACKING_NONE_VALUE | ||
if hand_tracking_enabled: | ||
var hand_tracking_frequency = _get_int_option("meta_xr_features/hand_tracking_frequency", HAND_TRACKING_FREQUENCY_LOW_VALUE) | ||
var hand_tracking_frequency_label = "LOW" if hand_tracking_frequency == HAND_TRACKING_FREQUENCY_LOW_VALUE else "HIGH" | ||
contents += " <meta-data tools:node=\"replace\" android:name=\"com.oculus.handtracking.frequency\" android:value=\"%s\" />\n" % hand_tracking_frequency_label | ||
contents += " <meta-data tools:node=\"replace\" android:name=\"com.oculus.handtracking.version\" android:value=\"V2.0\" />\n" | ||
|
||
return contents | ||
|
||
func _get_android_manifest_activity_element_contents(platform, debug) -> String: | ||
if not _supports_platform(platform) or not(_is_vendor_plugin_enabled()): | ||
return "" | ||
|
||
var contents = """ | ||
<intent-filter>\n | ||
<action android:name=\"android.intent.action.MAIN\" />\n | ||
<category android:name=\"android.intent.category.LAUNCHER\" />\n | ||
\n | ||
<!-- Enable access to OpenXR on Oculus mobile devices, no-op on other Android\n | ||
platforms. -->\n | ||
<category android:name=\"com.oculus.intent.category.VR\" />\n | ||
\n | ||
<!-- OpenXR category tag to indicate the activity starts in an immersive OpenXR mode. \n | ||
See https://registry.khronos.org/OpenXR/specs/1.0/html/xrspec.html#android-runtime-category. -->\n | ||
<category android:name=\"org.khronos.openxr.intent.category.IMMERSIVE_HMD\" />\n | ||
</intent-filter>\n | ||
""" | ||
|
||
return contents |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.