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 #47 from googlesamples/release-urquhart
Browse files Browse the repository at this point in the history
Release urquhart
  • Loading branch information
jguomoto committed Aug 21, 2015
2 parents b976b6c + 0f68665 commit 44d10f9
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 6 deletions.
3 changes: 2 additions & 1 deletion augmented-reality-jni-example/app/src/main/jni/scene.cc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ void Scene::Render(const glm::mat4& cur_pose_transformation) {
gesture_camera_->SetAnchorPosition(position);

frustum_->SetTransformationMatrix(cur_pose_transformation);

// Set the frustum scale to 4:3, this doesn't necessarily match the physical
// camera's aspect ratio, this is just for visualization purposes.
frustum_->SetScale(
glm::vec3(1.0f, camera_image_plane_ratio_, image_plane_distance_));
frustum_->Render(ar_camera_projection_matrix_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void PointCloudDrawable::Render(glm::mat4 projection_mat, glm::mat4 view_mat,
glVertexAttribPointer(vertices_handle_, 3, GL_FLOAT, GL_FALSE, 0, nullptr);
glBindBuffer(GL_ARRAY_BUFFER, 0);

glDrawArrays(GL_POINTS, 0, vertices.size());
glDrawArrays(GL_POINTS, 0, vertices.size() / 3);

glUseProgram(0);
tango_gl::util::CheckGlError("Pointcloud::Render");
Expand Down
2 changes: 1 addition & 1 deletion rgb-depth-sync-example/app/src/main/jni/Application.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

APP_ABI := armeabi-v7a
APP_STL := gnustl_static
APP_PLATFORM := android-19
APP_PLATFORM := android-19
18 changes: 18 additions & 0 deletions tango-gl/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,22 @@ void Camera::SetFieldOfView(float fov) {
Camera::~Camera() {
}

glm::mat4 Camera::ProjectionMatrixForCameraIntrinsics(float width, float height,
float fx, float fy,
float cx, float cy,
float near, float far) {
const float xscale = near / fx;
const float yscale = near / fy;

const float xoffset = (cx - (width / 2.0)) * xscale;
// OpenGL coordinates has y pointing downwards so we negate this term.
const float yoffset = -(cy - (height / 2.0)) * yscale;

return glm::frustum(xscale * -width / 2.0f - xoffset,
xscale * width / 2.0f - xoffset,
yscale * -height / 2.0f - yoffset,
yscale * height / 2.0f - yoffset,
near, far);
}

} // namespace tango_gl
17 changes: 17 additions & 0 deletions tango-gl/include/tango-gl/camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,23 @@ class Camera : public Transform {

glm::mat4 GetViewMatrix();
glm::mat4 GetProjectionMatrix();

/**
* Create an OpenGL perspective matrix from window size, camera intrinsics, and clip settings.
*
* @param width - The width of the camera image.
* @param height - The height of the camera image.
* @param fx - The x-axis focal length of the camera.
* @param fy - The y-axis focal length of the camera.
* @param cx - The x-coordinate principal point in pixels.
* @param cy - The y-coordinate principal point in pixels.
* @param near - The desired near z-clipping plane.
* @param far - The desired far z-clipping plane.
*/
static glm::mat4 ProjectionMatrixForCameraIntrinsics(float width, float height,
float fx, float fy,
float cx, float cy,
float near, float far);
private:
float field_of_view_;
float aspect_ratio_;
Expand Down
8 changes: 6 additions & 2 deletions tango-gl/shaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
namespace tango_gl {
namespace shaders {
std::string GetBasicVertexShader() {
return "attribute vec4 vertex;\n"
return "precision mediump float;\n"
"precision mediump int;\n"
"attribute vec4 vertex;\n"
"uniform mat4 mvp;\n"
"uniform vec4 color;\n"
"varying vec4 v_color;\n"
Expand All @@ -37,7 +39,9 @@ std::string GetBasicFragmentShader() {
}

std::string GetColorVertexShader() {
return "attribute vec4 vertex;\n"
return "precision mediump float;\n"
"precision mediump int;\n"
"attribute vec4 vertex;\n"
"attribute vec4 color;\n"
"uniform mat4 mvp;\n"
"varying vec4 v_color;\n"
Expand Down
16 changes: 15 additions & 1 deletion tango_client_api/include/tango_client_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ typedef struct TangoImageBuffer {
int64_t frame_number;
/// Pixel format of data.
TangoImageFormatType format;
/// Pixels in RGBA8888 format.
/// Pixels in the format of this image buffer.
uint8_t* data;
} TangoImageBuffer;

Expand Down Expand Up @@ -1318,6 +1318,20 @@ TangoErrorType TangoService_Experimental_freeTrajectory(
TangoErrorType TangoService_Experimental_loadAreaDescription(
const TangoUUID uuid);

/// Experimental API only, subject to change.
/// Loads an area description with the specified file path. This allows an
/// application to load an ADF for relocalization after connecting to the
/// service. It should only be called after calling TangoService_connect(), and
/// then only if the connect configuration did not specify an ADF to load, and
/// did not enable learning mode.
/// @param file_path The file path for the ADF to load.
/// @return Returns TANGO_SUCCESS if the ADF is successfully loaded for
/// relocalization. Returns TANGO_INVALID if the file path is invalid, or an ADF
/// is already being learned. Returns TANGO_ERROR if communication fails or if
/// the service needs to be initialized.
TangoErrorType TangoService_Experimental_loadAreaDescriptionFromFile(
const char* file_path);

#ifdef __cplusplus
}
#endif
Expand Down
Binary file modified tango_client_api/lib/libtango_client_api.so
Binary file not shown.

0 comments on commit 44d10f9

Please sign in to comment.