]> git.localhorst.tv Git - blobs.git/blob - src/graphics/Camera.hpp
basic sky box
[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         Camera &LookAt(const glm::vec3 &pos, const glm::vec3 &tgt, const glm::vec3 &up) noexcept;
35
36         /// track orientation of reference body
37         void TrackOrientation(bool b = true) noexcept { track_orient = b; }
38
39         const glm::mat4 &Projection() const noexcept { return projection; }
40         const glm::mat4 &View() const noexcept { return view; }
41         glm::mat4 Model(const world::Body &) const noexcept;
42         glm::mat4 Universe() const noexcept;
43
44 private:
45         void UpdateProjection() noexcept;
46
47 private:
48         float fov;
49         float aspect;
50         float near;
51         float far;
52
53         glm::mat4 projection;
54         glm::mat4 view;
55
56         // reference frame
57         const world::Body *ref;
58         // track reference body's orientation
59         bool track_orient;
60
61 };
62
63 }
64 }
65
66 #endif