Skip to content

Commit

Permalink
cardboard working with GVR SDK 1.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
codeanticode committed Jan 4, 2017
1 parent 7f89148 commit c958737
Show file tree
Hide file tree
Showing 28 changed files with 608 additions and 436 deletions.
377 changes: 377 additions & 0 deletions libraries/cardboard/.settings/org.eclipse.jdt.core.prefs

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions libraries/cardboard/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,56 @@
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_processing
formatter_settings_version=12
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=false
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
sp_cleanup.add_missing_override_annotations=true
sp_cleanup.add_missing_override_annotations_interface_methods=false
sp_cleanup.add_serial_version_id=false
sp_cleanup.always_use_blocks=true
sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_to_enhanced_for_loop=false
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=false
sp_cleanup.format_source_code_changes_only=false
sp_cleanup.make_local_variable_final=false
sp_cleanup.make_parameters_final=false
sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
sp_cleanup.make_variable_declarations_final=false
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=true
sp_cleanup.organize_imports=false
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
sp_cleanup.remove_unnecessary_casts=false
sp_cleanup.remove_unnecessary_nls_tags=false
sp_cleanup.remove_unused_imports=false
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
sp_cleanup.remove_unused_private_methods=true
sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_blocks=false
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_parentheses_in_expressions=false
sp_cleanup.use_this_for_non_static_field_access=false
sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
sp_cleanup.use_this_for_non_static_method_access=false
sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
6 changes: 3 additions & 3 deletions libraries/cardboard/build.xml
Expand Up @@ -29,9 +29,9 @@
srcdir="src" destdir="bin"
encoding="UTF-8"
includeAntRuntime="false"
classpath="lib/cardboard-audio-classes.jar;
lib/cardboard-common-classes.jar;
lib/cardboard-core-classes.jar;
classpath="lib/vr_base-classes.jar;
lib/vr_common-classes.jar;
lib/vr_audio-classes.jar;
../../android-core.zip;
${env.ANDROID_SDK}/platforms/android-23/android.jar"
nowarn="true"
Expand Down
21 changes: 0 additions & 21 deletions libraries/cardboard/examples/Cube/AndroidManifest.xml

This file was deleted.

3 changes: 0 additions & 3 deletions libraries/cardboard/examples/Cube/code/sketch.properties

This file was deleted.

Binary file added libraries/cardboard/gvrsdk/1.10.0/vr_audio.zip
Binary file not shown.
Binary file added libraries/cardboard/gvrsdk/1.10.0/vr_base.zip
Binary file not shown.
Binary file added libraries/cardboard/gvrsdk/1.10.0/vr_common.zip
Binary file not shown.
Binary file removed libraries/cardboard/gvrsdk/cardboard_audio.zip
Binary file not shown.
Binary file removed libraries/cardboard/gvrsdk/cardboard_common.zip
Binary file not shown.
Binary file removed libraries/cardboard/gvrsdk/cardboard_core.zip
Binary file not shown.
Binary file removed libraries/cardboard/lib/cardboard-audio-classes.jar
Binary file not shown.
Binary file not shown.
Binary file removed libraries/cardboard/lib/cardboard-core-classes.jar
Binary file not shown.
Binary file added libraries/cardboard/lib/vr_audio-classes.jar
Binary file not shown.
Binary file added libraries/cardboard/lib/vr_base-classes.jar
Binary file not shown.
Binary file added libraries/cardboard/lib/vr_common-classes.jar
Binary file not shown.
18 changes: 9 additions & 9 deletions libraries/cardboard/src/processing/cardboard/PCardboard.java
Expand Up @@ -22,16 +22,16 @@

package processing.cardboard;

import com.google.vrtoolkit.cardboard.CardboardActivity;
import com.google.vrtoolkit.cardboard.Eye;
import com.google.vr.sdk.base.GvrActivity;
import com.google.vr.sdk.base.Eye;

import android.content.Intent;
import android.util.DisplayMetrics;
import processing.android.AppComponent;
import processing.core.PApplet;

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

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

static public final int CARDBOARD = 3;

private DisplayMetrics metrics;
private PApplet sketch;

Expand All @@ -67,14 +67,14 @@ public int getDisplayHeight() {
public int getKind() {
return CARDBOARD;
}

public void dispose() {
}
}

public void onPermissionsGranted() {

}

public void setSketch(PApplet sketch) {
this.sketch = sketch;
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public void onPause() {
@Override
public void onDestroy() {
super.onDestroy();
sketch.onDestroy();
sketch.onDestroy();
}


Expand Down
Expand Up @@ -22,9 +22,9 @@

package processing.cardboard;

import com.google.vrtoolkit.cardboard.Eye;
import com.google.vrtoolkit.cardboard.HeadTransform;
import com.google.vrtoolkit.cardboard.Viewport;
import com.google.vr.sdk.base.Eye;
import com.google.vr.sdk.base.HeadTransform;
import com.google.vr.sdk.base.Viewport;

import processing.core.PMatrix3D;
import processing.opengl.PGL;
Expand All @@ -44,11 +44,13 @@ public class PGraphicsCardboard extends PGraphics3D {
private PMatrix3D perspectiveMatrix;


@Override
protected PGL createPGL(PGraphicsOpenGL pg) {
return new PGLES(pg);
}


@Override
public void beginDraw() {
super.beginDraw();
pgl.viewport(viewPort.x, viewPort.y, viewPort.width, viewPort.height);
Expand Down
Expand Up @@ -27,6 +27,7 @@
import processing.core.PSurface;

public class PGraphicsCardboardMono extends PGraphicsCardboard {
@Override
public PSurface createSurface(AppComponent component, SurfaceHolder holder) { // ignore
return new PSurfaceCardboard(this, component, holder, false);
}
Expand Down
Expand Up @@ -27,6 +27,7 @@
import processing.core.PSurface;

public class PGraphicsCardboardStereo extends PGraphicsCardboard {
@Override
public PSurface createSurface(AppComponent component, SurfaceHolder holder) { // ignore
return new PSurfaceCardboard(this, component, holder, true);
}
Expand Down
63 changes: 42 additions & 21 deletions libraries/cardboard/src/processing/cardboard/PSurfaceCardboard.java
Expand Up @@ -27,11 +27,12 @@

import javax.microedition.khronos.egl.EGLConfig;

import com.google.vrtoolkit.cardboard.CardboardActivity;
import com.google.vrtoolkit.cardboard.CardboardView;
import com.google.vrtoolkit.cardboard.Eye;
import com.google.vrtoolkit.cardboard.HeadTransform;
import com.google.vrtoolkit.cardboard.Viewport;
import com.google.vr.sdk.base.GvrActivity;
import com.google.vr.sdk.base.GvrView;
import com.google.vr.sdk.base.AndroidCompat;
import com.google.vr.sdk.base.Eye;
import com.google.vr.sdk.base.HeadTransform;
import com.google.vr.sdk.base.Viewport;

import android.app.Activity;
import android.app.ActivityManager;
Expand All @@ -53,54 +54,68 @@
public class PSurfaceCardboard extends PSurfaceGLES {
protected GLCardboardSurfaceView glview;
protected PGraphicsCardboard pgc;
protected CardboardActivity cardboard;

protected GvrActivity cardboard;
protected AndroidCardboardStereoRenderer renderer;

public PSurfaceCardboard(PGraphics graphics, AppComponent component, SurfaceHolder holder, boolean vr) {
this.sketch = graphics.parent;
this.graphics = graphics;
this.component = component;
this.pgl = (PGLES)((PGraphicsOpenGL)graphics).pgl;
cardboard = (CardboardActivity)component;

cardboard = (GvrActivity)component;
pgc = (PGraphicsCardboard)graphics;

glview = new GLCardboardSurfaceView(cardboard);
glview.setVRModeEnabled(vr);
glview.setStereoModeEnabled(vr);
if (vr) {
glview.setDistortionCorrectionEnabled(true);
glview.setNeckModelEnabled(true);
// glview.setElectronicDisplayStabilizationEnabled(true);
// glview.setElectronicDisplayStabilizationEnabled(true);
}

// Enable Cardboard-trigger feedback with Daydream headsets. This is a simple way of supporting
// Daydream controller input for basic interactions using the existing Cardboard trigger API.
glview.enableCardboardTriggerEmulation();

if (glview.setAsyncReprojectionEnabled(true)) {
// Async reprojection decouples the app framerate from the display framerate,
// allowing immersive interaction even at the throttled clockrates set by
// sustained performance mode.
AndroidCompat.setSustainedPerformanceMode(cardboard, true);
}
cardboard.setCardboardView(glview);
cardboard.setGvrView(glview);

surface = null;
}

@Override
public Context getContext() {
return cardboard;
}

@Override
public Activity getActivity() {
return cardboard;
}

@Override
public void finish() {
cardboard.finish();
}


@Override
public AssetManager getAssets() {
return cardboard.getAssets();
}

@Override
public void startActivity(Intent intent) {
cardboard.startActivity(intent);
}

@Override
public void initView(int sketchWidth, int sketchHeight) {
Window window = cardboard.getWindow();

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

@Override
public String getName() {
return cardboard.getComponentName().getPackageName();
}

@Override
public void setOrientation(int which) {
if (component.getKind() == AppComponent.FRAGMENT) {
if (which == PORTRAIT) {
Expand All @@ -132,18 +149,22 @@ public void setOrientation(int which) {
}
}

@Override
public File getFilesDir() {
return cardboard.getFilesDir();
}

@Override
public InputStream openFileInput(String filename) {
return null;
}

@Override
public File getFileStreamPath(String path) {
return cardboard.getFileStreamPath(path);
}

@Override
public void dispose() {
// surface.onDestroy();
}
Expand Down Expand Up @@ -186,7 +207,7 @@ public boolean isStopped() {

///////////////////////////////////////////////////////////

public class GLCardboardSurfaceView extends CardboardView {
public class GLCardboardSurfaceView extends GvrView {
public GLCardboardSurfaceView(Context context) {
super(context);

Expand Down Expand Up @@ -250,19 +271,19 @@ public boolean onKeyUp(int code, android.view.KeyEvent event) {
return super.onKeyUp(code, event);
}
}

///////////////////////////////////////////////////////////

// Android specific classes (Renderer, ConfigChooser)
// Android specific classes (Renderer, ConfigChooser)


public AndroidCardboardStereoRenderer getCardboardStereoRenderer() {
renderer = new AndroidCardboardStereoRenderer();
return renderer;
}
}


protected class AndroidCardboardStereoRenderer implements CardboardView.StereoRenderer {
protected class AndroidCardboardStereoRenderer implements GvrView.StereoRenderer {
public AndroidCardboardStereoRenderer() {

}
Expand Down

0 comments on commit c958737

Please sign in to comment.