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