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

Commit 338cb96

Browse files
committed
Merge pull request #55 from googlesamples/release-electra
release electra.
2 parents e4ea49e + 651c98b commit 338cb96

File tree

31 files changed

+589
-2129
lines changed

31 files changed

+589
-2129
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,13 @@ protected void onCreate(Bundle savedInstanceState) {
135135
// Configure OpenGL renderer
136136
mRenderer = setupGLViewAndRenderer();
137137

138-
mPoses = new TangoPoseData[3];
138+
}
139139

140-
// Set the number of loop closures to zero at start.
140+
/**
141+
* Initializes pose data we keep track of. To be done
142+
*/
143+
private void initializePoseData() {
144+
mPoses = new TangoPoseData[3];
141145
mStart2DevicePoseCount = 0;
142146
mAdf2DevicePoseCount = 0;
143147
mAdf2StartPoseCount = 0;
@@ -173,6 +177,9 @@ protected void onPause() {
173177
protected void onResume() {
174178
super.onResume();
175179

180+
// Reset pose data and start counting from resume.
181+
initializePoseData();
182+
176183
// Clear the relocalization state: we don't know where the device has been since our app was paused.
177184
mIsRelocalized = false;
178185

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

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

2323
import com.google.atap.tangoservice.TangoPoseData;
2424
import com.projecttango.rajawali.Pose;
25-
import com.projecttango.rajawali.ScenePoseCalcuator;
25+
import com.projecttango.rajawali.ScenePoseCalculator;
2626
import com.projecttango.rajawali.TouchViewHandler;
2727
import com.projecttango.rajawali.renderables.FrustumAxes;
2828
import com.projecttango.rajawali.renderables.Grid;
@@ -115,7 +115,7 @@ protected void onRender(long ellapsedRealtime, double deltaTime) {
115115
* updated.
116116
*/
117117
public synchronized void updateDevicePose(TangoPoseData tangoPoseData, boolean isRelocalized) {
118-
mDevicePose = ScenePoseCalcuator.toOpenGLPose(tangoPoseData);
118+
mDevicePose = ScenePoseCalculator.toOpenGLPose(tangoPoseData);
119119
mIsRelocalized = isRelocalized;
120120
mPoseUpdated = true;
121121
}

AugmentedRealitySample/app/src/main/java/com/projecttango/experiments/augmentedrealitysample/AugmentedRealityActivity.java

Lines changed: 173 additions & 102 deletions
Large diffs are not rendered by default.

AugmentedRealitySample/app/src/main/java/com/projecttango/experiments/augmentedrealitysample/AugmentedRealityRenderer.java

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.projecttango.experiments.augmentedrealitysample;
1717

1818
import android.content.Context;
19+
1920
import android.view.MotionEvent;
2021

2122
import com.google.atap.tangoservice.TangoPoseData;
@@ -29,28 +30,32 @@
2930
import org.rajawali3d.math.vector.Vector3;
3031
import org.rajawali3d.primitives.Cube;
3132

33+
import com.projecttango.rajawali.DeviceExtrinsics;
3234
import com.projecttango.rajawali.Pose;
35+
import com.projecttango.rajawali.ScenePoseCalculator;
3336
import com.projecttango.rajawali.ar.TangoRajawaliRenderer;
3437

3538
/**
36-
* Very simple example augmented reality renderer which displays two objects in
37-
* a fixed position in the world and the uses the Tango position tracking to
38-
* keep them in place.
39-
* <p/>
39+
* Very simple example augmented reality renderer which displays a cube fixed in place.
40+
* Whenever the user clicks on the screen, the cube is placed flush with the surface detected
41+
* with the depth camera in the position clicked.
42+
*
4043
* This follows the same development model than any regular Rajawali application
4144
* with the following peculiarities:
4245
* - It extends <code>TangoRajawaliArRenderer</code>.
4346
* - It calls <code>super.initScene()</code> in the initialization.
44-
* - It doesn't do anything with the camera, since that is handled automatically
45-
* by Tango.
47+
* - When an updated pose for the object is obtained after a user click, the object pose is updated
48+
* in the render loop
49+
* - The associated AugmentedRealityActivity is taking care of updating the camera pose to match
50+
* the displayed RGB camera texture and produce the AR effect through a Scene Frame Callback
51+
* (@see AugmentedRealityActivity)
4652
*/
4753
public class AugmentedRealityRenderer extends TangoRajawaliRenderer {
4854
private static final float CUBE_SIDE_LENGTH = 0.5f;
4955

50-
private Pose mPlanePose;
51-
private boolean mPlanePoseUpdated = false;
52-
5356
private Object3D mObject;
57+
private Pose mObjectPose;
58+
private boolean mObjectPoseUpdated = false;
5459

5560
public AugmentedRealityRenderer(Context context) {
5661
super(context);
@@ -93,38 +98,49 @@ protected void initScene() {
9398

9499
@Override
95100
protected void onRender(long elapsedRealTime, double deltaTime) {
96-
super.onRender(elapsedRealTime, deltaTime);
97-
101+
// Update the AR object if necessary
102+
// Synchronize against concurrent access with the setter below.
98103
synchronized (this) {
99-
if (mPlanePoseUpdated) {
100-
mPlanePoseUpdated = false;
104+
if (mObjectPoseUpdated) {
101105
// Place the 3D object in the location of the detected plane.
102-
mObject.setPosition(mPlanePose.getPosition());
103-
mObject.setOrientation(mPlanePose.getOrientation());
106+
mObject.setPosition(mObjectPose.getPosition());
107+
mObject.setOrientation(mObjectPose.getOrientation());
104108
// Move it forward by half of the size of the cube to make it
105109
// flush with the plane surface.
106110
mObject.moveForward(CUBE_SIDE_LENGTH / 2.0f);
111+
mObjectPoseUpdated = false;
107112
}
108113
}
114+
115+
super.onRender(elapsedRealTime, deltaTime);
116+
}
117+
118+
/**
119+
* Save the updated plane fit pose to update the AR object on the next render pass.
120+
* This is synchronized against concurrent access in the render loop above.
121+
*/
122+
public synchronized void updateObjectPose(TangoPoseData planeFitPose) {
123+
mObjectPose = ScenePoseCalculator.toOpenGLPose(planeFitPose);
124+
mObjectPoseUpdated = true;
109125
}
110126

111127
/**
112-
* Update the 3D object based on the provided measurement point, normal (in
113-
* depth frame) and device pose at the time the point and normal were
114-
* acquired.
128+
* Update the scene camera based on the provided pose in Tango start of service frame.
129+
* The device pose should match the pose of the device at the time the last rendered RGB
130+
* frame, which can be retrieved with this.getTimestamp();
131+
*
132+
* NOTE: This must be called from the OpenGL render thread - it is not thread safe.
115133
*/
116-
public synchronized void updateObjectPose(double[] point, double[] normal,
117-
TangoPoseData devicePose) {
118-
mPlanePose = mScenePoseCalcuator.planeFitToOpenGLPose(point, normal,
119-
devicePose);
120-
mPlanePoseUpdated = true;
134+
public void updateRenderCameraPose(TangoPoseData devicePose, DeviceExtrinsics extrinsics) {
135+
Pose cameraPose = ScenePoseCalculator.toOpenGlCameraPose(devicePose, extrinsics);
136+
getCurrentCamera().setRotation(cameraPose.getOrientation());
137+
getCurrentCamera().setPosition(cameraPose.getPosition());
121138
}
122139

123140
@Override
124141
public void onOffsetsChanged(float xOffset, float yOffset,
125142
float xOffsetStep, float yOffsetStep,
126143
int xPixelOffset, int yPixelOffset) {
127-
128144
}
129145

130146
@Override

AugmentedRealitySample/app/src/main/java/com/projecttango/experiments/augmentedrealitysample/PointCloudManager.java

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

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

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

2323
import com.google.atap.tangoservice.TangoPoseData;
2424
import com.projecttango.rajawali.Pose;
25+
import com.projecttango.rajawali.ScenePoseCalculator;
2526
import com.projecttango.rajawali.TouchViewHandler;
2627
import com.projecttango.rajawali.renderables.FrustumAxes;
2728
import com.projecttango.rajawali.renderables.Grid;
28-
import com.projecttango.rajawali.ScenePoseCalcuator;
2929
import com.projecttango.rajawali.renderables.Trajectory;
3030

3131
import org.rajawali3d.math.Quaternion;
@@ -37,7 +37,7 @@
3737
*/
3838
public class MotionTrackingRajawaliRenderer extends RajawaliRenderer {
3939

40-
private final String TAG = ScenePoseCalcuator.class.getSimpleName();
40+
private final String TAG = MotionTrackingRajawaliRenderer.class.getSimpleName();
4141

4242
// Only add line segments to the trajectory if the deviced moved more than THRESHOLD meters
4343
private static final double THRESHOLD = 0.002f;
@@ -104,7 +104,7 @@ protected void onRender(long ellapsedRealtime, double deltaTime) {
104104
* concurrent access from the OpenGL thread above.
105105
*/
106106
public synchronized void updateDevicePose(TangoPoseData tangoPoseData) {
107-
mDevicePose = ScenePoseCalcuator.toOpenGLPose(tangoPoseData);
107+
mDevicePose = ScenePoseCalculator.toOpenGLPose(tangoPoseData);
108108
mPoseUpdated = true;
109109
}
110110

PointCloudJava/app/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ repositories{
4040

4141
dependencies {
4242
compile (name: 'tango-ux-support-library', ext: 'aar')
43+
compile (name: 'tango_support_java_lib', ext: 'aar')
4344
compile 'org.rajawali3d:rajawali:1.0.294-SNAPSHOT@aar'
4445
compile project(':TangoUtils')
4546
}

0 commit comments

Comments
 (0)