util.h
Go to the documentation of this file.
00001 /*
00002  * Copyright 2014 Google Inc. All Rights Reserved.
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *      http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef TANGO_GL_GL_UTIL_H_
00018 #define TANGO_GL_GL_UTIL_H_
00019 #define GLM_FORCE_RADIANS
00020 
00021 #define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
00022 
00023 #include <stdlib.h>
00024 #include <jni.h>
00025 #include <android/log.h>
00026 #include <GLES2/gl2.h>
00027 #include <GLES2/gl2ext.h>
00028 #include <tango_support_api.h>
00029 
00030 #include "glm/glm.hpp"
00031 #include "glm/gtc/matrix_transform.hpp"
00032 #include "glm/gtc/quaternion.hpp"
00033 #include "glm/gtc/type_ptr.hpp"
00034 #include "glm/gtx/matrix_decompose.hpp"
00035 
00036 #define LOG_TAG "rtabmap"
00037 #ifdef DISABLE_LOG
00038 #define LOGD(...) ;
00039 #define LOGI(...) ;
00040 #define LOGW(...) ;
00041 #else
00042 #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
00043 #define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
00044 #define LOGW(...) __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
00045 #endif
00046 #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
00047 
00048 #ifndef M_PI
00049 #define M_PI 3.1415926f
00050 #endif
00051 
00052 #define RADIAN_2_DEGREE 57.2957795f
00053 #define DEGREE_2_RADIANS 0.0174532925f
00054 
00055 namespace tango_gl {
00056 namespace util {
00057   void CheckGlError(const char* operation);
00058 
00059   GLuint CreateProgram(const char* vertex_source,
00060                        const char* fragment_source);
00061 
00062   void DecomposeMatrix(const glm::mat4& transform_mat,
00063                        glm::vec3& translation,
00064                        glm::quat& rotation,
00065                        glm::vec3& scale);
00066 
00067   // Get a 3x1 column from the upper 3x4 of a transformation matrix. Columns
00068   // 0, 1, 2 are the rotation/scale portion, and column 3 is the translation.
00069   glm::vec3 GetColumnFromMatrix(const glm::mat4& mat, const int col);
00070 
00071   // Get the translation component of a transformation matrix.
00072   glm::vec3 GetTranslationFromMatrix(const glm::mat4& mat);
00073 
00074   float Clamp(float value, float min, float max);
00075   void PrintMatrix(const glm::mat4& matrix);
00076   void PrintVector(const glm::vec3& vector);
00077   void PrintQuaternion(const glm::quat& quat);
00078 
00079   glm::vec3 LerpVector(const glm::vec3& x, const glm::vec3& y, float a);
00080   float DistanceSquared(const glm::vec3& v1, const glm::vec3& v2);
00081 
00082   bool SegmentAABBIntersect(const glm::vec3& aabb_min, const glm::vec3& aabb_max,
00083                         const glm::vec3& start, const glm::vec3& end);
00084 
00085   glm::vec3 ApplyTransform(const glm::mat4& mat, const glm::vec3& vec);
00086 
00087   // Get the Android rotation integer value from color camera to display.
00088   // This function is used to compute the orientation difference to handle
00089   // the portrait and landscape mode for color camera display.
00090   //
00091   // @param display: integer value of display orientation, values available
00092   // are 0, 1, 2 ,3. Followed by Android display orientation standard:
00093   // https://developer.android.com/reference/android/view/Display.html#getRotation()
00094   // @param color_camera: integer value of color camera oreintation, values
00095   // available are 0, 90, 180, 270. Followed by Android camera orientation
00096   // standard:
00097   // https://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation
00098   TangoSupportRotation GetAndroidRotationFromColorCameraToDisplay(
00099       int display_rotation, int color_camera_rotation);
00100 
00101   // Get the Android rotation integer value from color camera to display.
00102   // This function is used to compute the orientation difference to handle
00103   // the portrait and landscape mode for color camera display.
00104   //
00105   // @param display: the device display orientation.
00106   // @param color_camera: integer value of color camera oreintation, values
00107   // available are 0, 90, 180, 270. Followed by Android camera orientation
00108   // standard:
00109   // https://developer.android.com/reference/android/hardware/Camera.CameraInfo.html#orientation
00110   TangoSupportRotation GetAndroidRotationFromColorCameraToDisplay(
00111       TangoSupportRotation display_rotation, int color_camera_rotation);
00112 
00113 }  // namespace util
00114 }  // namespace tango_gl
00115 #endif  // TANGO_GL_RENDERER_GL_UTIL


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jun 6 2019 21:59:32