Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
hudget.h
1 #pragma once
2 
3 #include <glm/glm.hpp>
4 #include <glm/gtx/quaternion.hpp>
5 
6 #include "geometry/ray.h"
7 
8 enum class ClickType;
9 class HUD;
10 
11 
12 /*
13  Hudget, named after Widget - is an element on the HUD
14 */
15 class Hudget {
16 public:
17  Hudget(HUD* hud);
18 
19  HUD* hud();
20 
21  bool visible() const;
22  void setVisible(bool visible);
23 
24  bool pressed() const;
25  bool hovered() const;
26 
27  bool clicked() const;
28  bool released() const;
29 
30  bool entered() const;
31  bool left() const;
32 
33 
34 
35  virtual void onClick(ClickType clickType);
36 
37  /*
38  Shall return true when the Clickable is under a
39  pointer at quat orientation
40  */
41  virtual bool isAt(const Ray& ray) const;
42 
43  /*
44  To be called every frame, clicked shall be true when the
45  pointer was clicked in that exact frame
46  */
47  virtual void pointerAt(const Ray& ray, bool pressed);
48 
49  /*
50  Set the relative distance from the HUD center, where 1.0f
51  is exactly on the HUD-sphere
52  */
53  void setRelativeDistance(float relativeDistance);
54 
55  /*
56  Set the direction the hudget shall point, either to a
57  position in the world or one in the local coordinate system
58  */
59  void pointToWorldPoint(const glm::vec3& worldPoint);
60  void pointToLocalPoint(const glm::vec3& localPoint);
61 
62  glm::vec3 localDirection() const;
63  glm::vec3 worldDirection() const;
64 
65  /*
66  Additionally to the direction, a rotation on the direction-vector
67  can be added to orientate the hudget
68  */
69  float directionAngle() const;
70  void setDirectionAngle(float directionAngle);
71 
72 
73  /*
74  Since the Hudgets need to be placed in world-coordinates
75  to make stereo-rendering easier, these functions can be used
76  to retrieve world-coordinates
77  */
78  glm::vec3 worldPosition() const;
79  glm::vec3 worldPosition(const glm::vec3& localVector) const;
80  glm::quat worldOrientation() const;
81  glm::quat worldOrientation(const glm::vec3& localVector) const;
82 
83  virtual void update(float deltaSec) = 0;
84  virtual void draw() = 0;
85 
86 
87 protected:
88  HUD* m_hud;
89 
90  glm::vec3 m_direction;
91  float m_directionAngle;
92  float m_relativeDistance;
93 
94  bool m_visible;
95 
96  bool m_pressed;
97  bool m_hovered;
98  bool m_clicked;
99  bool m_released;
100  bool m_entered;
101  bool m_left;
102 };
103 
Definition: hudget.h:15
Definition: hud.h:34
Definition: ray.h:12