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_UI_ELEMENTS_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_ |
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "chrome/browser/android/vr_shell/vr_math.h" | 13 #include "device/vr/vr_types.h" |
14 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" | |
15 | 14 |
16 namespace vr_shell { | 15 namespace vr_shell { |
17 | 16 |
18 class Animation; | 17 class Animation; |
19 | 18 |
20 enum XAnchoring { | 19 enum XAnchoring { |
21 XNONE = 0, | 20 XNONE = 0, |
22 XLEFT, | 21 XLEFT, |
23 XRIGHT, | 22 XRIGHT, |
24 }; | 23 }; |
(...skipping 17 matching lines...) Expand all Loading... |
42 // The element is filled with the content web site. Only one content element | 41 // The element is filled with the content web site. Only one content element |
43 // may be added to the | 42 // may be added to the |
44 // scene. | 43 // scene. |
45 CONTENT = 4, | 44 CONTENT = 4, |
46 }; | 45 }; |
47 | 46 |
48 struct Transform { | 47 struct Transform { |
49 Transform(); | 48 Transform(); |
50 | 49 |
51 void MakeIdentity(); | 50 void MakeIdentity(); |
52 void Rotate(gvr::Quatf quat); | 51 void Rotate(const vr::Quatf& quat); |
53 void Rotate(float ax, float ay, float az, float rad); | 52 void Rotate(const vr::RotationAxisAngle& axis_angle); |
54 void Translate(float tx, float ty, float tz); | 53 void Translate(const gfx::Vector3dF& translation); |
55 void Scale(float sx, float sy, float sz); | 54 void Scale(const gfx::Vector3dF& scale); |
56 | 55 |
57 gvr::Mat4f to_world; | 56 vr::Matf to_world; |
58 }; | 57 }; |
59 | 58 |
60 class WorldRectangle { | 59 class WorldRectangle { |
61 public: | 60 public: |
62 const gvr::Mat4f& TransformMatrix() const; | 61 const vr::Matf& TransformMatrix() const; |
63 Transform* mutable_transform() { return &transform_; } | 62 Transform* mutable_transform() { return &transform_; } |
64 | 63 |
65 gvr::Vec3f GetCenter() const; | 64 gfx::Point3F GetCenter() const; |
66 gvr::Vec3f GetNormal() const; | 65 gfx::Vector3dF GetNormal() const; |
67 | 66 |
68 // Computes the distance from |ray_origin| to this rectangles's plane, along | 67 // Computes the distance from |ray_origin| to this rectangles's plane, along |
69 // |ray_vector|. Returns true and populates |distance| if the calculation is | 68 // |ray_vector|. Returns true and populates |distance| if the calculation is |
70 // possible, and false if the ray is parallel to the plane. | 69 // possible, and false if the ray is parallel to the plane. |
71 bool GetRayDistance(const gvr::Vec3f& ray_origin, | 70 bool GetRayDistance(const gfx::Point3F& ray_origin, |
72 const gvr::Vec3f& ray_vector, | 71 const gfx::Vector3dF& ray_vector, |
73 float* distance) const; | 72 float* distance) const; |
74 | 73 |
75 // Projects a 3D world point onto the X and Y axes of the transformed | 74 // Projects a 3D world point onto the X and Y axes of the transformed |
76 // rectangle, returning 2D coordinates relative to the un-transformed unit | 75 // rectangle, returning 2D coordinates relative to the un-transformed unit |
77 // rectangle. This allows beam intersection points to be mapped to sprite | 76 // rectangle. This allows beam intersection points to be mapped to sprite |
78 // pixel coordinates. Points that fall onto the rectangle will generate X and | 77 // pixel coordinates. Points that fall onto the rectangle will generate X and |
79 // Y values on the interval [-0.5, 0.5]. | 78 // Y values on the interval [-0.5, 0.5]. |
80 gvr::Vec2f GetUnitRectangleCoordinates(const gvr::Vec3f& world_point); | 79 gfx::PointF GetUnitRectangleCoordinates(const gfx::Point3F& world_point); |
81 | 80 |
82 private: | 81 private: |
83 Transform transform_; | 82 Transform transform_; |
84 }; | 83 }; |
85 | 84 |
86 struct ContentRectangle : public WorldRectangle { | 85 struct ContentRectangle : public WorldRectangle { |
87 ContentRectangle(); | 86 ContentRectangle(); |
88 ~ContentRectangle(); | 87 ~ContentRectangle(); |
89 | 88 |
90 void Animate(int64_t time); | 89 void Animate(int64_t time); |
(...skipping 18 matching lines...) Expand all Loading... |
109 bool visible = true; | 108 bool visible = true; |
110 | 109 |
111 // If false, the reticle will not hit the element, even if visible. | 110 // If false, the reticle will not hit the element, even if visible. |
112 bool hit_testable = true; | 111 bool hit_testable = true; |
113 | 112 |
114 // If true, transformations will be applied relative to the field of view, | 113 // If true, transformations will be applied relative to the field of view, |
115 // rather than the world. | 114 // rather than the world. |
116 bool lock_to_fov = false; | 115 bool lock_to_fov = false; |
117 | 116 |
118 // Specifies the region (in pixels) of a texture to render. | 117 // Specifies the region (in pixels) of a texture to render. |
119 Recti copy_rect = {0, 0, 0, 0}; | 118 gfx::Rect copy_rect = {0, 0, 0, 0}; |
120 | 119 |
121 // The size of the object. This does not affect children. | 120 // The size of the object. This does not affect children. |
122 gvr::Vec3f size = {1.0f, 1.0f, 1.0f}; | 121 gfx::Vector3dF size = {1.0f, 1.0f, 1.0f}; |
123 | 122 |
124 // The scale of the object, and its children. | 123 // The scale of the object, and its children. |
125 gvr::Vec3f scale = {1.0f, 1.0f, 1.0f}; | 124 gfx::Vector3dF scale = {1.0f, 1.0f, 1.0f}; |
126 | 125 |
127 // The rotation of the object, and its children. | 126 // The rotation of the object, and its children. |
128 RotationAxisAngle rotation = {1.0f, 0.0f, 0.0f, 0.0f}; | 127 vr::RotationAxisAngle rotation = {1.0f, 0.0f, 0.0f, 0.0f}; |
129 | 128 |
130 // The translation of the object, and its children. Translation is applied | 129 // The translation of the object, and its children. Translation is applied |
131 // after rotation and scaling. | 130 // after rotation and scaling. |
132 gvr::Vec3f translation = {0.0f, 0.0f, 0.0f}; | 131 gfx::Vector3dF translation = {0.0f, 0.0f, 0.0f}; |
133 | 132 |
134 // The opacity of the object (between 0.0 and 1.0). | 133 // The opacity of the object (between 0.0 and 1.0). |
135 float opacity = 1.0f; | 134 float opacity = 1.0f; |
136 | 135 |
137 // The computed opacity, incorporating opacity of parent objects. | 136 // The computed opacity, incorporating opacity of parent objects. |
138 float computed_opacity; | 137 float computed_opacity; |
139 | 138 |
140 // The computed lock to the FoV, incorporating lock of parent objects. | 139 // The computed lock to the FoV, incorporating lock of parent objects. |
141 bool computed_lock_to_fov; | 140 bool computed_lock_to_fov; |
142 | 141 |
143 // If anchoring is specified, the translation will be relative to the | 142 // If anchoring is specified, the translation will be relative to the |
144 // specified edge(s) of the parent, rather than the center. A parent object | 143 // specified edge(s) of the parent, rather than the center. A parent object |
145 // must be specified when using anchoring. | 144 // must be specified when using anchoring. |
146 XAnchoring x_anchoring = XAnchoring::XNONE; | 145 XAnchoring x_anchoring = XAnchoring::XNONE; |
147 YAnchoring y_anchoring = YAnchoring::YNONE; | 146 YAnchoring y_anchoring = YAnchoring::YNONE; |
148 | 147 |
149 // Animations that affect the properties of the object over time. | 148 // Animations that affect the properties of the object over time. |
150 std::vector<std::unique_ptr<Animation>> animations; | 149 std::vector<std::unique_ptr<Animation>> animations; |
151 | 150 |
152 Fill fill = Fill::NONE; | 151 Fill fill = Fill::NONE; |
153 | 152 |
154 Colorf edge_color = {1.0f, 1.0f, 1.0f, 1.0f}; | 153 vr::Colorf edge_color = {1.0f, 1.0f, 1.0f, 1.0f}; |
155 Colorf center_color = {1.0f, 1.0f, 1.0f, 1.0f}; | 154 vr::Colorf center_color = {1.0f, 1.0f, 1.0f, 1.0f}; |
156 | 155 |
157 int gridline_count = 1; | 156 int gridline_count = 1; |
158 | 157 |
159 int draw_phase = 1; | 158 int draw_phase = 1; |
160 | 159 |
161 // This transform can be used by children to derive position of its parent. | 160 // This transform can be used by children to derive position of its parent. |
162 Transform inheritable_transform; | 161 Transform inheritable_transform; |
163 | 162 |
164 // A flag usable during transformation calculates to avoid duplicate work. | 163 // A flag usable during transformation calculates to avoid duplicate work. |
165 bool dirty; | 164 bool dirty; |
166 | 165 |
167 private: | 166 private: |
168 DISALLOW_COPY_AND_ASSIGN(ContentRectangle); | 167 DISALLOW_COPY_AND_ASSIGN(ContentRectangle); |
169 }; | 168 }; |
170 | 169 |
171 } // namespace vr_shell | 170 } // namespace vr_shell |
172 | 171 |
173 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_ | 172 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_ |
OLD | NEW |