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

Commit 129691b

Browse files
committed
Merge pull request #28 from googlesamples/release-nash
release-nash
2 parents 3827954 + 28e9e13 commit 129691b

17 files changed

Lines changed: 127 additions & 58 deletions

File tree

3.67 KB
Binary file not shown.

AreaLearningJava/src/com/projecttango/experiments/javaarealearning/ALRenderer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class ALRenderer extends Renderer implements GLSurfaceView.Renderer {
4545
private CameraFrustum mCameraFrustum;
4646
private CameraFrustumAndAxis mCameraFrustumAndAxis;
4747
private Grid mFloorGrid;
48-
48+
private boolean mIsValid = false;
4949
@Override
5050
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
5151
// Set background color and enable depth testing
@@ -63,6 +63,7 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
6363
Matrix.setIdentityM(mViewMatrix, 0);
6464
Matrix.setLookAtM(mViewMatrix, 0, 5f, 5f, 5f, 0f, 0f, 0f, 0f, 1f, 0f);
6565
mCameraFrustumAndAxis.setModelMatrix(getModelMatCalculator().getModelMatrix());
66+
mIsValid = true;
6667
}
6768

6869
@Override
@@ -99,5 +100,9 @@ public Trajectory getBlueTrajectory() {
99100
public Trajectory getGreenTrajectory() {
100101
return mGreenTrajectory;
101102
}
103+
104+
public boolean isValid(){
105+
return mIsValid;
106+
}
102107

103108
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public void onPoseAvailable(TangoPoseData pose) {
274274
mAdf2DevicePoseDelta = (pose.timestamp - mAdf2DevicePreviousPoseTimeStamp)
275275
* SECONDS_TO_MILLI;
276276
mAdf2DevicePreviousPoseTimeStamp = pose.timestamp;
277-
if (mIsRelocalized) {
277+
if (mIsRelocalized && mRenderer.isValid()) {
278278
updateRenderer = true;
279279
mRenderer.getGreenTrajectory().updateTrajectory(translation);
280280
}
@@ -292,7 +292,7 @@ public void onPoseAvailable(TangoPoseData pose) {
292292
mStart2DevicePoseDelta = (pose.timestamp - mStart2DevicePreviousPoseTimeStamp)
293293
* SECONDS_TO_MILLI;
294294
mStart2DevicePreviousPoseTimeStamp = pose.timestamp;
295-
if (!mIsRelocalized) {
295+
if (!mIsRelocalized && mRenderer.isValid()) {
296296
updateRenderer = true;
297297

298298
synchronized (mRenderer.getBlueTrajectory()) {
@@ -324,7 +324,7 @@ public void onPoseAvailable(TangoPoseData pose) {
324324

325325
// Update the trajectory, model matrix, and view matrix, then
326326
// render the scene again
327-
if (updateRenderer) {
327+
if (updateRenderer && mRenderer.isValid()) {
328328
mRenderer.getModelMatCalculator().updateModelMatrix(translation,
329329
pose.getRotationAsFloats());
330330
mRenderer.updateViewMatrix();
3.67 KB
Binary file not shown.

MotionTrackingJava/src/com/projecttango/experiments/javamotiontracking/MTGLRenderer.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class MTGLRenderer extends Renderer implements GLSurfaceView.Renderer {
4444
private CameraFrustum mCameraFrustum;
4545
private CameraFrustumAndAxis mCameraFrustumAndAxis;
4646
private Grid mFloorGrid;
47-
47+
private boolean mIsValid = false;
4848
@Override
4949
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
5050

@@ -62,6 +62,7 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
6262
Matrix.setIdentityM(mViewMatrix, 0);
6363
Matrix.setLookAtM(mViewMatrix, 0, 5f, 5f, 5f, 0f, 0f, 0f, 0f, 1f, 0f);
6464
mCameraFrustumAndAxis.setModelMatrix(getModelMatCalculator().getModelMatrix());
65+
mIsValid = true;
6566

6667
}
6768

@@ -94,5 +95,8 @@ public CameraFrustumAndAxis getCameraFrustumAndAxis() {
9495
public Trajectory getTrajectory() {
9596
return mTrajectory;
9697
}
97-
98+
99+
public boolean isValid(){
100+
return mIsValid;
101+
}
98102
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ public void onPoseAvailable(final TangoPoseData pose) {
178178
// Update the OpenGL renderable objects with the new Tango Pose
179179
// data
180180
float[] translation = pose.getTranslationAsFloats();
181+
if(!mRenderer.isValid()){
182+
return;
183+
}
181184
mRenderer.getTrajectory().updateTrajectory(translation);
182185
mRenderer.getModelMatCalculator().updateModelMatrix(translation,
183186
pose.getRotationAsFloats());
3.67 KB
Binary file not shown.

PointCloudJava/src/com/projecttango/experiments/javapointcloud/PCRenderer.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class PCRenderer extends Renderer implements GLSurfaceView.Renderer {
4646
private Grid mGrid;
4747
private CameraFrustumAndAxis mCameraFrustumAndAxis;
4848
private int mMaxDepthPoints;
49-
49+
private boolean mIsValid = false;
5050
public PCRenderer(int maxDepthPoints) {
5151
mMaxDepthPoints = maxDepthPoints;
5252
}
@@ -61,6 +61,7 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
6161
Matrix.setIdentityM(mViewMatrix, 0);
6262
Matrix.setLookAtM(mViewMatrix, 0, 5f, 5f, 5f, 0f, 0f, 0f, 0f, 1f, 0f);
6363
mCameraFrustumAndAxis.setModelMatrix(getModelMatCalculator().getModelMatrix());
64+
mIsValid = true;
6465
}
6566

6667
@Override
@@ -86,4 +87,8 @@ public void onDrawFrame(GL10 gl) {
8687
public PointCloud getPointCloud() {
8788
return mPointCloud;
8889
}
90+
91+
public boolean isValid(){
92+
return mIsValid;
93+
}
8994
}

PointCloudJava/src/com/projecttango/experiments/javapointcloud/PointCloudActivity.java

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ protected void onCreate(Bundle savedInstanceState) {
116116
mThirdPersonButton.setOnClickListener(this);
117117
mTopDownButton = (Button) findViewById(R.id.top_down_button);
118118
mTopDownButton.setOnClickListener(this);
119-
120119
mTango = new Tango(this);
121120
mConfig = new TangoConfig();
122121
mConfig = mTango.getConfig(TangoConfig.CONFIG_TYPE_CURRENT);
@@ -279,6 +278,9 @@ public void onPoseAvailable(final TangoPoseData pose) {
279278
}
280279
count++;
281280
mPreviousPoseStatus = pose.statusCode;
281+
if(!mRenderer.isValid()){
282+
return;
283+
}
282284
mRenderer.getModelMatCalculator().updateModelMatrix(
283285
pose.getTranslationAsFloats(), pose.getRotationAsFloats());
284286
mRenderer.updateViewMatrix();
@@ -295,28 +297,20 @@ public void onXyzIjAvailable(final TangoXyzIjData xyzIj) {
295297
mPointCloudFrameDelta = (mCurrentTimeStamp - mXyIjPreviousTimeStamp)
296298
* SECS_TO_MILLISECS;
297299
mXyIjPreviousTimeStamp = mCurrentTimeStamp;
298-
mPointCount = xyzIj.xyzCount;
299-
byte[] buffer = new byte[xyzIj.xyzCount * 3 * 4];
300-
// TODO: Use getXYZBuffer() call instead of parcel file directly.
301-
FileInputStream fileStream = new FileInputStream(xyzIj.xyzParcelFileDescriptor
302-
.getFileDescriptor());
303-
try {
304-
fileStream.read(buffer, xyzIj.xyzParcelFileDescriptorOffset, buffer.length);
305-
fileStream.close();
306-
} catch (IOException e) {
307-
e.printStackTrace();
308-
}
309300
try {
310301
TangoPoseData pointCloudPose = mTango.getPoseAtTime(mCurrentTimeStamp,
311-
framePairs.get(0));
312-
313-
mRenderer.getPointCloud().UpdatePoints(buffer, xyzIj.xyzCount);
302+
framePairs.get(0));
303+
mPointCount = xyzIj.xyzCount;
304+
if(!mRenderer.isValid()){
305+
return;
306+
}
307+
mRenderer.getPointCloud().UpdatePoints(xyzIj.xyz);
314308
mRenderer.getModelMatCalculator().updatePointCloudModelMatrix(
315-
pointCloudPose.getTranslationAsFloats(),
316-
pointCloudPose.getRotationAsFloats());
309+
pointCloudPose.getTranslationAsFloats(),
310+
pointCloudPose.getRotationAsFloats());
317311
mRenderer.getPointCloud().setModelMatrix(
318312
mRenderer.getModelMatCalculator().getPointCloudModelMatrixCopy());
319-
} catch (TangoErrorException e) {
313+
} catch (TangoErrorException e) {
320314
Toast.makeText(getApplicationContext(), R.string.TangoError,
321315
Toast.LENGTH_SHORT).show();
322316
} catch (TangoInvalidException e) {

QuickstartJava/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
android:label="@string/app_name"
3232
android:theme="@style/AppTheme" >
3333
<activity
34-
android:name="com.projecttango.quickstartjava.MainActivity"
34+
android:name="com.projecttango.experiments.quickstartjava.MainActivity"
3535
android:label="@string/app_name" >
3636
<intent-filter>
3737
<action android:name="android.intent.action.MAIN" />

0 commit comments

Comments
 (0)