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

Commit

Permalink
Merge pull request #55 from googlesamples/release-electra
Browse files Browse the repository at this point in the history
release electra.
  • Loading branch information
jguomoto committed Jan 13, 2016
2 parents e4ea49e + 651c98b commit 338cb96
Show file tree
Hide file tree
Showing 31 changed files with 589 additions and 2,129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,13 @@ protected void onCreate(Bundle savedInstanceState) {
// Configure OpenGL renderer
mRenderer = setupGLViewAndRenderer();

mPoses = new TangoPoseData[3];
}

// Set the number of loop closures to zero at start.
/**
* Initializes pose data we keep track of. To be done
*/
private void initializePoseData() {
mPoses = new TangoPoseData[3];
mStart2DevicePoseCount = 0;
mAdf2DevicePoseCount = 0;
mAdf2StartPoseCount = 0;
Expand Down Expand Up @@ -173,6 +177,9 @@ protected void onPause() {
protected void onResume() {
super.onResume();

// Reset pose data and start counting from resume.
initializePoseData();

// Clear the relocalization state: we don't know where the device has been since our app was paused.
mIsRelocalized = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

import com.google.atap.tangoservice.TangoPoseData;
import com.projecttango.rajawali.Pose;
import com.projecttango.rajawali.ScenePoseCalcuator;
import com.projecttango.rajawali.ScenePoseCalculator;
import com.projecttango.rajawali.TouchViewHandler;
import com.projecttango.rajawali.renderables.FrustumAxes;
import com.projecttango.rajawali.renderables.Grid;
Expand Down Expand Up @@ -115,7 +115,7 @@ protected void onRender(long ellapsedRealtime, double deltaTime) {
* updated.
*/
public synchronized void updateDevicePose(TangoPoseData tangoPoseData, boolean isRelocalized) {
mDevicePose = ScenePoseCalcuator.toOpenGLPose(tangoPoseData);
mDevicePose = ScenePoseCalculator.toOpenGLPose(tangoPoseData);
mIsRelocalized = isRelocalized;
mPoseUpdated = true;
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.projecttango.experiments.augmentedrealitysample;

import android.content.Context;

import android.view.MotionEvent;

import com.google.atap.tangoservice.TangoPoseData;
Expand All @@ -29,28 +30,32 @@
import org.rajawali3d.math.vector.Vector3;
import org.rajawali3d.primitives.Cube;

import com.projecttango.rajawali.DeviceExtrinsics;
import com.projecttango.rajawali.Pose;
import com.projecttango.rajawali.ScenePoseCalculator;
import com.projecttango.rajawali.ar.TangoRajawaliRenderer;

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

private Pose mPlanePose;
private boolean mPlanePoseUpdated = false;

private Object3D mObject;
private Pose mObjectPose;
private boolean mObjectPoseUpdated = false;

public AugmentedRealityRenderer(Context context) {
super(context);
Expand Down Expand Up @@ -93,38 +98,49 @@ protected void initScene() {

@Override
protected void onRender(long elapsedRealTime, double deltaTime) {
super.onRender(elapsedRealTime, deltaTime);

// Update the AR object if necessary
// Synchronize against concurrent access with the setter below.
synchronized (this) {
if (mPlanePoseUpdated) {
mPlanePoseUpdated = false;
if (mObjectPoseUpdated) {
// Place the 3D object in the location of the detected plane.
mObject.setPosition(mPlanePose.getPosition());
mObject.setOrientation(mPlanePose.getOrientation());
mObject.setPosition(mObjectPose.getPosition());
mObject.setOrientation(mObjectPose.getOrientation());
// Move it forward by half of the size of the cube to make it
// flush with the plane surface.
mObject.moveForward(CUBE_SIDE_LENGTH / 2.0f);
mObjectPoseUpdated = false;
}
}

super.onRender(elapsedRealTime, deltaTime);
}

/**
* Save the updated plane fit pose to update the AR object on the next render pass.
* This is synchronized against concurrent access in the render loop above.
*/
public synchronized void updateObjectPose(TangoPoseData planeFitPose) {
mObjectPose = ScenePoseCalculator.toOpenGLPose(planeFitPose);
mObjectPoseUpdated = true;
}

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

@Override
public void onOffsetsChanged(float xOffset, float yOffset,
float xOffsetStep, float yOffsetStep,
int xPixelOffset, int yPixelOffset) {

}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

import com.google.atap.tangoservice.TangoPoseData;
import com.projecttango.rajawali.Pose;
import com.projecttango.rajawali.ScenePoseCalculator;
import com.projecttango.rajawali.TouchViewHandler;
import com.projecttango.rajawali.renderables.FrustumAxes;
import com.projecttango.rajawali.renderables.Grid;
import com.projecttango.rajawali.ScenePoseCalcuator;
import com.projecttango.rajawali.renderables.Trajectory;

import org.rajawali3d.math.Quaternion;
Expand All @@ -37,7 +37,7 @@
*/
public class MotionTrackingRajawaliRenderer extends RajawaliRenderer {

private final String TAG = ScenePoseCalcuator.class.getSimpleName();
private final String TAG = MotionTrackingRajawaliRenderer.class.getSimpleName();

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

Expand Down
1 change: 1 addition & 0 deletions PointCloudJava/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ repositories{

dependencies {
compile (name: 'tango-ux-support-library', ext: 'aar')
compile (name: 'tango_support_java_lib', ext: 'aar')
compile 'org.rajawali3d:rajawali:1.0.294-SNAPSHOT@aar'
compile project(':TangoUtils')
}
Loading

0 comments on commit 338cb96

Please sign in to comment.