Skip to content

Commit e142144

Browse files
committed
WIP: ARCore-based position tracking
1 parent 0b357ce commit e142144

File tree

10 files changed

+280
-7
lines changed

10 files changed

+280
-7
lines changed

code/mobile/android/PhoneVR/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/ALVR
1212
/cardboard
1313
/gvr-android-sdk-1.200
14+
/arcore-android-sdk-main
1415
/app/libraries
1516
/app/libraries_gvr
1617

code/mobile/android/PhoneVR/app/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ add_library(native-lib-alvr SHARED
1919
${LIB_SRC}
2020
)
2121

22+
# Import the ARCore (Google Play Services for AR) library.
23+
add_library(arcore SHARED IMPORTED)
24+
set_target_properties(arcore PROPERTIES IMPORTED_LOCATION
25+
${ARCORE_LIBPATH}/${ANDROID_ABI}/libarcore_sdk_c.so
26+
INTERFACE_INCLUDE_DIRECTORIES ${ARCORE_INCLUDE}
27+
)
28+
2229
set(libs_dir ${CMAKE_CURRENT_SOURCE_DIR}/libraries)
2330
set(alvr_build_dir ${CMAKE_CURRENT_SOURCE_DIR}/../ALVR/build/alvr_client_core)
2431

@@ -31,10 +38,11 @@ target_include_directories(native-lib-alvr
3138
# ALVR Headers
3239
PUBLIC ${alvr_build_dir}
3340
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../cardboard
41+
PUBLIC ${ARCORE_INCLUDE}
3442
)
3543

3644
target_link_libraries(native-lib-alvr
37-
log android EGL GLESv3 mediandk
45+
log android EGL GLESv3 mediandk arcore
3846
${alvr_build_dir}/${ANDROID_ABI}/libalvr_client_core.so
3947
${libs_dir}/jni/${ANDROID_ABI}/libGfxPluginCardboard.so
4048
)

code/mobile/android/PhoneVR/app/build.gradle

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ apply plugin: 'com.google.gms.google-services'
77
apply from: '../versioning.gradle'
88
apply plugin: "com.diffplug.spotless"
99

10+
/*
11+
The arcore aar library contains the native shared libraries. These are
12+
extracted before building to a temporary directory.
13+
*/
14+
def arcore_libpath = "${rootProject.layout.buildDirectory.get()}/arcore-native"
15+
16+
// Create a configuration to mark which aars to extract .so files from
17+
configurations { natives }
18+
1019
def keystorePropertiesFile = rootProject.file("keystore.properties")
1120
def keystoreProperties = new Properties()
1221
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
@@ -50,6 +59,8 @@ android {
5059
externalNativeBuild {
5160
cmake {
5261
cppFlags "-std=c++17 -fexceptions -frtti" //-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON"
62+
arguments "-DARCORE_LIBPATH=${arcore_libpath}/jni",
63+
"-DARCORE_INCLUDE=${project.rootDir}/arcore-android-sdk-main/libraries/include"
5364
}
5465
}
5566

@@ -175,6 +186,9 @@ dependencies {
175186
implementation 'androidx.camera:camera-lifecycle:1.3.4'
176187
implementation 'androidx.camera:camera-camera2:1.3.4'
177188

189+
implementation 'com.google.ar:core:1.46.0'
190+
natives 'com.google.ar:core:1.46.0'
191+
178192
def acraVersion = '5.7.0'
179193
implementation "ch.acra:acra-mail:$acraVersion"
180194
implementation "ch.acra:acra-dialog:$acraVersion"
@@ -200,6 +214,13 @@ task extractNdk(type: Copy) {
200214
include "jni/**/libgvr.so"
201215
}
202216
}
217+
configurations.natives.files.each { f ->
218+
copy {
219+
from zipTree(f)
220+
into arcore_libpath
221+
include "jni/**/*"
222+
}
223+
}
203224
}
204225

205226
task deleteNdk(type: Delete) {

code/mobile/android/PhoneVR/app/src/gvr/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -std=c++17 -g")
99
set(ANDROID_STL c++_static)
1010
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
1111

12-
1312
set(gvr_libs_dir ${CMAKE_CURRENT_SOURCE_DIR}/../../libraries_gvr)
1413
file(GLOB_RECURSE LIB_SRC
1514
../../../../../../common/libs/ifaddrs/*.c

code/mobile/android/PhoneVR/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@
7575
android:screenOrientation="landscape"
7676
android:theme="@style/Theme.AppCompat.NoActionBar"
7777
android:launchMode="singleTop" />
78+
79+
<meta-data android:name="com.google.ar.core" android:value="optional" />
7880
</application>
7981

8082
</manifest>

0 commit comments

Comments
 (0)