]> git.localhorst.tv Git - blobs.git/blob - src/graphics/Camera.hpp
spherical planets
[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         /// look at center, position relative to orbital reference plane for children
38         Camera &Orbital(const glm::vec3 &pos) noexcept;
39         /// look at creature from the side, angle in euler (ZXY in surface reference plane)
40         Camera &Radial(const creature::Creature &, double distance, const glm::dvec3 &angle);
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