forked from GodotVR/godot_openxr_vendors
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the Android XR OpenXR vendor (including hybrid app su…
…pport)
- Loading branch information
Showing
8 changed files
with
482 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<!-- Permissions needed by OpenXR --> | ||
<uses-permission android:name="org.khronos.openxr.permission.OPENXR" /> | ||
<uses-permission android:name="org.khronos.openxr.permission.OPENXR_SYSTEM" /> | ||
|
||
<queries> | ||
<intent> | ||
<action android:name="org.khronos.openxr.OpenXRRuntimeService"/> | ||
</intent> | ||
<provider android:authorities="org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker" /> | ||
</queries> | ||
|
||
<application> | ||
<meta-data | ||
android:name="org.godotengine.plugin.v2.GodotOpenXRAndroid" | ||
android:value="org.godotengine.openxr.vendors.android.GodotOpenXRAndroid" /> | ||
|
||
<meta-data android:name="org.godotengine.plugin.v2.GodotOpenXRHybridAppInternal" | ||
android:value="org.godotengine.openxr.vendors.GodotOpenXRHybridAppInternal" /> | ||
</application> | ||
|
||
</manifest> |
108 changes: 108 additions & 0 deletions
108
plugin/src/android/java/org/godotengine/openxr/vendors/android/GodotOpenXRAndroid.kt
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,108 @@ | ||
/**************************************************************************/ | ||
/* GodotOpenXRAndroid.kt */ | ||
/**************************************************************************/ | ||
/* This file is part of: */ | ||
/* GODOT XR */ | ||
/* https://godotengine.org */ | ||
/**************************************************************************/ | ||
/* Copyright (c) 2022-present Godot XR contributors (see CONTRIBUTORS.md) */ | ||
/* */ | ||
/* Permission is hereby granted, free of charge, to any person obtaining */ | ||
/* a copy of this software and associated documentation files (the */ | ||
/* "Software"), to deal in the Software without restriction, including */ | ||
/* without limitation the rights to use, copy, modify, merge, publish, */ | ||
/* distribute, sublicense, and/or sell copies of the Software, and to */ | ||
/* permit persons to whom the Software is furnished to do so, subject to */ | ||
/* the following conditions: */ | ||
/* */ | ||
/* The above copyright notice and this permission notice shall be */ | ||
/* included in all copies or substantial portions of the Software. */ | ||
/* */ | ||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ | ||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ | ||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */ | ||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ | ||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ | ||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ | ||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ | ||
/**************************************************************************/ | ||
|
||
package org.godotengine.openxr.vendors.android | ||
|
||
import org.godotengine.godot.Godot | ||
import org.godotengine.godot.utils.PermissionsUtil | ||
import org.godotengine.openxr.vendors.GodotOpenXR | ||
|
||
/** | ||
* Godot OpenXR plugin for the Android XR platform. | ||
*/ | ||
class GodotOpenXRAndroid(godot: Godot?) : GodotOpenXR(godot) { | ||
companion object { | ||
/** | ||
* Representing the user's eye pose and orientation, for the purposes of avatars | ||
*/ | ||
private const val EYE_TRACKING_PERMISSION = "android.permission.EYE_TRACKING" | ||
|
||
/** | ||
* Eye gaze input and interactions | ||
*/ | ||
private const val EYE_TRACKING_FINE_PERMISSION = "android.permission.EYE_TRACKING_FINE" | ||
|
||
/** | ||
* Tracking and rendering facial expressions | ||
*/ | ||
private const val FACE_TRACKING_PERMISSION = "android.permission.FACE_TRACKING" | ||
|
||
/** | ||
* Tracking hand joint poses and angular and linear velocities; Using a mesh representation of the user's hands | ||
*/ | ||
private const val HAND_TRACKING_PERMISSION = "android.permission.HAND_TRACKING" | ||
|
||
/** | ||
* - Light estimation | ||
* - projecting passthrough onto mesh surfaces | ||
* - performing raycasts against trackables in the environment | ||
* - plane tracking | ||
* - object tracking | ||
* - working with depth for occlusion and hit testing | ||
* - persistent anchors | ||
*/ | ||
private const val SCENE_UNDERSTANDING_PERMISSION = "android.permission.SCENE_UNDERSTANDING" | ||
|
||
private val ANDROID_XR_PERMISSIONS_LIST = listOf( | ||
EYE_TRACKING_PERMISSION, | ||
EYE_TRACKING_FINE_PERMISSION, | ||
FACE_TRACKING_PERMISSION, | ||
HAND_TRACKING_PERMISSION, | ||
SCENE_UNDERSTANDING_PERMISSION, | ||
) | ||
} | ||
override fun getPluginName() = "GodotOpenXRAndroid" | ||
|
||
override fun getPluginPermissionsToEnable(): MutableList<String> { | ||
val permissionsToEnable = super.getPluginPermissionsToEnable() | ||
|
||
// Go through the list of permissions, and request the ones that are included in the | ||
// manifest. | ||
for (permission in ANDROID_XR_PERMISSIONS_LIST) { | ||
if (PermissionsUtil.hasManifestPermission(activity, permission)) { | ||
permissionsToEnable.add(permission) | ||
} | ||
} | ||
return permissionsToEnable | ||
} | ||
|
||
override fun supportsFeature(featureTag: String): Boolean { | ||
if ("PERMISSION_XR_EXT_eye_gaze_interaction" == featureTag) { | ||
val grantedPermissions = godot?.getGrantedPermissions() | ||
if (grantedPermissions != null) { | ||
for (permission in grantedPermissions) { | ||
if (EYE_TRACKING_FINE_PERMISSION == permission) { | ||
return true | ||
} | ||
} | ||
} | ||
} | ||
return false | ||
} | ||
} |
Oops, something went wrong.