Skip to content
This repository was archived by the owner on Mar 2, 2018. It is now read-only.

Commit c55cc77

Browse files
committed
release-yamabe
1 parent 52f9dc7 commit c55cc77

11 files changed

Lines changed: 164 additions & 80 deletions

File tree

AreaLearningJava/app/src/main/java/com/projecttango/experiments/javaarealearning/AreaLearningActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848

4949
import com.projecttango.tangoutils.TangoPoseUtilities;
5050

51+
import org.rajawali3d.surface.IRajawaliSurface;
5152
import org.rajawali3d.surface.RajawaliSurfaceView;
5253

5354
/**
@@ -242,6 +243,7 @@ private AreaLearningRajawaliRenderer setupGLViewAndRenderer(){
242243
// OpenGL view where all of the graphics are drawn
243244
RajawaliSurfaceView glView = (RajawaliSurfaceView) findViewById(R.id.gl_surface_view);
244245
glView.setEGLContextClientVersion(2);
246+
glView.setRenderMode(IRajawaliSurface.RENDERMODE_CONTINUOUSLY);
245247
glView.setSurfaceRenderer(renderer);
246248
return renderer;
247249
}

AreaLearningJava/app/src/main/java/com/projecttango/experiments/javaarealearning/AreaLearningRajawaliRenderer.java

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class AreaLearningRajawaliRenderer extends RajawaliRenderer {
5151

5252
// Latest available device pose;
5353
private Pose mDevicePose = new Pose(Vector3.ZERO, Quaternion.getIdentity());
54+
private boolean mPoseUpdated = false;
5455

5556
public AreaLearningRajawaliRenderer(Context context) {
5657
super(context);
@@ -60,17 +61,17 @@ public AreaLearningRajawaliRenderer(Context context) {
6061

6162
@Override
6263
protected void initScene() {
63-
Grid grid = new Grid(100, 1);
64+
Grid grid = new Grid(100, 1, 1, 0xFFCCCCCC);
6465
grid.setPosition(0, -1.3f, 0);
6566
getCurrentScene().addChild(grid);
6667

67-
mFrustumAxes = new FrustumAxes();
68+
mFrustumAxes = new FrustumAxes(3);
6869
getCurrentScene().addChild(mFrustumAxes);
6970

70-
mBlueTrajectory = new Trajectory(Color.BLUE);
71+
mBlueTrajectory = new Trajectory(Color.BLUE, 2);
7172
getCurrentScene().addChild(mBlueTrajectory);
7273

73-
mGreenTrajectory = new Trajectory(Color.GREEN);
74+
mGreenTrajectory = new Trajectory(Color.GREEN, 2);
7475
getCurrentScene().addChild(mGreenTrajectory);
7576

7677
getCurrentScene().setBackgroundColor(Color.WHITE);
@@ -86,18 +87,21 @@ protected void onRender(long ellapsedRealtime, double deltaTime) {
8687
// Update the scene objects with the latest device position and orientation information.
8788
// Synchronize to avoid concurrent access from the Tango callback thread below.
8889
synchronized (this) {
89-
mFrustumAxes.setPosition(mDevicePose.getPosition());
90-
mFrustumAxes.setOrientation(mDevicePose.getOrientation());
91-
if(mIsRelocalized){
92-
if (mGreenTrajectory.getLastPoint().distanceTo2(mDevicePose.getPosition()) > THRESHOLD) {
93-
mGreenTrajectory.addSegmentTo(mDevicePose.getPosition());
94-
}
95-
} else {
96-
if (mBlueTrajectory.getLastPoint().distanceTo2(mDevicePose.getPosition()) > THRESHOLD) {
97-
mBlueTrajectory.addSegmentTo(mDevicePose.getPosition());
90+
if (mPoseUpdated) {
91+
mPoseUpdated = false;
92+
mFrustumAxes.setPosition(mDevicePose.getPosition());
93+
mFrustumAxes.setOrientation(mDevicePose.getOrientation());
94+
if (mIsRelocalized) {
95+
if (mGreenTrajectory.getLastPoint().distanceTo2(mDevicePose.getPosition()) > THRESHOLD) {
96+
mGreenTrajectory.addSegmentTo(mDevicePose.getPosition());
97+
}
98+
} else {
99+
if (mBlueTrajectory.getLastPoint().distanceTo2(mDevicePose.getPosition()) > THRESHOLD) {
100+
mBlueTrajectory.addSegmentTo(mDevicePose.getPosition());
101+
}
98102
}
103+
mTouchViewHandler.updateCamera(mDevicePose.getPosition(), mDevicePose.getOrientation());
99104
}
100-
mTouchViewHandler.updateCamera(mDevicePose.getPosition(), mDevicePose.getOrientation());
101105
}
102106
}
103107

@@ -113,6 +117,7 @@ protected void onRender(long ellapsedRealtime, double deltaTime) {
113117
public synchronized void updateDevicePose(TangoPoseData tangoPoseData, boolean isRelocalized) {
114118
mDevicePose = ScenePoseCalcuator.toOpenGLPose(tangoPoseData);
115119
mIsRelocalized = isRelocalized;
120+
mPoseUpdated = true;
116121
}
117122

118123
@Override

MotionTrackingJava/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if (project.hasProperty("Tango.catkin_devel_prefix")) {
3838

3939
dependencies {
4040
compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar'])
41-
compile(name: 'TangoUtils', ext: 'aar')
41+
compile (name: 'TangoUtils', ext: 'aar')
4242
compile 'org.rajawali3d:rajawali:1.0.294-SNAPSHOT@aar'
4343
}
4444

MotionTrackingJava/app/src/main/java/com/projecttango/experiments/javamotiontracking/MotionTrackingActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import android.widget.TextView;
4040
import android.widget.Toast;
4141

42+
import org.rajawali3d.surface.IRajawaliSurface;
4243
import org.rajawali3d.surface.RajawaliSurfaceView;
4344

4445
import java.text.DecimalFormat;
@@ -99,6 +100,7 @@ private MotionTrackingRajawaliRenderer setupGLViewAndRenderer(){
99100
// OpenGL view where all of the graphics are drawn
100101
RajawaliSurfaceView glView = (RajawaliSurfaceView) findViewById(R.id.gl_surface_view);
101102
glView.setEGLContextClientVersion(2);
103+
glView.setRenderMode(IRajawaliSurface.RENDERMODE_CONTINUOUSLY);
102104
glView.setSurfaceRenderer(renderer);
103105
return renderer;
104106

MotionTrackingJava/app/src/main/java/com/projecttango/experiments/javamotiontracking/MotionTrackingRajawaliRenderer.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ public class MotionTrackingRajawaliRenderer extends RajawaliRenderer {
5151
private TouchViewHandler touchViewHandler;
5252

5353
// Latest available device pose;
54-
private Pose devicePose = new Pose(Vector3.ZERO, Quaternion.getIdentity());
54+
private Pose mDevicePose = new Pose(Vector3.ZERO, Quaternion.getIdentity());
55+
private boolean mPoseUpdated = false;
5556

5657
public MotionTrackingRajawaliRenderer(Context context) {
5758
super(context);
@@ -60,14 +61,14 @@ public MotionTrackingRajawaliRenderer(Context context) {
6061

6162
@Override
6263
protected void initScene() {
63-
Grid grid = new Grid(100, 1);
64+
Grid grid = new Grid(100, 1, 1, 0xFFCCCCCC);
6465
grid.setPosition(0, -1.3f, 0);
6566
getCurrentScene().addChild(grid);
6667

67-
mFrustumAxes = new FrustumAxes();
68+
mFrustumAxes = new FrustumAxes(3);
6869
getCurrentScene().addChild(mFrustumAxes);
6970

70-
mTrajectory = new Trajectory(Color.BLUE);
71+
mTrajectory = new Trajectory(Color.BLUE, 2);
7172
getCurrentScene().addChild(mTrajectory);
7273

7374
getCurrentScene().setBackgroundColor(Color.WHITE);
@@ -83,14 +84,17 @@ protected void onRender(long ellapsedRealtime, double deltaTime) {
8384
// Update the scene objects with the latest device position and orientation information.
8485
// Synchronize to avoid concurrent access from the Tango callback thread below.
8586
synchronized (this) {
86-
mFrustumAxes.setPosition(devicePose.getPosition());
87-
mFrustumAxes.setOrientation(devicePose.getOrientation());
87+
if (mPoseUpdated) {
88+
mPoseUpdated = false;
89+
mFrustumAxes.setPosition(mDevicePose.getPosition());
90+
mFrustumAxes.setOrientation(mDevicePose.getOrientation());
8891

89-
if (mTrajectory.getLastPoint().distanceTo2(devicePose.getPosition()) > THRESHOLD) {
90-
mTrajectory.addSegmentTo(devicePose.getPosition());
91-
}
92+
if (mTrajectory.getLastPoint().distanceTo2(mDevicePose.getPosition()) > THRESHOLD) {
93+
mTrajectory.addSegmentTo(mDevicePose.getPosition());
94+
}
9295

93-
touchViewHandler.updateCamera(devicePose.getPosition(), devicePose.getOrientation());
96+
touchViewHandler.updateCamera(mDevicePose.getPosition(), mDevicePose.getOrientation());
97+
}
9498
}
9599
}
96100

@@ -100,7 +104,8 @@ protected void onRender(long ellapsedRealtime, double deltaTime) {
100104
* concurrent access from the OpenGL thread above.
101105
*/
102106
public synchronized void updateDevicePose(TangoPoseData tangoPoseData) {
103-
devicePose = ScenePoseCalcuator.toOpenGLPose(tangoPoseData);
107+
mDevicePose = ScenePoseCalcuator.toOpenGLPose(tangoPoseData);
108+
mPoseUpdated = true;
104109
}
105110

106111
@Override

MotionTrackingJava/settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include ':app'
1+
include ':app'

PointCloudJava/app/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ if (project.hasProperty("Tango.catkin_devel_prefix")) {
3737
}
3838

3939
dependencies {
40-
compile fileTree(dir: external_lib_prefix + '/jar', include: ['**/*.jar'])
41-
compile(name: 'TangoUtils', ext: 'aar')
40+
compile (name: 'TangoUtils', ext: 'aar')
4241
compile (name: 'tango-ux-support-library', ext: 'aar')
4342
compile 'org.rajawali3d:rajawali:1.0.294-SNAPSHOT@aar'
4443
}

PointCloudJava/app/src/main/java/com/projecttango/experiments/javapointcloud/PointCloudRajawaliRenderer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public class PointCloudRajawaliRenderer extends RajawaliRenderer {
5151
private Points mPoints;
5252
private PointCloudManager mPointCloudManager;
5353

54-
5554
public PointCloudRajawaliRenderer(Context context, PointCloudManager pointCloudManager) {
5655
super(context);
5756
mTouchViewHandler = new TouchViewHandler(mContext, getCurrentCamera());
@@ -61,11 +60,11 @@ public PointCloudRajawaliRenderer(Context context, PointCloudManager pointCloudM
6160

6261
@Override
6362
protected void initScene() {
64-
mGrid = new Grid(100, 1);
63+
mGrid = new Grid(100, 1, 1, 0xFFCCCCCC);
6564
mGrid.setPosition(0, -1.3f, 0);
6665
getCurrentScene().addChild(mGrid);
6766

68-
mFrustumAxes = new FrustumAxes();
67+
mFrustumAxes = new FrustumAxes(3);
6968
getCurrentScene().addChild(mFrustumAxes);
7069

7170
mPoints = new Points(MAX_NUMBER_OF_POINTS);

TangoUtils/app/src/main/java/com/projecttango/rajawali/renderables/FrustumAxes.java

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,58 @@
1515
*/
1616
package com.projecttango.rajawali.renderables;
1717

18+
import android.graphics.Color;
19+
1820
import org.rajawali3d.Object3D;
21+
import org.rajawali3d.materials.Material;
1922
import org.rajawali3d.math.vector.Vector3;
23+
import org.rajawali3d.primitives.Line3D;
24+
25+
import java.util.Arrays;
26+
import java.util.Collections;
27+
import java.util.Stack;
2028

2129
/**
2230
*A primitive which represents a combination of Frustum and Axes.
2331
*/
24-
public class FrustumAxes extends Object3D {
25-
private Frustum mFrustum;
26-
private Axes mAxes;
27-
public FrustumAxes() {
28-
mFrustum = new Frustum(0.8f, 0.6f, 0.5f);
29-
addChild(mFrustum);
30-
mAxes = new Axes();
31-
addChild(mAxes);
32+
public class FrustumAxes extends Line3D {
33+
private static final float FRUSTUM_WIDTH = 0.8f;
34+
private static final float FRUSTUM_HEIGHT = 0.6f;
35+
private static final float FRUSTUM_DEPTH = 0.5f;
36+
37+
public FrustumAxes(float thickness) {
38+
super(makePoints(), thickness, makeColors());
39+
Material material = new Material();
40+
material.useVertexColors(true);
41+
setMaterial(material);
42+
}
43+
44+
private static Stack<Vector3> makePoints() {
45+
Vector3 o = new Vector3(0, 0, 0);
46+
Vector3 a = new Vector3(-FRUSTUM_WIDTH / 2f, FRUSTUM_HEIGHT / 2f, -FRUSTUM_DEPTH);
47+
Vector3 b = new Vector3(FRUSTUM_WIDTH / 2f, FRUSTUM_HEIGHT / 2f, -FRUSTUM_DEPTH);
48+
Vector3 c = new Vector3(FRUSTUM_WIDTH / 2f, -FRUSTUM_HEIGHT / 2f, -FRUSTUM_DEPTH);
49+
Vector3 d = new Vector3(-FRUSTUM_WIDTH / 2f, -FRUSTUM_HEIGHT / 2f, -FRUSTUM_DEPTH);
50+
51+
Vector3 x = new Vector3(1, 0, 0);
52+
Vector3 y = new Vector3(0, 1, 0);
53+
Vector3 z = new Vector3(0, 0, 1);
54+
55+
Stack<Vector3> points = new Stack<Vector3>();
56+
Collections.addAll(points, new Vector3[]{o, x, o, y, o, z, o, a, b, o, b, c, o, c, d, o, d, a});
57+
58+
return points;
59+
}
60+
61+
private static int[] makeColors() {
62+
int[] colors = new int[18];
63+
Arrays.fill(colors, Color.BLACK);
64+
colors[0] = Color.RED;
65+
colors[1] = Color.RED;
66+
colors[2] = Color.GREEN;
67+
colors[3] = Color.GREEN;
68+
colors[4] = Color.BLUE;
69+
colors[5] = Color.BLUE;
70+
return colors;
3271
}
3372
}

TangoUtils/app/src/main/java/com/projecttango/rajawali/renderables/Grid.java

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,47 @@
1515
*/
1616
package com.projecttango.rajawali.renderables;
1717

18-
import android.graphics.Color;
18+
import android.opengl.GLES20;
1919

20-
import org.rajawali3d.Object3D;
2120
import org.rajawali3d.materials.Material;
2221
import org.rajawali3d.math.vector.Vector3;
2322
import org.rajawali3d.primitives.Line3D;
2423

2524
import java.util.Stack;
2625

2726
/**
28-
* Rajawali primitive object which represents the 'floor' of the current scene.
27+
* Rajawali object which represents the 'floor' of the current scene.
2928
* This is a static grid placed in the scene to provide perspective in the
3029
* various views.
3130
*/
32-
public class Grid extends Object3D {
33-
public Grid(int size, int step) {
34-
Material m = new Material();
35-
m.setColor(Color.BLACK);
36-
37-
Line3D line;
38-
Stack<Vector3> points;
31+
public class Grid extends Line3D {
32+
public Grid(int size, int step, float thickness, int color) {
33+
super(calculatePoints(size, step), thickness, color);
34+
Material material = new Material();
35+
material.setColor(color);
36+
this.setMaterial(material);
37+
}
38+
private static Stack<Vector3> calculatePoints(int size, int step) {
39+
Stack<Vector3> points = new Stack<Vector3>();
3940

4041
// Rows
41-
for (float i=-size/2f; i <= size/2f; i += step) {
42-
points = new Stack<Vector3>();
43-
points.add(new Vector3(i, 0, -size/2f));
44-
points.add(new Vector3(i, 0, size/2f));
45-
line = new Line3D(points, 1f);
46-
line.setMaterial(m);
47-
addChild(line);
42+
for (float i = -size / 2f; i <= size / 2f; i += step) {
43+
points.add(new Vector3(i, 0 ,-size / 2f));
44+
points.add(new Vector3(i, 0, size / 2f));
4845
}
4946

5047
// Columns
51-
for (float i=-size/2f; i <= size/2f; i += step) {
52-
points = new Stack<Vector3>();
53-
points.add(new Vector3(-size/2f, 0, i));
54-
points.add(new Vector3(size/2f, 0, i));
55-
line = new Line3D(points, 1f);
56-
line.setMaterial(m);
57-
addChild(line);
48+
for (float i = -size / 2f; i <= size / 2f; i += step) {
49+
points.add(new Vector3(-size / 2f, 0, i));
50+
points.add(new Vector3(size / 2f, 0, i));
5851
}
5952

60-
setMaterial(m);
53+
return points;
54+
}
55+
56+
@Override
57+
protected void init(boolean createVBOs) {
58+
super.init(createVBOs);
59+
setDrawingMode(GLES20.GL_LINES);
6160
}
6261
}

0 commit comments

Comments
 (0)