]> git.localhorst.tv Git - blobs.git/blobdiff - src/graphics/Camera.hpp
(slightly) better camera handling
[blobs.git] / src / graphics / Camera.hpp
index 7cc141ecb65e150b8b65b53632c19586a422ab23..f4a98d50cc0eefe80d5294f6f3c0c934c97c0377 100644 (file)
@@ -5,12 +5,15 @@
 
 
 namespace blobs {
+namespace world {
+       class Body;
+}
 namespace graphics {
 
 class Camera {
 
 public:
-       Camera() noexcept;
+       explicit Camera(const world::Body &) noexcept;
        ~Camera() noexcept;
 
        Camera(const Camera &) = delete;
@@ -20,14 +23,25 @@ public:
        Camera &operator =(Camera &&) = delete;
 
 public:
-       void FOV(float f) noexcept;
-       void Aspect(float r) noexcept;
-       void Aspect(float w, float h) noexcept;
-       void Clip(float near, float far) noexcept;
+       Camera &FOV(float f) noexcept;
+       Camera &Aspect(float r) noexcept;
+       Camera &Aspect(float w, float h) noexcept;
+       Camera &Clip(float near, float far) noexcept;
+
+       const world::Body &Reference() const noexcept { return *ref; }
+       Camera &Reference(const world::Body &) noexcept;
+
+       /// standing on given surface, with pos.z being elevation over NN
+       /// looking at given coordinates
+       Camera &FirstPerson(int surface, const glm::vec3 &pos, const glm::vec3 &at) noexcept;
+       /// looking straight down at surface from above
+       Camera &MapView(int surface, const glm::vec3 &pos, float roll = 0.0f) noexcept;
+       /// look at center, position relative to orbital reference plane for children
+       Camera &Orbital(const glm::vec3 &pos) noexcept;
 
        const glm::mat4 &Projection() const noexcept { return projection; }
        const glm::mat4 &View() const noexcept { return view; }
-       void View(const glm::mat4 &v) noexcept;
+       glm::mat4 Model(const world::Body &) const noexcept;
 
 private:
        void UpdateProjection() noexcept;
@@ -41,6 +55,11 @@ private:
        glm::mat4 projection;
        glm::mat4 view;
 
+       // reference frame
+       const world::Body *ref;
+       // track reference body's orientation
+       bool track_orient;
+
 };
 
 }