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 #43 from googlesamples/release-schur
Browse files Browse the repository at this point in the history
release-schur
  • Loading branch information
jguomoto committed Jul 23, 2015
2 parents f8880cf + 41acd27 commit e672ad8
Show file tree
Hide file tree
Showing 26 changed files with 1,923 additions and 1,832 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,21 @@
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

/**
* AugmentedRealityView renders graphic content.
*/
public class AugmentedRealityView implements GLSurfaceView.Renderer {

public boolean isAutoRecovery;
public AugmentedRealityActivity activity;

public void onDrawFrame(GL10 gl) {
TangoJNINative.render();
}
// AugmentedRealityRenderer renders graphic content. This includes the ground grid,
// camera frustum, camera axis, and trajectory based on the Tango device's pose.
public class AugmentedRealityRenderer implements GLSurfaceView.Renderer {
// Render loop of the Gl context.
public void onDrawFrame(GL10 gl) {
TangoJNINative.render();
}

public void onSurfaceChanged(GL10 gl, int width, int height) {
TangoJNINative.connectTexture();
TangoJNINative.connectService();
TangoJNINative.setupViewport(width, height);
}
// Called when the surface size changes.
public void onSurfaceChanged(GL10 gl, int width, int height) {
TangoJNINative.setupGraphic(width, height);
}

public void onSurfaceCreated(GL10 gl, EGLConfig config) {
TangoJNINative.setupGraphic();
TangoJNINative.initialize(activity);
TangoJNINative.setupConfig(isAutoRecovery);
}
// Called when the surface is created or recreated.
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
TangoJNINative.initGlContent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,66 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.projecttango.experiments.nativeaugmentedreality;

/**
* Interfaces between C and Java.
*/
// Interfaces between native C++ code and Java code.
public class TangoJNINative {
static {
System.loadLibrary("augmented_reality_jni_example");
}

public static native int initialize(AugmentedRealityActivity activity);
static {
System.loadLibrary("augmented_reality_jni_example");
}

public static native void setupConfig(boolean isAutoRecovery);
// Initialize the Tango Service, this function starts the communication
// between the application and Tango Service.
// The activity object is used for checking if the API version is outdated.
public static native int initialize(AugmentedRealityActivity activity);

public static native void connectTexture();
// Setup the configuration file of the Tango Service. We are also setting up
// the auto-recovery option from here.
public static native int setupConfig();

public static native int connectService();
// Connect the onPoseAvailable callback.
public static native int connectCallbacks();

public static native void disconnectService();
// Connect to the Tango Service.
// This function will start the Tango Service pipeline, in this case, it will
// start Motion Tracking.
public static native int connect();

public static native void onDestroy();
// Disconnect from the Tango Service, release all the resources that the app is
// holding from the Tango Service.
public static native void disconnect();

public static native void setupGraphic();
// Release all OpenGL resources that are allocated from the program.
public static native void freeGLContent();

public static native void setupViewport(int width, int height);
// Allocate OpenGL resources for rendering.
public static native void initGlContent();

public static native void render();
// Setup the view port width and height.
public static native void setupGraphic(int width, int height);

public static native void setCamera(int cameraIndex);
// Main render loop.
public static native void render();

public static native void resetMotionTracking();
// Set the render camera's viewing angle:
// first person, third person, or top down.
public static native void setCamera(int cameraIndex);

public static native byte updateStatus();
// Explicitly reset motion tracking and restart the pipeline.
// Note that this will cause motion tracking to re-initialize.
public static native void resetMotionTracking();

public static native String getPoseString();
// Get the latest pose string from our application for display in our debug UI.
public static native String getPoseString();

public static native String getVersionNumber();

public static native boolean getIsLocalized();
// Get the latest event string from our application for display in our debug UI.
public static native String getEventString();

public static native void updateARElement(int arElement, int interactionType);
// Get the TangoCore version from our application for display in our debug UI.
public static native String getVersionNumber();

public static native float startSetCameraOffset();

public static native float setCameraOffset(float rotX, float rotY, float zDistance);

public static native void placeObject();
// Pass touch events to the native layer.
public static native void onTouchEvent(int touchCount, int event0,
float x0, float y0, float x1, float y1);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2014 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.projecttango.experiments.nativeaugmentedreality;

import android.util.Log;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

// Util class provides handy utility functions.
public class Util {

// Checks if the calling app has the specified permission.
// It is recommended that an app check if it has a permission before trying
// to request it; this will save time by avoiding re-requesting permissions
// that have already been granted.

// @param context The context of the calling app.
// @param permissionType The type of permission to request; either
// PERMISSIONTYPE_MOTION_TRACKING or PERMISSIONTYPE_ADF_LOAD_SAVE.
// @return boolean Whether or not the permission was already granted.
public static boolean hasPermission(Context context, String permissionType){
Uri uri = Uri.parse("content://com.google.atap.tango.PermissionStatusProvider/" +
permissionType);
Cursor cursor = context.getContentResolver().query(uri, null, null, null, null);
if (cursor == null) {
return false;
} else {
return true;
}
}
}
8 changes: 6 additions & 2 deletions augmented-reality-jni-example/app/src/main/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,17 @@ LOCAL_MODULE := libaugmented_reality_jni_example
LOCAL_SHARED_LIBRARIES := tango_client_api
LOCAL_CFLAGS := -std=c++11

LOCAL_SRC_FILES := tango_augmented_reality.cpp \
tango_data.cpp \
LOCAL_SRC_FILES := augmented_reality_app.cc \
jni_interface.cc \
pose_data.cc \
scene.cc \
tango_event_data.cc \
$(PROJECT_ROOT_FROM_JNI)/tango-gl/axis.cpp \
$(PROJECT_ROOT_FROM_JNI)/tango-gl/camera.cpp \
$(PROJECT_ROOT_FROM_JNI)/tango-gl/conversions.cpp \
$(PROJECT_ROOT_FROM_JNI)/tango-gl/drawable_object.cpp \
$(PROJECT_ROOT_FROM_JNI)/tango-gl/frustum.cpp \
$(PROJECT_ROOT_FROM_JNI)/tango-gl/gesture_camera.cpp \
$(PROJECT_ROOT_FROM_JNI)/tango-gl/grid.cpp \
$(PROJECT_ROOT_FROM_JNI)/tango-gl/goal_marker.cpp \
$(PROJECT_ROOT_FROM_JNI)/tango-gl/line.cpp \
Expand Down
Loading

0 comments on commit e672ad8

Please sign in to comment.