diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2022-12-11 14:22:57 +0000 |
---|---|---|
committer | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2022-12-12 09:17:38 +0000 |
commit | 379b07fa1fb953cc175028fcb95dfbb64c392451 (patch) | |
tree | a299bb5118612a308f2404638e24d3b4184a78d7 /gfx/gl/camera.h | |
parent | Fix case of GetViewProjection (diff) | |
download | ilt-379b07fa1fb953cc175028fcb95dfbb64c392451.tar.bz2 ilt-379b07fa1fb953cc175028fcb95dfbb64c392451.tar.xz ilt-379b07fa1fb953cc175028fcb95dfbb64c392451.zip |
Make Camera members private with accessors and helpful setters
Diffstat (limited to 'gfx/gl/camera.h')
-rw-r--r-- | gfx/gl/camera.h | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/gfx/gl/camera.h b/gfx/gl/camera.h index e22d23f..d82802f 100644 --- a/gfx/gl/camera.h +++ b/gfx/gl/camera.h @@ -1,6 +1,7 @@ #pragma once
#include <glm/glm.hpp>
+#include <maths.h>
#include <ray.hpp>
class Camera {
@@ -10,10 +11,43 @@ public: [[nodiscard]] glm::mat4 getViewProjection() const;
[[nodiscard]] Ray unProject(const glm::vec2 &) const;
- glm::vec3 pos;
+ void
+ setPosition(const glm::vec3 & p)
+ {
+ position = p;
+ }
+ void
+ setForward(const glm::vec3 & f)
+ {
+ forward = f;
+ }
+ void
+ setView(const glm::vec3 & p, const glm::vec3 & f, const glm::vec3 & u = ::up)
+ {
+ position = p;
+ forward = f;
+ up = u;
+ }
+ void
+ lookAt(const glm::vec3 & target)
+ {
+ setForward(glm::normalize(target - position));
+ }
+ [[nodiscard]] auto
+ getForward() const
+ {
+ return forward;
+ }
+ [[nodiscard]] auto
+ getPosition() const
+ {
+ return position;
+ }
+
+private:
+ glm::vec3 position;
glm::vec3 forward;
glm::vec3 up;
-private:
glm::mat4 projection;
};
|