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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
52 void Rotate(float ax, float ay, float az, float rad); | 52 void Rotate(float ax, float ay, float az, float rad); |
53 void Translate(float tx, float ty, float tz); | 53 void Translate(float tx, float ty, float tz); |
54 void Scale(float sx, float sy, float sz); | 54 void Scale(float sx, float sy, float sz); |
55 | 55 |
56 gvr::Mat4f to_world; | 56 gvr::Mat4f to_world; |
57 }; | 57 }; |
58 | 58 |
59 class WorldRectangle { | 59 class WorldRectangle { |
60 public: | 60 public: |
61 const gvr::Mat4f& TransformMatrix() const; | 61 const gvr::Mat4f& TransformMatrix() const; |
62 void SetTransform(const Transform& transform); | 62 Transform* GetTransform() { return &transform_; } |
63 | 63 |
64 gvr::Vec3f GetCenter() const; | 64 gvr::Vec3f GetCenter() const; |
65 gvr::Vec3f GetNormal() const; | 65 gvr::Vec3f GetNormal() const; |
66 | 66 |
67 // 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 |
68 // |ray_vector|. Returns true and populates |distance| if the calculation is | 68 // |ray_vector|. Returns true and populates |distance| if the calculation is |
69 // possible, and false if the ray is parallel to the plane. | 69 // possible, and false if the ray is parallel to the plane. |
70 bool GetRayDistance(const gvr::Vec3f& ray_origin, | 70 bool GetRayDistance(const gvr::Vec3f& ray_origin, |
71 const gvr::Vec3f& ray_vector, | 71 const gvr::Vec3f& ray_vector, |
72 float* distance) const; | 72 float* distance) const; |
73 | 73 |
74 // 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 |
75 // rectangle, returning 2D coordinates relative to the un-transformed unit | 75 // rectangle, returning 2D coordinates relative to the un-transformed unit |
76 // rectangle. This allows beam intersection points to be mapped to sprite | 76 // rectangle. This allows beam intersection points to be mapped to sprite |
77 // 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 |
78 // Y values on the interval [-0.5, 0.5]. | 78 // Y values on the interval [-0.5, 0.5]. |
79 gvr::Vec2f GetUnitRectangleCoordinates(const gvr::Vec3f& world_point); | 79 gvr::Vec2f GetUnitRectangleCoordinates(const gvr::Vec3f& world_point); |
80 | 80 |
81 private: | 81 private: |
82 Transform transform_; | 82 Transform transform_; |
83 }; | 83 }; |
84 | 84 |
85 struct ContentRectangle : public WorldRectangle { | 85 struct ContentRectangle : public WorldRectangle { |
86 ContentRectangle(); | 86 ContentRectangle(); |
87 ~ContentRectangle(); | 87 ~ContentRectangle(); |
88 | 88 |
89 Transform* GetInheritableTransform() { return &inheritable_transform_; } | |
tiborg
2017/03/24 21:58:37
Do we need this? inheritable_transform_ is public
cjgrant
2017/03/27 14:07:52
My motivation: This object started as a struct be
tiborg
2017/03/27 14:30:18
I think we can also make a gradual switch (even th
cjgrant
2017/03/27 15:20:16
Done. Lets go all-or-nothing here.
| |
90 | |
89 void Animate(int64_t time); | 91 void Animate(int64_t time); |
90 | 92 |
91 // Indicates whether the element should be visually rendered. | 93 // Indicates whether the element should be visually rendered. |
92 bool IsVisible() const; | 94 bool IsVisible() const; |
93 | 95 |
94 // Indicates whether the element should be tested for cursor input. | 96 // Indicates whether the element should be tested for cursor input. |
95 bool IsHitTestable() const; | 97 bool IsHitTestable() const; |
96 | 98 |
97 // Valid IDs are non-negative. | 99 // Valid IDs are non-negative. |
98 int id = -1; | 100 int id = -1; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 | 149 |
148 Fill fill = Fill::NONE; | 150 Fill fill = Fill::NONE; |
149 | 151 |
150 Colorf edge_color = {1.0f, 1.0f, 1.0f, 1.0f}; | 152 Colorf edge_color = {1.0f, 1.0f, 1.0f, 1.0f}; |
151 Colorf center_color = {1.0f, 1.0f, 1.0f, 1.0f}; | 153 Colorf center_color = {1.0f, 1.0f, 1.0f, 1.0f}; |
152 | 154 |
153 int gridline_count = 1; | 155 int gridline_count = 1; |
154 | 156 |
155 int draw_phase = 1; | 157 int draw_phase = 1; |
156 | 158 |
159 // This transform can be used by children to derive position of its parent. | |
160 Transform inheritable_transform_; | |
tiborg
2017/03/24 21:58:37
Remove trailing _?
cjgrant
2017/03/27 15:20:16
Done.
| |
161 | |
162 // A flag usable during transformation calculates to avoid duplicate work. | |
163 bool dirty; | |
164 | |
157 private: | 165 private: |
158 DISALLOW_COPY_AND_ASSIGN(ContentRectangle); | 166 DISALLOW_COPY_AND_ASSIGN(ContentRectangle); |
159 }; | 167 }; |
160 | 168 |
161 } // namespace vr_shell | 169 } // namespace vr_shell |
162 | 170 |
163 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_ | 171 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_UI_ELEMENTS_H_ |
OLD | NEW |