Skip to content

Commit f55d831

Browse files
author
Sameer Padala
committed
Switch code from Oculus SDK to Google SDK
1 parent a78b49c commit f55d831

31 files changed

+928
-2582
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.iml
22
.gradle
33
/local.properties
4+
/.idea/misc.xml
45
/.idea/workspace.xml
56
/.idea/libraries
67
/.idea/caches

app/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ add_library( # Sets the name of the library.
2424
src/main/cpp/udp.cpp
2525
src/main/cpp/nal.cpp
2626
src/main/cpp/vr_context.cpp
27-
src/main/cpp/render.cpp
2827
src/main/cpp/latency_collector.cpp
2928
src/main/cpp/fec.cpp
3029
src/main/cpp/asset.cpp
@@ -57,7 +56,7 @@ target_link_libraries( # Specifies the target library.
5756
# included in the NDK.
5857
${log-lib}
5958

60-
vrapi
59+
gvr
6160
GLESv3
6261
EGL
6362
android

app/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ android {
1111
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1212
externalNativeBuild {
1313
cmake {
14-
cppFlags ""
14+
cppFlags "-std=gnu++11"
1515
}
1616
}
1717
}
@@ -79,4 +79,5 @@ dependencies {
7979
androidTestImplementation 'com.android.support.test:runner:1.0.1'
8080
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
8181
ARCoreImplementation('com.google.ar:core:1.2.1')
82+
implementation 'com.google.vr:sdk-base:1.160.0'
8283
}

app/src/ARCore/java/com/polygraphene/alvr/ArThread.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void start() {
6666
super.startBase();
6767
}
6868

69-
public static void requestPermissions(MainActivity activity) {
69+
public static void requestPermissions(AlvrActivity activity) {
7070
ActivityCompat.requestPermissions(
7171
activity, new String[]{Manifest.permission.CAMERA}, RC_PERMISSIONS);
7272
}
@@ -87,7 +87,7 @@ public String getErrorMessage() {
8787
return mErrorMessage;
8888
}
8989

90-
public void initialize(MainActivity activity) {
90+
public void initialize(AlvrActivity activity) {
9191
try {
9292
Session session = createArSession(activity, mInstallRequested);
9393
if (session == null) {
@@ -161,7 +161,7 @@ public void run() {
161161
}
162162
}
163163

164-
private Session createArSession(MainActivity activity, boolean installRequested)
164+
private Session createArSession(AlvrActivity activity, boolean installRequested)
165165
throws UnavailableException {
166166
Session session = null;
167167
// if we have the camera permission, create the session
@@ -185,23 +185,23 @@ private Session createArSession(MainActivity activity, boolean installRequested)
185185
/**
186186
* Check to see we have the necessary permissions for this app.
187187
*/
188-
private static boolean hasCameraPermission(MainActivity activity) {
188+
private static boolean hasCameraPermission(AlvrActivity activity) {
189189
return ContextCompat.checkSelfPermission(activity, Manifest.permission.CAMERA)
190190
== PackageManager.PERMISSION_GRANTED;
191191
}
192192

193193
/**
194194
* Check to see if we need to show the rationale for this permission.
195195
*/
196-
private static boolean shouldShowRequestPermissionRationale(MainActivity activity) {
196+
private static boolean shouldShowRequestPermissionRationale(AlvrActivity activity) {
197197
return ActivityCompat.shouldShowRequestPermissionRationale(
198198
activity, Manifest.permission.CAMERA);
199199
}
200200

201201
/**
202202
* Launch Application Setting to grant permission.
203203
*/
204-
private void launchPermissionSettings(MainActivity activity) {
204+
private void launchPermissionSettings(AlvrActivity activity) {
205205
Intent intent = new Intent();
206206
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
207207
intent.setData(Uri.fromParts("package", activity.getPackageName(), null));
@@ -223,7 +223,7 @@ private void handleSessionException(UnavailableException sessionException) {
223223
}
224224
}
225225

226-
public static boolean onRequestPermissionsResult(MainActivity activity) {
226+
public static boolean onRequestPermissionsResult(AlvrActivity activity) {
227227
if (!hasCameraPermission(activity)) {
228228
Toast.makeText(
229229
activity, "Camera permission is needed to run this application", Toast.LENGTH_LONG)
@@ -260,7 +260,7 @@ private void makeContext(EGLContext shareContext) {
260260
}
261261
}
262262

263-
public void debugReadPixel(MainActivity activity) {
263+
public void debugReadPixel(AlvrActivity activity) {
264264
//Generate a new FBO. It will contain your texture.
265265
int fb[] = new int[1];
266266
GLES11Ext.glGenFramebuffersOES(1, IntBuffer.wrap(fb));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package com.polygraphene.alvr;
22

33
public class Constants {
4-
public static final boolean IS_ARCORE_BUILD = true;
4+
public static final boolean IS_ARCORE_BUILD = false;
55
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
<resources>
2-
<string name="app_name">ALVR (ARCore)</string>
2+
<string name="ovr_name">ALVR (OVR + ARCore)</string>
3+
<string name="dd_name">ALVR (Daydream)</string>
34
</resources>

app/src/main/AndroidManifest.xml

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,53 @@
33
package="com.polygraphene.alvr"
44
android:installLocation="auto">
55

6+
<uses-sdk android:minSdkVersion="24" android:targetSdkVersion="24" />
67
<uses-feature
7-
android:glEsVersion="0x00030001"
8+
android:glEsVersion="0x00030002"
89
android:required="true" />
910
<uses-permission android:name="android.permission.INTERNET" />
11+
12+
<!-- Functionality required for Daydream. All OculusVR devices should have these features. -->
13+
<uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true"/>
14+
<uses-feature android:name="android.hardware.sensor.gyroscope" android:required="true"/>
15+
<!-- Most OculusVR devices won't have these features. -->
16+
<uses-feature android:name="android.software.vr.mode" android:required="true"/>
17+
<uses-feature android:name="android.hardware.vr.high_performance" android:required="true"/>
18+
19+
20+
<uses-feature
21+
android:name="android.hardware.vr.headtracking"
22+
android:version="1"
23+
android:required="false"/>
1024
<application
1125
android:allowBackup="true"
1226
android:icon="@mipmap/ic_launcher"
13-
android:label="@string/app_name"
27+
android:label="@string/ovr_name"
1428
android:roundIcon="@mipmap/ic_launcher_round"
1529
android:supportsRtl="true"
1630
android:theme="@style/AppTheme">
1731

18-
<meta-data
19-
android:name="com.samsung.android.vr.application.mode"
20-
android:value="vr_only" />
21-
22-
<activity
23-
android:name="com.polygraphene.alvr.MainActivity"
24-
android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode|density"
25-
android:excludeFromRecents="true"
26-
android:icon="@mipmap/ic_launcher"
27-
android:launchMode="singleTask"
28-
android:roundIcon="@mipmap/ic_launcher_round"
29-
android:screenOrientation="landscape"
30-
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
32+
33+
<!--
34+
<meta-data android:name="com.samsung.android.vr.application.mode" android:value="vr_only" />
35+
-->
36+
37+
<activity android:name=".DaydreamLayersActivity"
38+
android:label="@string/dd_name"
39+
android:screenOrientation="landscape"
40+
android:configChanges="orientation|keyboardHidden|screenSize|uiMode|navigation|density"
41+
android:enableVrMode="@string/gvr_vr_mode_component"
42+
android:resizeableActivity="false">
43+
<!-- Metadata used to tell DD about this Activity. -->
44+
<meta-data android:name="com.google.android.vr.icon"
45+
android:resource="@drawable/daydream_icon" />
46+
<meta-data android:name="com.google.android.vr.icon_background"
47+
android:resource="@drawable/daydream_background" />
48+
3149
<intent-filter>
3250
<action android:name="android.intent.action.MAIN" />
33-
34-
<category android:name="${filter}" />
51+
<category android:name="android.intent.category.LAUNCHER" />
52+
<category android:name="com.google.intent.category.DAYDREAM" />
3553
</intent-filter>
3654
</activity>
3755
</application>

app/src/main/cpp/gltf_model.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
#include "tinygltf/tiny_gltf.h"
1010
#include "utils.h"
11-
#include "render.h"
1211

1312
void GltfModel::load() {
1413
tinygltf::TinyGLTF loader;
@@ -55,10 +54,8 @@ void GltfModel::drawScene(int position, int uv,
5554

5655
GL(glBindVertexArray(m_vao));
5756

58-
ovrMatrix4f transform = ovrMatrix4f_CreateIdentity();
5957

6058
for (auto node_i : scene.nodes) {
61-
drawNodeTree(node_i, transform);
6259
}
6360

6461
GL(glBindVertexArray(0));
@@ -67,13 +64,6 @@ void GltfModel::drawScene(int position, int uv,
6764
void GltfModel::drawNodeTree(int node_i, const ovrMatrix4f &transform) {
6865
auto &node = m_model.nodes[node_i];
6966

70-
ovrMatrix4f nodeTransform = createNodeTrasform(transform, node);
71-
72-
drawNode(node_i, nodeTransform);
73-
74-
for (auto &child_i : node.children) {
75-
drawNodeTree(child_i, nodeTransform);
76-
}
7767
}
7868

7969
void GltfModel::drawNode(int node_i, const ovrMatrix4f &transform) {
@@ -177,26 +167,3 @@ void GltfModel::drawNode(int node_i, const ovrMatrix4f &transform) {
177167
GL(glDisableVertexAttribArray(m_position));
178168
}
179169
}
180-
181-
ovrMatrix4f
182-
GltfModel::createNodeTrasform(const ovrMatrix4f &baseTransform, const tinygltf::Node &node) {
183-
ovrMatrix4f nodeTransform = baseTransform;
184-
if(node.translation.size() == 3) {
185-
ovrMatrix4f translation = ovrMatrix4f_CreateTranslation(node.translation[0], node.translation[1], node.translation[2]);
186-
nodeTransform = ovrMatrix4f_Multiply(&nodeTransform, &translation);
187-
}
188-
if(node.rotation.size() == 4) {
189-
ovrQuatf q;
190-
q.x = node.rotation[0];
191-
q.y = node.rotation[1];
192-
q.z = node.rotation[2];
193-
q.w = node.rotation[3];
194-
ovrMatrix4f rotation = ovrMatrix4f_CreateFromQuaternion(&q);
195-
nodeTransform = ovrMatrix4f_Multiply(&nodeTransform, &rotation);
196-
}
197-
if(node.scale.size() == 3) {
198-
ovrMatrix4f scale = ovrMatrix4f_CreateScale(node.scale[0], node.scale[1], node.scale[2]);
199-
nodeTransform = ovrMatrix4f_Multiply(&nodeTransform, &scale);
200-
}
201-
return nodeTransform;
202-
}

app/src/main/cpp/gltf_model.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <vector>
55
#include <string>
66
#include <GLES3/gl3.h>
7-
#include <VrApi_Types.h>
7+
#include "utils.h"
88

99
#define TINYGLTF_NO_STB_IMAGE_WRITE
1010
#include "tinygltf/tiny_gltf.h"
@@ -23,7 +23,6 @@ class GltfModel {
2323

2424
void drawNodeTree(int node_i, const ovrMatrix4f &transform);
2525
void drawNode(int node_i, const ovrMatrix4f &transform);
26-
ovrMatrix4f createNodeTrasform(const ovrMatrix4f &baseTransform, const tinygltf::Node &node);
2726
public:
2827
void load();
2928
void drawScene(int position, int uv, int normal, GLint color, GLint mMatrix, GLint mode);

0 commit comments

Comments
 (0)