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

Commit

Permalink
release zaniah
Browse files Browse the repository at this point in the history
  • Loading branch information
jguomoto committed Nov 4, 2016
1 parent 2884481 commit dce7dfd
Show file tree
Hide file tree
Showing 21 changed files with 392 additions and 135 deletions.
Binary file modified TangoReleaseLibs/aar/tango-ux-support-library.aar
Binary file not shown.
Binary file modified TangoReleaseLibs/aar/tango_support_java_lib.aar
Binary file not shown.
Binary file modified TangoReleaseLibs/jar/tango_java_lib.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,7 @@ public void onDisplayAdded(int displayId) {}
@Override
public void onDisplayChanged(int displayId) {
synchronized (this) {
Display display = getWindowManager().getDefaultDisplay();
Camera.CameraInfo colorCameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(COLOR_CAMERA_ID, colorCameraInfo);

mColorCameraToDisplayAndroidRotation =
getColorCameraToDisplayAndroidRotation(display.getRotation(),
colorCameraInfo.orientation);
mRenderer.updateColorCameraTextureUv(mColorCameraToDisplayAndroidRotation);
setAndroidOrientation();
}
}

Expand All @@ -130,6 +123,9 @@ public void onDisplayRemoved(int displayId) {}
protected void onResume() {
super.onResume();
mSurfaceView.onResume();

setAndroidOrientation();

// Set render mode to RENDERMODE_CONTINUOUSLY to force getting onDraw callbacks until the
// Tango service is properly set-up and we start getting onFrameAvailable callbacks.
mSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
Expand Down Expand Up @@ -455,4 +451,18 @@ private static float[] projectionMatrixFromCameraIntrinsics(TangoCameraIntrinsic
near, far);
return m;
}

/**
* Set the color camera background texture rotation and save the camera to display rotation.
*/
private void setAndroidOrientation() {
Display display = getWindowManager().getDefaultDisplay();
Camera.CameraInfo colorCameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(COLOR_CAMERA_ID, colorCameraInfo);

mColorCameraToDisplayAndroidRotation =
getColorCameraToDisplayAndroidRotation(display.getRotation(),
colorCameraInfo.orientation);
mRenderer.updateColorCameraTextureUv(mColorCameraToDisplayAndroidRotation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/
package com.projecttango.examples.java.augmentedreality;

import com.google.atap.tangoservice.TangoCameraIntrinsics;
import com.google.atap.tangoservice.TangoPoseData;

import android.content.Context;
Expand All @@ -29,7 +28,6 @@
import org.rajawali3d.animation.Animation;
import org.rajawali3d.animation.Animation3D;
import org.rajawali3d.animation.EllipticalOrbitAnimation3D;
import org.rajawali3d.animation.RotateAroundAnimation3D;
import org.rajawali3d.animation.RotateOnAxisAnimation;
import org.rajawali3d.lights.DirectionalLight;
import org.rajawali3d.materials.Material;
Expand Down Expand Up @@ -66,7 +64,7 @@ public class AugmentedRealityRenderer extends RajawaliRenderer {
// Keeps track of whether the scene camera has been configured.
private boolean mSceneCameraConfigured;

private ScreenQuad mBackgroundQuad = new ScreenQuad();
private ScreenQuad mBackgroundQuad;

public AugmentedRealityRenderer(Context context) {
super(context);
Expand All @@ -79,7 +77,10 @@ protected void initScene() {
Material tangoCameraMaterial = new Material();
tangoCameraMaterial.setColorInfluence(0);

mBackgroundQuad.getGeometry().setTextureCoords(textureCoords0);
if (mBackgroundQuad == null) {
mBackgroundQuad = new ScreenQuad();
mBackgroundQuad.getGeometry().setTextureCoords(textureCoords0);
}
// We need to use Rajawali's {@code StreamingTexture} since it sets up the texture
// for GL_TEXTURE_EXTERNAL_OES rendering
mTangoCameraTexture =
Expand Down Expand Up @@ -166,6 +167,10 @@ protected void initScene() {
* between landscape and portrait mode.
*/
public void updateColorCameraTextureUv(int rotation){
if (mBackgroundQuad == null) {
mBackgroundQuad = new ScreenQuad();
}

switch (rotation) {
case Surface.ROTATION_90:
mBackgroundQuad.getGeometry().setTextureCoords(textureCoords90);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ private WallMeasurement doWallMeasurement(float u, float v, double rgbTimestamp)
TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION,
TangoPoseData.COORDINATE_FRAME_CAMERA_DEPTH,
TangoSupport.TANGO_SUPPORT_ENGINE_OPENGL,
TangoSupport.TANGO_SUPPORT_ENGINE_TANGO);
TangoSupport.TANGO_SUPPORT_ENGINE_TANGO, 0);
if (transform.statusCode == TangoPoseData.POSE_VALID) {
// Update the AR object location.
float[] planeFitTransform = calculatePlaneTransform(
Expand Down Expand Up @@ -532,7 +532,7 @@ public void updateMeasurements() {
TangoPoseData.COORDINATE_FRAME_AREA_DESCRIPTION,
TangoPoseData.COORDINATE_FRAME_CAMERA_DEPTH,
TangoSupport.TANGO_SUPPORT_ENGINE_OPENGL,
TangoSupport.TANGO_SUPPORT_ENGINE_TANGO);
TangoSupport.TANGO_SUPPORT_ENGINE_TANGO, 0);
if (transform.statusCode == TangoPoseData.POSE_VALID) {
wallMeasurement.update(transform.matrix);
mRenderer.addWallMeasurement(wallMeasurement);
Expand Down
2 changes: 1 addition & 1 deletion java_green_screen_example/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ android {
defaultConfig {
applicationId "com.projecttango.examples.java.greenscreen"
minSdkVersion 19
targetSdkVersion 23
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
Expand Down
3 changes: 2 additions & 1 deletion java_green_screen_example/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
android:required="true" />
<activity
android:name="com.projecttango.examples.java.greenscreen.GreenScreenActivity"
android:label="@string/app_name_long" >
android:label="@string/app_name_long"
android:screenOrientation="landscape" >
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
3 changes: 2 additions & 1 deletion java_mesh_builder_example/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
android:required="true" />
<activity
android:name=".MeshBuilderActivity"
android:label="@string/app_name_long" >
android:label="@string/app_name_long"
android:screenOrientation="landscape">
<intent-filter android:label="@string/app_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import android.opengl.Matrix;
import android.os.Bundle;
import android.util.Log;
import android.view.Display;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
Expand Down Expand Up @@ -68,6 +69,8 @@ public class MeshBuilderActivity extends Activity {
private boolean mIsPaused;
private boolean mClearMeshes;

private int mDeviceToDisplayRotation = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -83,6 +86,10 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
protected void onResume() {
super.onResume();

Display display = getWindowManager().getDefaultDisplay();
mDeviceToDisplayRotation = display.getRotation();

mSurfaceView.onResume();
mSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
// Check if it has permissions.
Expand Down Expand Up @@ -257,37 +264,44 @@ public void preRender() {
// onRender callbacks had a chance to run and before scene objects are rendered
// into the scene.

// Synchronize against disconnecting while using the service.
synchronized (MeshBuilderActivity.this) {
// Don't execute any tango API actions if we're not connected to the service
if (!mIsConnected) {
return;
}
try {
// Synchronize against disconnecting while using the service.
synchronized (MeshBuilderActivity.this) {
// Don't execute any tango API actions if we're not connected to the service
if (!mIsConnected) {
return;
}

// Set-up scene camera projection to match RGB camera intrinsics
if (!mRenderer.isSceneCameraConfigured()) {
mRenderer.setProjectionMatrix(
projectionMatrixFromCameraIntrinsics(mIntrinsics));
}
// Set-up scene camera projection to match RGB camera intrinsics
if (!mRenderer.isSceneCameraConfigured()) {
mRenderer.setProjectionMatrix(
projectionMatrixFromCameraIntrinsics(mIntrinsics));
}

// Calculate the camera color pose at the camera frame update time in
// OpenGL engine.
TangoSupport.TangoMatrixTransformData ssTdev =
TangoSupport.getMatrixTransformAtTime(
0.0, TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,
TangoPoseData.COORDINATE_FRAME_DEVICE,
TangoSupport.TANGO_SUPPORT_ENGINE_TANGO,
TangoSupport.TANGO_SUPPORT_ENGINE_OPENGL);

if (ssTdev.statusCode == TangoPoseData.POSE_VALID) {
// Update the camera pose from the renderer
mRenderer.updateViewMatrix(ssTdev.matrix);
} else {
Log.w(TAG, "Can't get last camera pose");
// Calculate the camera color pose at the camera frame update time in
// OpenGL engine.
TangoSupport.TangoMatrixTransformData ssTdev =
TangoSupport.getMatrixTransformAtTime(
0.0, TangoPoseData.COORDINATE_FRAME_START_OF_SERVICE,
TangoPoseData.COORDINATE_FRAME_DEVICE,
TangoSupport.TANGO_SUPPORT_ENGINE_TANGO,
TangoSupport.TANGO_SUPPORT_ENGINE_OPENGL,
mDeviceToDisplayRotation);

if (ssTdev.statusCode == TangoPoseData.POSE_VALID) {
// Update the camera pose from the renderer
mRenderer.updateViewMatrix(ssTdev.matrix);
} else {
Log.w(TAG, "Can't get last camera pose");
}
}
// Update mesh.
updateMeshMap();
} catch (TangoErrorException e) {
Log.w(TAG, "Tango API call error within the OpenGL thread", e);
} catch (TangoInvalidException e) {
Log.w(TAG, "Tango API call error within the OpenGL thread", e);
}
// Update mesh.
updateMeshMap();
}
});
mSurfaceView.setRenderer(mRenderer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
*/
package com.projecttango.examples.java.meshbuilder;

import static android.opengl.GLES20.GL_TRIANGLES;
import static android.opengl.GLES20.GL_UNSIGNED_INT;
import static android.opengl.GLES20.glDrawElements;

import com.google.atap.tango.mesh.TangoMesh;

import android.annotation.SuppressLint;
Expand Down Expand Up @@ -105,7 +101,7 @@ private void drawMesh(MeshSegment mesh) {
GLES20.glEnableVertexAttribArray(mMeshMaterial.getPosHandle());
// Draw the mesh
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, mesh.indexBufferId);
glDrawElements(GL_TRIANGLES, mesh.numFaces * 3, GL_UNSIGNED_INT, 0);
GLES20.glDrawElements(GLES20.GL_TRIANGLES, mesh.numFaces * 3, GLES20.GL_UNSIGNED_INT, 0);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package com.projecttango.examples.java.meshbuilder;

import static android.opengl.GLES20.glUseProgram;

import android.opengl.GLES20;

/**
Expand Down Expand Up @@ -59,7 +57,7 @@ public int getPosHandle() {

private void loadHandles() {
mShaderProgram = OpenGlHelper.createProgram(mVss, mFss);
glUseProgram(mShaderProgram);
GLES20.glUseProgram(mShaderProgram);

mPosHandle = GLES20.glGetAttribLocation(mShaderProgram, "a_Position");
mAttributeColorHandle = GLES20.glGetAttribLocation(mShaderProgram, "a_Color");
Expand All @@ -72,7 +70,7 @@ public void start(float[] mvpMatrix) {
if (!mLoaded) {
loadHandles();
}
glUseProgram(mShaderProgram);
GLES20.glUseProgram(mShaderProgram);
// Send the MVP Matrix.
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mvpMatrix, 0);
}
Expand Down
Loading

0 comments on commit dce7dfd

Please sign in to comment.