HIRO_DRAW
Computer Graphics Structures library
VisualCamera.h
1 /*
2  Copyright (C) Skeletex Research, s.r.o. - All Rights Reserved
3  Unauthorized copying of this file, via any medium is strictly prohibited
4  Proprietary and confidential
5 */
6 #ifndef HIRO_DRAW_VISUAL_CAMERA_H
7 #define HIRO_DRAW_VISUAL_CAMERA_H
8 #include <functional>
9 
10 #include <glm/glm.hpp>
11 
12 #include <Utils/GeometryStructures.h>
13 #include <Utils/ExtGLM.h>
14 #include <HIRO_DRAW/API.h>
15 
16 
17 
18 namespace hiro::draw
19 {
20 
27  class HIRO_DRAW_API VisualCamera
28  {
29  public:
30 
31  using CallbackOnChange = std::function<void(void)>;
32 
34  VisualCamera();
35 
37  void CopyView(const hiro::draw::VisualCamera &source_camera);
38 
40  const glm_ext::TransMat4 &GetViewMatrix() const;
41 
43  glm::vec3 GetForward() const;
44 
46  glm::vec3 GetRight() const;
47 
49  glm::vec3 GetUp() const;
50 
52  void SetPosition(const glm::vec3 &camera_position);
53 
55  void AlignUpVector(const glm::vec3 &vector);
56 
58  void LookInDirection(const glm::vec3 &new_forward);
59 
61  void LookAt(const glm::vec3 &point_of_interest, const glm::vec3 &up);
62 
64  void SetPositionAndLookAt(const glm::vec3 &camera_position, const glm::vec3 &point_of_interest, const glm::vec3 &up);
65 
67  glm::vec3 GetPosition() const;
68 
70  void Rotate(const glm::quat &rot);
71 
73  void Dolly(const float distance);
74 
76  void Crab(const float distance);
77 
79  void Boom(const float distance);
80 
82  void Pan(const float angle);
83 
85  void Tilt(const float angle);
86 
88  void Roll(const float angle);
89 
91  void Move(const glm::vec3 &move_vector);
92 
94  void ReadFromStream(std::istream &str);
95 
97  void WriteToStream(std::ostream &str);
98 
100  void SubscribeChange(const hiro::draw::VisualCamera::CallbackOnChange &listener);
101 
103  void Reset();
104 
105  protected:
106  glm::vec3 position_ = glm::vec3(0.0f);
107  glm::vec3 basis_z_ = glm::vec3(0.0f, 0.0f, -1.0f); // camera backward direction
108  glm::vec3 basis_y_ = glm::vec3(0.0f, 1.0f, 0.0f); // camera up direction
109  glm_ext::TransMat4 view_matrix_;
110  std::vector<hiro::draw::VisualCamera::CallbackOnChange> listeners_;
111  void UpdateCameraSpace();
112  };
113 
114 }
115 
116 #endif /* !HIRO_DRAW_VISUAL_CAMERA_H */
Extensions for object visualization. Implements a higher level of OpenGL rendering.
Definition: API.h:20
A wrapper over view matrix, providing intuitive control.
Definition: VisualCamera.h:27