]> git.localhorst.tv Git - tacos.git/blob - src/graphics/camera.hpp
controllable camera
[tacos.git] / src / graphics / camera.hpp
1 #ifndef TACOS_GRAPHICS_CAMERA_HPP_
2 #define TACOS_GRAPHICS_CAMERA_HPP_
3
4 #include <glm/glm.hpp>
5
6
7 namespace tacos {
8
9 /// Camera is facing a focus point. Its position is determined by
10 /// displacing said focus point by a distance in the direction indicated
11 /// by pitch and yaw.
12 /// The up direction is fixed to positive Y.
13 class Camera {
14
15 public:
16         Camera();
17
18         glm::mat4 View() const noexcept;
19
20         /// set focal point to given position
21         void Warp(const glm::vec3 &position) noexcept { focus = position; }
22         /// move focal point by given delta
23         void Move(const glm::vec3 &delta) noexcept;
24
25         /// set distance of camera to focal point
26         void Distance(float dist) noexcept { distance = dist; }
27         /// adjust distance of camera to focal point
28         void BackOff(float delta) noexcept { distance += delta; }
29
30         /// set pitch and yaw
31         void Orient(const glm::vec2 &orient) noexcept { orientation = orient; }
32         /// change pitch and yaw
33         void Rotate(const glm::vec2 &delta) noexcept;
34
35 private:
36         glm::vec3 focus;
37         float distance;
38         glm::vec2 orientation;
39
40 };
41
42 }
43
44 #endif