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