Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Side by Side Diff: chrome/browser/android/vr_shell/vr_math.h

Issue 2814443004: Refactor VR math off of GVR types, onto gfx types where possible. (Closed)
Patch Set: Fix tests Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_MATH_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_MATH_H_
7
8 #include <array>
9
10 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h"
11
12 namespace vr_shell {
13
14 // 2D rectangles. Unlike gvr::Rectf and gvr::Recti, these have width and height
15 // rather than right and top.
16 typedef struct Recti {
17 int x;
18 int y;
19 int width;
20 int height;
21 } Recti;
22
23 typedef struct Rectf {
24 float x;
25 float y;
26 float width;
27 float height;
28 } Rectf;
29
30 typedef struct RotationAxisAngle {
31 float x;
32 float y;
33 float z;
34 float angle;
35 } RotationAxisAngle;
36
37 typedef struct Colorf {
38 float r;
39 float g;
40 float b;
41 float a;
42 } Colorf;
43
44 void SetIdentityM(gvr::Mat4f& mat);
45 void TranslateM(gvr::Mat4f& tmat, 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);
47
48 // Util functions that are copied from the treasure_hunt NDK demo in
49 // third_party/gvr-andoir-sdk/ folder.
50 gvr::Vec3f MatrixVectorMul(const gvr::Mat4f& m, const gvr::Vec3f& v);
51 gvr::Vec3f MatrixVectorRotate(const gvr::Mat4f& m, const gvr::Vec3f& v);
52 gvr::Mat4f MatrixMul(const gvr::Mat4f& matrix1, const gvr::Mat4f& matrix2);
53 gvr::Mat4f PerspectiveMatrixFromView(const gvr::Rectf& fov,
54 float z_near,
55 float z_far);
56
57 // Provides the direction the head is looking towards as a 3x1 unit vector.
58 gvr::Vec3f GetForwardVector(const gvr::Mat4f& matrix);
59
60 gvr::Vec3f GetTranslation(const gvr::Mat4f& matrix);
61
62 gvr::Mat4f QuatToMatrix(const gvr::Quatf& quat);
63
64 float VectorLength(const gvr::Vec3f& vec);
65 gvr::Vec3f VectorSubtract(const gvr::Vec3f& a, const gvr::Vec3f& b);
66 float VectorDot(const gvr::Vec3f& a, const gvr::Vec3f& b);
67
68 // Normalize a vector, and return its original length.
69 float NormalizeVector(gvr::Vec3f& vec);
70
71 void NormalizeQuat(gvr::Quatf& quat);
72
73 gvr::Quatf QuatFromAxisAngle(const gvr::Vec3f& axis, float angle);
74
75 gvr::Vec3f GetRayPoint(const gvr::Vec3f& rayOrigin,
76 const gvr::Vec3f& rayVector,
77 float scale);
78
79 float Distance(const gvr::Vec3f& vec1, const gvr::Vec3f& vec2);
80
81 // Angle between the vectors' projections to the XZ plane.
82 bool XZAngle(const gvr::Vec3f& vec1, const gvr::Vec3f& vec2, float* angle);
83
84 } // namespace vr_shell
85
86 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_MATH_H_
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_gl_util.cc ('k') | chrome/browser/android/vr_shell/vr_math.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698