Skip to content

Commit

Permalink
Messy but functional.
Browse files Browse the repository at this point in the history
  • Loading branch information
kanawish committed Sep 29, 2016
1 parent 0fd47ae commit 6b04bc5
Show file tree
Hide file tree
Showing 16 changed files with 102 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta3'
classpath 'com.android.tools.build:gradle:2.2.0-rc1'
classpath 'com.google.gms:google-services:3.0.0'

// Retrolambda Support
Expand Down
1 change: 1 addition & 0 deletions rajaDemo/src/main/java/com/kanawish/raja/DemoFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa

@Override
public BaselineRenderer createRenderer() {
// NOTE: If you build your own renderer, simply switch them in here.
return new SimpleRenderer(getActivity(), this);
}

Expand Down
2 changes: 2 additions & 0 deletions rajaDemo/src/main/java/com/kanawish/raja/SimpleRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ protected void initScene() {
// Models
Material material = new Material();
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.setColor(0xffff0000);
material.setColorInfluence(1);
material.enableLighting(true);
Cube cube = new Cube(1);
cube.setMaterial(material);
Expand Down
2 changes: 1 addition & 1 deletion rajaTangoLib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar'])
compile (name: 'TangoSupport_Qianru_Java', ext: 'aar')
compile (name: 'tango_support_java_lib', ext: 'aar')

compile project(':commonLib')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
import org.rajawali3d.primitives.Sphere;
import org.rajawali3d.vr.renderer.RajaStereoRenderer;

public final class DemoVRRenderer extends RajaStereoRenderer {
public final class DemoVrRenderer extends RajaStereoRenderer {

private Material sphereAMaterial;
private Material lookedAtMaterial;
private Object3D sphereA;

private PostProcessingManager effectsManager;

public DemoVRRenderer(Context context) {
public DemoVrRenderer(Context context) {
super(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ public void onCreate(Bundle savedInstanceState) {
RajaVrView gvrView = (RajaVrView) findViewById(R.id.gvr_view);

gvrView.setEGLConfigChooser(8, 8, 8, 8, 16, 8);
gvrView.setRenderer(new DemoVRRenderer(this));

// NOTE: If you build your own renderer, simply switch them in here.
gvrView.setRenderer(new SimpleVrRenderer(this));

gvrView.setTransitionViewEnabled(true);
gvrView.setOnCardboardBackButtonListener(() -> vibrator.vibrate(50));
setGvrView(gvrView);
this.setGvrView(gvrView);

// Initialize 3D audio engine.
gvrAudioEngine = new GvrAudioEngine(this, GvrAudioEngine.RenderingMode.BINAURAL_HIGH_QUALITY);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.kanawish.raja.vr;

import android.content.Context;
import android.graphics.Color;
import android.view.MotionEvent;

import org.rajawali3d.animation.Animation;
import org.rajawali3d.animation.RotateOnAxisAnimation;
import org.rajawali3d.lights.DirectionalLight;
import org.rajawali3d.materials.Material;
import org.rajawali3d.materials.methods.DiffuseMethod;
import org.rajawali3d.materials.textures.ATexture;
import org.rajawali3d.math.vector.Vector3;
import org.rajawali3d.primitives.Cube;
import org.rajawali3d.vr.renderer.RajaStereoRenderer;

class SimpleVrRenderer extends RajaStereoRenderer {

SimpleVrRenderer(Context context) {
super(context);
}

@Override
protected void initScene() {
try {
getCurrentScene().setBackgroundColor(Color.BLUE);

getCurrentCamera().setFarPlane(1000);

// Skybox images by Emil Persson, aka Humus. http://www.humus.name humus@comhem.se
try {
getCurrentScene().setSkybox(R.drawable.posx, R.drawable.negx,
R.drawable.posy, R.drawable.negy, R.drawable.posz, R.drawable.negz);
} catch (ATexture.TextureException e) {
e.printStackTrace();
}

// Lights,
DirectionalLight key = new DirectionalLight(0, 0.1, 0.2);
key.setPosition(0.0, 10.0, 2.5);
key.enableLookAt();
key.setPower(2);
getCurrentScene().addLight(key);

// Models
Material material = new Material();
material.setDiffuseMethod(new DiffuseMethod.Lambert());
material.enableLighting(true);
Cube cube = new Cube(1);
cube.setPosition(0, -1, -3);
cube.setMaterial(material);
getCurrentScene().addChild(cube);

// NOTE: Camera is controlled via VR headset orientation.

// Action!
RotateOnAxisAnimation anim = new RotateOnAxisAnimation(new Vector3(1, 1, 1), 360);
anim.setTransformable3D(cube);
anim.setDurationMilliseconds(20000);
anim.setRepeatMode(Animation.RepeatMode.INFINITE);
getCurrentScene().registerAnimation(anim);
anim.play();
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void onRender(final long ellapsedTime, final double deltaTime) {
super.onRender(ellapsedTime, deltaTime);
}

@Override
public void onTouchEvent(MotionEvent event) {
}
}
Binary file removed tangoLibs/aar/TangoSupport_Qianru_Java.aar
Binary file not shown.
Binary file removed tangoLibs/aar/TangoUX_Qianru_Java.aar
Binary file not shown.
Binary file added tangoLibs/aar/tango_support_java_lib.aar
Binary file not shown.
Binary file removed tangoLibs/jar/TangoSDK_Qianru_Java.jar
Binary file not shown.
Binary file added tangoLibs/jar/tango_java_lib.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion tangoRoomEditor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])

compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar'])
compile (name: 'TangoSupport_Qianru_Java', ext: 'aar')
compile (name: 'tango_support_java_lib', ext: 'aar')

compile project(':rajaTangoLib')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
if (planeFitTransform != null) {
// Update the position of the rendered cube to the pose of the detected plane
// This update is made thread safe by the renderer
surfaceView.queueEvent( );
renderer.updateObjectPose(planeFitTransform);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import org.rajawali3d.animation.Animation;
import org.rajawali3d.animation.Animation3D;
import org.rajawali3d.animation.RotateOnAxisAnimation;
import org.rajawali3d.debug.CoordinateTrident;
import org.rajawali3d.debug.DebugCamera;
import org.rajawali3d.debug.DebugLight;
import org.rajawali3d.lights.DirectionalLight;
import org.rajawali3d.loader.LoaderOBJ;
import org.rajawali3d.loader.ParsingException;
Expand All @@ -43,6 +46,7 @@
import org.rajawali3d.math.vector.Vector3;
import org.rajawali3d.primitives.Cube;
import org.rajawali3d.primitives.Plane;
import org.rajawali3d.primitives.RectangularPrism;
import org.rajawali3d.primitives.ScreenQuad;
import org.rajawali3d.primitives.Sphere;
import org.rajawali3d.renderer.Renderer;
Expand Down Expand Up @@ -104,15 +108,17 @@ protected void initScene() {
light.setPower(1.2f);
light.setPosition(0, 10, 0);
getCurrentScene().addLight(light);
getCurrentScene().addChild(new DebugLight(light));

// Set-up a material
Material cubeMaterial = buildMaterial(Color.RED);

// Build a Cube
// cube = new CoordinateTrident();
cube = new Cube(CUBE_SIDE_LENGTH);
cube.setMaterial(cubeMaterial);
cube.setPosition(0, 0, 0);
cube.setRotation(Vector3.Axis.Z, 180);
cube.setPosition(0, 0, 0);
cube.setVisible(false);
getCurrentScene().addChild(cube);

Expand All @@ -133,12 +139,14 @@ protected void initScene() {
} catch (ATexture.TextureException e) {
e.printStackTrace();
}
plane = new Plane();
plane = new Plane(0.5f,0.5f,1,1);
plane.setMaterial(checkerboard);
plane.setDoubleSided(true);
plane.setColor(0xff0000ff);
plane.setVisible(false);
getCurrentScene().addChild(plane);

// getCurrentScene().addChild(new DebugCamera(getCurrentCamera())); // ?
}

@NonNull
Expand All @@ -156,6 +164,7 @@ enum Furniture {
Furniture next() {
int i = (this.ordinal() + 1) % Furniture.values().length;
return Furniture.values()[i];
// return PLANE ;
}
}
Furniture currentFurniture = Furniture.PLANE;
Expand Down
2 changes: 2 additions & 0 deletions tangoRoomEditor/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
android:layout_height="wrap_content"
android:text="placeholder"/>

<!--
<Button
android:layout_gravity="bottom|right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BLAH"/>
-->

</FrameLayout>

0 comments on commit 6b04bc5

Please sign in to comment.