Skip to content

Commit

Permalink
Add support for the Meta scene capture API
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Oct 21, 2023
1 parent beb0949 commit 26a5a29
Show file tree
Hide file tree
Showing 69 changed files with 17,113 additions and 46 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/build-addon-on-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,28 @@ jobs:
uses: actions/checkout@v3
with:
path: aar
submodules: recursive
- name: Set up Python (for SCons)
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install scons
run: |
python -m pip install scons==4.0.0
- name: Setup java
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: 'adopt'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Create Godot OpenXR loader AARs
run: |
cd aar
cd thirdparty/godot-cpp
scons platform=android target=template_debug -j4
scons platform=android target=template_release -j4
cd ../..
./gradlew build
cd ..
# GODOT 4.2 ADDON GENERATION SECTION
Expand Down
20 changes: 17 additions & 3 deletions .github/workflows/mavencentral-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,31 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up JDK 11
with:
submodules: recursive
- name: Set up Python (for SCons)
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install scons
run: |
python -m pip install scons==4.0.0
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: adopt
java-version: 11
java-version: 17
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1

# Builds the release artifacts of the library
- name: Release build
run: ./gradlew -Prelease_version=${{ github.ref_name }} build
run: |
cd thirdparty/godot-cpp
scons platform=android target=template_debug -j4
scons platform=android target=template_release -j4
cd ../..
./gradlew -Prelease_version=${{ github.ref_name }} build
# Runs upload, and then closes & releases the repository
- name: Publish to MavenCentral
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "thirdparty/godot-cpp"]
path = thirdparty/godot-cpp
url = https://github.com/godotengine/godot-cpp
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
- Add the ability to customize supported Meta devices
- Add support for Quest 3 devices
- Update the directory structure for the v2 plugin
- Add godot-cpp dependency
- Update Meta OpenXR mobile SDK to version 57
- Add OpenXR 1.0.30 headers
- Add support for the Meta scene capture API

## 1.1.0
- Update Meta OpenXR loader to version 54
Expand Down
39 changes: 35 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,47 @@ for support on prior versions of Godot 4.

## Building this asset

### Linux
You can build this asset after cloning by simply running:
After cloning this project, run the following command in the project root directory to initialize
the `godot-cpp` submodule:
```
git submodule update --init
```

### Building the Godot-CPP bindings
Build the Android C++ bindings using the following commands. To speed up compilation, add `-jN` at
the end of the SCons command line where `N` is the number of CPU threads you have on your system.
The example below uses 4 threads.
```
cd thirdparty/godot-cpp
scons target=template_debug -j4
scons target=template_release -j4
scons platform=android target=template_debug -j4
scons platform=android target=template_release -j4
```

When the command is completed, you should have static libraries stored in `thirdparty/godot-cpp/bin`
that will be used for compilation by the plugin.

### Building the Plugin

#### Linux / MacOS
Run the following command to build the plugin:
```
./gradlew build
cd godotopenxrmeta
scons target=template_debug -j4
scons target=template_release -j4
```

### Windows
You can build this asset after cloning by simply running:
#### Windows
Run the following command to build the plugin:
```
gradlew.bat build
cd godotopenxrmeta
scons target=template_debug -j4
scons target=template_release -j4
```

## Downloading this asset
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {
dependencies {
classpath "com.android.tools.build:gradle:$versions.gradlePluginVersion"
classpath "io.github.gradle-nexus:publish-plugin:$versions.nexusPublishVersion"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion"
}
}

Expand Down
6 changes: 4 additions & 2 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ ext {
compileSdk : 33,
minSdk : 21,
targetSdk : 33,
javaVersion : JavaVersion.VERSION_11,
nexusPublishVersion : '1.3.0'
javaVersion : JavaVersion.VERSION_17,
nexusPublishVersion : '1.3.0',
kotlinVersion : '1.7.22',
coreKtxVersion: '1.12.0',
]

libraries = [
Expand Down
1 change: 0 additions & 1 deletion demo/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Godot 4+ specific ignores
.godot/
/addons/godotopenxr/.bin/**/*.aar
/android/
2 changes: 2 additions & 0 deletions demo/addons/godotopenxr/.bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ const PASSTHROUGH_OPTION = {
"update_visibility": false,
}

const USE_ANCHOR_API_OPTION = {
"option": {
"name": "meta_xr_features/use_anchor_api",
"class_name": "",
"type": TYPE_BOOL,
"hint": PROPERTY_HINT_NONE,
"hint_string": "",
"usage": PROPERTY_USAGE_DEFAULT,
},
"default_value": false,
"update_visibility": false,
}

const SUPPORT_QUEST_1_OPTION = {
"option": {
"name": "meta_xr_features/quest_1_support",
Expand Down Expand Up @@ -130,6 +143,7 @@ func _get_export_options(platform) -> Array[Dictionary]:
HAND_TRACKING_OPTION,
HAND_TRACKING_FREQUENCY_OPTION,
PASSTHROUGH_OPTION,
USE_ANCHOR_API_OPTION,
SUPPORT_QUEST_1_OPTION,
SUPPORT_QUEST_2_OPTION,
SUPPORT_QUEST_3_OPTION,
Expand Down Expand Up @@ -195,6 +209,10 @@ func _get_export_option_warning(platform, option) -> String:
if not(openxr_enabled) and _get_int_option(option, PASSTHROUGH_NONE_VALUE) > PASSTHROUGH_NONE_VALUE:
warning = "\"Passthrough\" requires \"XR Mode\" to be \"OpenXR\".\n"

"meta_xr_features/use_anchor_api":
if not(openxr_enabled) and _get_bool_option(option):
warning = "\"Use anchor API\" is only valid when \"XR Mode\" is \"OpenXR\"."

_:
warning = super._get_export_option_warning(platform, option)

Expand Down Expand Up @@ -234,6 +252,11 @@ func _get_android_manifest_element_contents(platform, debug) -> String:
elif passthrough_mode == PASSTHROUGH_REQUIRED_VALUE:
contents += " <uses-feature tools:node=\"replace\" android:name=\"com.oculus.feature.PASSTHROUGH\" android:required=\"true\" />\n"

# Check for anchor api
var use_anchor_api = _get_bool_option("meta_xr_features/use_anchor_api")
if use_anchor_api:
contents += " <uses-permission android:name=\"com.oculus.permission.USE_ANCHOR_API\" />\n"

return contents


Expand Down
20 changes: 20 additions & 0 deletions demo/addons/godotopenxr/export/meta/plugin.gdextension
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[configuration]

entry_symbol = "plugin_library_init"
compatibility_minimum = "4.2"
android_aar_plugin = true

[libraries]

android.debug.arm64 = "res://addons/godotopenxr/.bin/meta/debug/arm64-v8a/libgodotopenxrmeta.so"
android.release.arm64 = "res://addons/godotopenxr/.bin/meta/release/arm64-v8a/libgodotopenxrmeta.so"
macos.debug = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.macos.template_debug.framework"
macos.release = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.macos.template_release.framework"
windows.debug.x86_64 = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.windows.template_debug.x86_64.dll"
windows.release.x86_64 = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.windows.template_release.x86_64.dll"
linux.debug.x86_64 = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.linux.template_debug.x86_64.so"
linux.release.x86_64 = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.linux.template_release.x86_64.so"
linux.debug.arm64 = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.linux.template_debug.arm64.so"
linux.release.arm64 = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.linux.template_release.arm64.so"
linux.debug.rv64 = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.linux.template_debug.rv64.so"
linux.release.rv64 = "res://addons/godotopenxr/.bin/meta/libgodotopenxrmeta.linux.template_release.rv64.so"
1 change: 1 addition & 0 deletions demo/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,4 @@ meta_xr_features/quest_1_support=false
meta_xr_features/quest_2_support=true
meta_xr_features/quest_3_support=true
meta_xr_features/quest_pro_support=true
meta_xr_features/use_anchor_api=true
9 changes: 9 additions & 0 deletions demo/main.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ func _ready():
if xr_interface and xr_interface.is_initialized():
var vp: Viewport = get_viewport()
vp.use_xr = true

var scene_capture: OpenXRFbSceneCaptureExtensionWrapper = OpenXRFbSceneCaptureExtensionWrapper.get_singleton()
scene_capture.connect("scene_capture_completed", _on_scene_capture_completed)
scene_capture.request_scene_capture()



# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass


func _on_scene_capture_completed():
print("Scene Capture completed")
2 changes: 2 additions & 0 deletions godotopenxrkhr/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}


Expand Down Expand Up @@ -49,6 +50,7 @@ android {
}

dependencies {
implementation "androidx.core:core-ktx:$versions.coreKtxVersion"
compileOnly libraries.godotAndroidLib
}

Expand Down
2 changes: 2 additions & 0 deletions godotopenxrlynx/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
}

ext {
Expand Down Expand Up @@ -49,6 +50,7 @@ android {
}

dependencies {
implementation "androidx.core:core-ktx:$versions.coreKtxVersion"
compileOnly libraries.godotAndroidLib
}

Expand Down
Loading

0 comments on commit 26a5a29

Please sign in to comment.