| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_MATH_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_MATH_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_MATH_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_MATH_H_ |
| 7 | 7 |
| 8 #include <array> | 8 #include <array> |
| 9 | 9 |
| 10 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" | 10 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 } RotationAxisAngle; | 35 } RotationAxisAngle; |
| 36 | 36 |
| 37 typedef struct Colorf { | 37 typedef struct Colorf { |
| 38 float r; | 38 float r; |
| 39 float g; | 39 float g; |
| 40 float b; | 40 float b; |
| 41 float a; | 41 float a; |
| 42 } Colorf; | 42 } Colorf; |
| 43 | 43 |
| 44 void SetIdentityM(gvr::Mat4f& mat); | 44 void SetIdentityM(gvr::Mat4f& mat); |
| 45 | |
| 46 void TranslateM(gvr::Mat4f& tmat, gvr::Mat4f& mat, float x, float y, float z); | 45 void TranslateM(gvr::Mat4f& tmat, gvr::Mat4f& mat, float x, float y, float z); |
| 47 void TranslateMRight(gvr::Mat4f& tmat, | |
| 48 gvr::Mat4f& mat, | |
| 49 float x, | |
| 50 float y, | |
| 51 float z); | |
| 52 | |
| 53 void ScaleM(gvr::Mat4f& tmat, const gvr::Mat4f& mat, float x, float y, float z); | 46 void ScaleM(gvr::Mat4f& tmat, const gvr::Mat4f& mat, float x, float y, float z); |
| 54 void ScaleMRight(gvr::Mat4f& tmat, | |
| 55 const gvr::Mat4f& mat, | |
| 56 float x, | |
| 57 float y, | |
| 58 float z); | |
| 59 | 47 |
| 60 // Util functions that are copied from the treasure_hunt NDK demo in | 48 // Util functions that are copied from the treasure_hunt NDK demo in |
| 61 // third_party/gvr-andoir-sdk/ folder. | 49 // third_party/gvr-andoir-sdk/ folder. |
| 62 gvr::Mat4f MatrixTranspose(const gvr::Mat4f& mat); | 50 gvr::Mat4f MatrixTranspose(const gvr::Mat4f& mat); |
| 63 std::array<float, 4> MatrixVectorMul(const gvr::Mat4f& matrix, | 51 std::array<float, 4> MatrixVectorMul(const gvr::Mat4f& matrix, |
| 64 const std::array<float, 4>& vec); | 52 const std::array<float, 4>& vec); |
| 65 std::array<float, 3> MatrixVectorMul(const gvr::Mat4f& matrix, | 53 std::array<float, 3> MatrixVectorMul(const gvr::Mat4f& matrix, |
| 66 const std::array<float, 3>& vec); | 54 const std::array<float, 3>& vec); |
| 67 gvr::Vec3f MatrixVectorMul(const gvr::Mat4f& m, const gvr::Vec3f& v); | 55 gvr::Vec3f MatrixVectorMul(const gvr::Mat4f& m, const gvr::Vec3f& v); |
| 68 gvr::Vec3f MatrixVectorRotate(const gvr::Mat4f& m, const gvr::Vec3f& v); | 56 gvr::Vec3f MatrixVectorRotate(const gvr::Mat4f& m, const gvr::Vec3f& v); |
| 69 gvr::Mat4f MatrixMul(const gvr::Mat4f& matrix1, const gvr::Mat4f& matrix2); | 57 gvr::Mat4f MatrixMul(const gvr::Mat4f& matrix1, const gvr::Mat4f& matrix2); |
| 70 gvr::Mat4f PerspectiveMatrixFromView(const gvr::Rectf& fov, | 58 gvr::Mat4f PerspectiveMatrixFromView(const gvr::Rectf& fov, |
| 71 float z_near, | 59 float z_near, |
| 72 float z_far); | 60 float z_far); |
| 73 | 61 |
| 74 // Provides the direction the head is looking towards as a 3x1 unit vector. | 62 // Provides the direction the head is looking towards as a 3x1 unit vector. |
| 75 gvr::Vec3f GetForwardVector(const gvr::Mat4f& matrix); | 63 gvr::Vec3f GetForwardVector(const gvr::Mat4f& matrix); |
| 76 | 64 |
| 77 gvr::Vec3f GetTranslation(const gvr::Mat4f& matrix); | 65 gvr::Vec3f GetTranslation(const gvr::Mat4f& matrix); |
| 78 | 66 |
| 79 gvr::Quatf QuatMultiply(const gvr::Quatf& a, const gvr::Quatf& b); | |
| 80 | |
| 81 gvr::Mat4f QuatToMatrix(const gvr::Quatf& quat); | 67 gvr::Mat4f QuatToMatrix(const gvr::Quatf& quat); |
| 82 | 68 |
| 83 float VectorLength(const gvr::Vec3f& vec); | 69 float VectorLength(const gvr::Vec3f& vec); |
| 70 gvr::Vec3f VectorSubtract(const gvr::Vec3f& a, const gvr::Vec3f& b); |
| 71 float VectorDot(const gvr::Vec3f& a, const gvr::Vec3f& b); |
| 84 | 72 |
| 85 // Normalize a vector, and return its original length. | 73 // Normalize a vector, and return its original length. |
| 86 float NormalizeVector(gvr::Vec3f& vec); | 74 float NormalizeVector(gvr::Vec3f& vec); |
| 87 | 75 |
| 88 float VectorDot(const gvr::Vec3f& a, const gvr::Vec3f& b); | |
| 89 | |
| 90 void NormalizeQuat(gvr::Quatf& quat); | 76 void NormalizeQuat(gvr::Quatf& quat); |
| 91 | 77 |
| 92 gvr::Quatf QuatFromAxisAngle(const gvr::Vec3f& axis, float angle); | 78 gvr::Quatf QuatFromAxisAngle(const gvr::Vec3f& axis, float angle); |
| 93 | 79 |
| 94 gvr::Vec3f GetRayPoint(const gvr::Vec3f& rayOrigin, | 80 gvr::Vec3f GetRayPoint(const gvr::Vec3f& rayOrigin, |
| 95 const gvr::Vec3f& rayVector, | 81 const gvr::Vec3f& rayVector, |
| 96 float scale); | 82 float scale); |
| 97 | 83 |
| 98 } // namespace vr_shell | 84 } // namespace vr_shell |
| 99 | 85 |
| 100 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_MATH_H_ | 86 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_MATH_H_ |
| OLD | NEW |