Skip to content

Commit c958737

Browse files
committed
cardboard working with GVR SDK 1.10.0
1 parent 7f89148 commit c958737

28 files changed

+608
-436
lines changed

libraries/cardboard/.settings/org.eclipse.jdt.core.prefs

Lines changed: 377 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
eclipse.preferences.version=1
2+
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
3+
formatter_profile=_processing
4+
formatter_settings_version=12
5+
sp_cleanup.add_default_serial_version_id=true
6+
sp_cleanup.add_generated_serial_version_id=false
7+
sp_cleanup.add_missing_annotations=true
8+
sp_cleanup.add_missing_deprecated_annotations=false
9+
sp_cleanup.add_missing_methods=false
10+
sp_cleanup.add_missing_nls_tags=false
11+
sp_cleanup.add_missing_override_annotations=true
12+
sp_cleanup.add_missing_override_annotations_interface_methods=false
13+
sp_cleanup.add_serial_version_id=false
14+
sp_cleanup.always_use_blocks=true
15+
sp_cleanup.always_use_parentheses_in_expressions=false
16+
sp_cleanup.always_use_this_for_non_static_field_access=false
17+
sp_cleanup.always_use_this_for_non_static_method_access=false
18+
sp_cleanup.convert_to_enhanced_for_loop=false
19+
sp_cleanup.correct_indentation=false
20+
sp_cleanup.format_source_code=false
21+
sp_cleanup.format_source_code_changes_only=false
22+
sp_cleanup.make_local_variable_final=false
23+
sp_cleanup.make_parameters_final=false
24+
sp_cleanup.make_private_fields_final=true
25+
sp_cleanup.make_type_abstract_if_missing_method=false
26+
sp_cleanup.make_variable_declarations_final=false
27+
sp_cleanup.never_use_blocks=false
28+
sp_cleanup.never_use_parentheses_in_expressions=true
29+
sp_cleanup.on_save_use_additional_actions=true
30+
sp_cleanup.organize_imports=false
31+
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
32+
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
33+
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
34+
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
35+
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
36+
sp_cleanup.remove_private_constructors=true
37+
sp_cleanup.remove_trailing_whitespaces=true
38+
sp_cleanup.remove_trailing_whitespaces_all=true
39+
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
40+
sp_cleanup.remove_unnecessary_casts=false
41+
sp_cleanup.remove_unnecessary_nls_tags=false
42+
sp_cleanup.remove_unused_imports=false
43+
sp_cleanup.remove_unused_local_variables=false
44+
sp_cleanup.remove_unused_private_fields=true
45+
sp_cleanup.remove_unused_private_members=false
46+
sp_cleanup.remove_unused_private_methods=true
47+
sp_cleanup.remove_unused_private_types=true
48+
sp_cleanup.sort_members=false
49+
sp_cleanup.sort_members_all=false
50+
sp_cleanup.use_blocks=false
51+
sp_cleanup.use_blocks_only_for_return_and_throw=false
52+
sp_cleanup.use_parentheses_in_expressions=false
53+
sp_cleanup.use_this_for_non_static_field_access=false
54+
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
55+
sp_cleanup.use_this_for_non_static_method_access=false
56+
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true

libraries/cardboard/build.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
srcdir="src" destdir="bin"
3030
encoding="UTF-8"
3131
includeAntRuntime="false"
32-
classpath="lib/cardboard-audio-classes.jar;
33-
lib/cardboard-common-classes.jar;
34-
lib/cardboard-core-classes.jar;
32+
classpath="lib/vr_base-classes.jar;
33+
lib/vr_common-classes.jar;
34+
lib/vr_audio-classes.jar;
3535
../../android-core.zip;
3636
${env.ANDROID_SDK}/platforms/android-23/android.jar"
3737
nowarn="true"

libraries/cardboard/examples/Cube/AndroidManifest.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

libraries/cardboard/examples/Cube/code/sketch.properties

Lines changed: 0 additions & 3 deletions
This file was deleted.
1.26 MB
Binary file not shown.
2.1 MB
Binary file not shown.
Binary file not shown.
-1.15 MB
Binary file not shown.
-266 KB
Binary file not shown.
-1.54 MB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1.26 MB
Binary file not shown.
2 MB
Binary file not shown.
453 KB
Binary file not shown.

libraries/cardboard/src/processing/cardboard/PCardboard.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222

2323
package processing.cardboard;
2424

25-
import com.google.vrtoolkit.cardboard.CardboardActivity;
26-
import com.google.vrtoolkit.cardboard.Eye;
25+
import com.google.vr.sdk.base.GvrActivity;
26+
import com.google.vr.sdk.base.Eye;
2727

2828
import android.content.Intent;
2929
import android.util.DisplayMetrics;
3030
import processing.android.AppComponent;
3131
import processing.core.PApplet;
3232

3333
// http://pastebin.com/6wPgFYhq
34-
public class PCardboard extends CardboardActivity implements AppComponent {
34+
public class PCardboard extends GvrActivity implements AppComponent {
3535
public static final String STEREO = "processing.cardboard.PGraphicsCardboardStereo";
3636
public static final String MONO = "processing.cardboard.PGraphicsCardboardMono";
3737

@@ -40,7 +40,7 @@ public class PCardboard extends CardboardActivity implements AppComponent {
4040
public static final int MONOCULAR = Eye.Type.MONOCULAR;
4141

4242
static public final int CARDBOARD = 3;
43-
43+
4444
private DisplayMetrics metrics;
4545
private PApplet sketch;
4646

@@ -67,14 +67,14 @@ public int getDisplayHeight() {
6767
public int getKind() {
6868
return CARDBOARD;
6969
}
70-
70+
7171
public void dispose() {
72-
}
73-
72+
}
73+
7474
public void onPermissionsGranted() {
7575

7676
}
77-
77+
7878
public void setSketch(PApplet sketch) {
7979
this.sketch = sketch;
8080
}
@@ -129,7 +129,7 @@ public void onPause() {
129129
@Override
130130
public void onDestroy() {
131131
super.onDestroy();
132-
sketch.onDestroy();
132+
sketch.onDestroy();
133133
}
134134

135135

libraries/cardboard/src/processing/cardboard/PGraphicsCardboard.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
package processing.cardboard;
2424

25-
import com.google.vrtoolkit.cardboard.Eye;
26-
import com.google.vrtoolkit.cardboard.HeadTransform;
27-
import com.google.vrtoolkit.cardboard.Viewport;
25+
import com.google.vr.sdk.base.Eye;
26+
import com.google.vr.sdk.base.HeadTransform;
27+
import com.google.vr.sdk.base.Viewport;
2828

2929
import processing.core.PMatrix3D;
3030
import processing.opengl.PGL;
@@ -44,11 +44,13 @@ public class PGraphicsCardboard extends PGraphics3D {
4444
private PMatrix3D perspectiveMatrix;
4545

4646

47+
@Override
4748
protected PGL createPGL(PGraphicsOpenGL pg) {
4849
return new PGLES(pg);
4950
}
5051

5152

53+
@Override
5254
public void beginDraw() {
5355
super.beginDraw();
5456
pgl.viewport(viewPort.x, viewPort.y, viewPort.width, viewPort.height);

libraries/cardboard/src/processing/cardboard/PGraphicsCardboardMono.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import processing.core.PSurface;
2828

2929
public class PGraphicsCardboardMono extends PGraphicsCardboard {
30+
@Override
3031
public PSurface createSurface(AppComponent component, SurfaceHolder holder) { // ignore
3132
return new PSurfaceCardboard(this, component, holder, false);
3233
}

libraries/cardboard/src/processing/cardboard/PGraphicsCardboardStereo.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import processing.core.PSurface;
2828

2929
public class PGraphicsCardboardStereo extends PGraphicsCardboard {
30+
@Override
3031
public PSurface createSurface(AppComponent component, SurfaceHolder holder) { // ignore
3132
return new PSurfaceCardboard(this, component, holder, true);
3233
}

libraries/cardboard/src/processing/cardboard/PSurfaceCardboard.java

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727

2828
import javax.microedition.khronos.egl.EGLConfig;
2929

30-
import com.google.vrtoolkit.cardboard.CardboardActivity;
31-
import com.google.vrtoolkit.cardboard.CardboardView;
32-
import com.google.vrtoolkit.cardboard.Eye;
33-
import com.google.vrtoolkit.cardboard.HeadTransform;
34-
import com.google.vrtoolkit.cardboard.Viewport;
30+
import com.google.vr.sdk.base.GvrActivity;
31+
import com.google.vr.sdk.base.GvrView;
32+
import com.google.vr.sdk.base.AndroidCompat;
33+
import com.google.vr.sdk.base.Eye;
34+
import com.google.vr.sdk.base.HeadTransform;
35+
import com.google.vr.sdk.base.Viewport;
3536

3637
import android.app.Activity;
3738
import android.app.ActivityManager;
@@ -53,54 +54,68 @@
5354
public class PSurfaceCardboard extends PSurfaceGLES {
5455
protected GLCardboardSurfaceView glview;
5556
protected PGraphicsCardboard pgc;
56-
57-
protected CardboardActivity cardboard;
57+
58+
protected GvrActivity cardboard;
5859
protected AndroidCardboardStereoRenderer renderer;
5960

6061
public PSurfaceCardboard(PGraphics graphics, AppComponent component, SurfaceHolder holder, boolean vr) {
6162
this.sketch = graphics.parent;
6263
this.graphics = graphics;
6364
this.component = component;
6465
this.pgl = (PGLES)((PGraphicsOpenGL)graphics).pgl;
65-
66-
cardboard = (CardboardActivity)component;
66+
67+
cardboard = (GvrActivity)component;
6768
pgc = (PGraphicsCardboard)graphics;
6869

6970
glview = new GLCardboardSurfaceView(cardboard);
70-
glview.setVRModeEnabled(vr);
71+
glview.setStereoModeEnabled(vr);
7172
if (vr) {
7273
glview.setDistortionCorrectionEnabled(true);
7374
glview.setNeckModelEnabled(true);
74-
// glview.setElectronicDisplayStabilizationEnabled(true);
75+
// glview.setElectronicDisplayStabilizationEnabled(true);
76+
}
77+
78+
// Enable Cardboard-trigger feedback with Daydream headsets. This is a simple way of supporting
79+
// Daydream controller input for basic interactions using the existing Cardboard trigger API.
80+
glview.enableCardboardTriggerEmulation();
81+
82+
if (glview.setAsyncReprojectionEnabled(true)) {
83+
// Async reprojection decouples the app framerate from the display framerate,
84+
// allowing immersive interaction even at the throttled clockrates set by
85+
// sustained performance mode.
86+
AndroidCompat.setSustainedPerformanceMode(cardboard, true);
7587
}
76-
cardboard.setCardboardView(glview);
88+
cardboard.setGvrView(glview);
7789

7890
surface = null;
7991
}
80-
92+
8193
@Override
8294
public Context getContext() {
8395
return cardboard;
8496
}
85-
97+
8698
@Override
8799
public Activity getActivity() {
88100
return cardboard;
89101
}
90-
102+
91103
@Override
92104
public void finish() {
93105
cardboard.finish();
94106
}
95-
107+
108+
@Override
96109
public AssetManager getAssets() {
97110
return cardboard.getAssets();
98111
}
99112

113+
@Override
100114
public void startActivity(Intent intent) {
101115
cardboard.startActivity(intent);
102116
}
103117

118+
@Override
104119
public void initView(int sketchWidth, int sketchHeight) {
105120
Window window = cardboard.getWindow();
106121

@@ -118,10 +133,12 @@ public void initView(int sketchWidth, int sketchHeight) {
118133
window.setContentView(glview);
119134
}
120135

136+
@Override
121137
public String getName() {
122138
return cardboard.getComponentName().getPackageName();
123139
}
124140

141+
@Override
125142
public void setOrientation(int which) {
126143
if (component.getKind() == AppComponent.FRAGMENT) {
127144
if (which == PORTRAIT) {
@@ -132,18 +149,22 @@ public void setOrientation(int which) {
132149
}
133150
}
134151

152+
@Override
135153
public File getFilesDir() {
136154
return cardboard.getFilesDir();
137155
}
138156

157+
@Override
139158
public InputStream openFileInput(String filename) {
140159
return null;
141160
}
142161

162+
@Override
143163
public File getFileStreamPath(String path) {
144164
return cardboard.getFileStreamPath(path);
145165
}
146166

167+
@Override
147168
public void dispose() {
148169
// surface.onDestroy();
149170
}
@@ -186,7 +207,7 @@ public boolean isStopped() {
186207

187208
///////////////////////////////////////////////////////////
188209

189-
public class GLCardboardSurfaceView extends CardboardView {
210+
public class GLCardboardSurfaceView extends GvrView {
190211
public GLCardboardSurfaceView(Context context) {
191212
super(context);
192213

@@ -250,19 +271,19 @@ public boolean onKeyUp(int code, android.view.KeyEvent event) {
250271
return super.onKeyUp(code, event);
251272
}
252273
}
253-
274+
254275
///////////////////////////////////////////////////////////
255276

256-
// Android specific classes (Renderer, ConfigChooser)
277+
// Android specific classes (Renderer, ConfigChooser)
257278

258279

259280
public AndroidCardboardStereoRenderer getCardboardStereoRenderer() {
260281
renderer = new AndroidCardboardStereoRenderer();
261282
return renderer;
262-
}
283+
}
263284

264285

265-
protected class AndroidCardboardStereoRenderer implements CardboardView.StereoRenderer {
286+
protected class AndroidCardboardStereoRenderer implements GvrView.StereoRenderer {
266287
public AndroidCardboardStereoRenderer() {
267288

268289
}

0 commit comments

Comments
 (0)