]> git.localhorst.tv Git - blobs.git/blob - src/graphics/Camera.hpp
51dd8f15c447e1a67731b816b78f7211f251179d
[blobs.git] / src / graphics / Camera.hpp
1 #ifndef BLOBS_GRAPHICS_CAMERA_HPP_
2 #define BLOBS_GRAPHICS_CAMERA_HPP_
3
4 #include "../math/glm.hpp"
5
6
7 namespace blobs {
8 namespace world {
9         class Body;
10 }
11 namespace graphics {
12
13 class Camera {
14
15 public:
16         explicit Camera(const world::Body &) noexcept;
17         ~Camera() noexcept;
18
19         Camera(const Camera &) = delete;
20         Camera &operator =(const Camera &) = delete;
21
22         Camera(Camera &&) = delete;
23         Camera &operator =(Camera &&) = delete;
24
25 public:
26         Camera &FOV(float f) noexcept;
27         Camera &Aspect(float r) noexcept;
28         Camera &Aspect(float w, float h) noexcept;
29         Camera &Clip(float near, float far) noexcept;
30
31         const world::Body &Reference() const noexcept { return *ref; }
32         Camera &Reference(const world::Body &) noexcept;
33
34         /// standing on given surface, with pos.z being elevation over NN
35         /// looking at given coordinates
36         Camera &FirstPerson(int surface, const glm::vec3 &pos, const glm::vec3 &at) noexcept;
37         /// looking straight down at surface from above
38         Camera &MapView(int surface, const glm::vec3 &pos, float roll = 0.0f) noexcept;
39         /// look at center, position relative to orbital reference plane for children
40         Camera &Orbital(const glm::vec3 &pos) noexcept;
41
42         const glm::mat4 &Projection() const noexcept { return projection; }
43         const glm::mat4 &View() const noexcept { return view; }
44         glm::mat4 Model(const world::Body &) const noexcept;
45
46 private:
47         void UpdateProjection() noexcept;
48
49 private:
50         float fov;
51         float aspect;
52         float near;
53         float far;
54
55         glm::mat4 projection;
56         glm::mat4 view;
57
58         // reference frame
59         const world::Body *ref;
60         // track reference body's orientation
61         bool track_orient;
62
63 };
64
65 }
66 }
67
68 #endif