summaryrefslogtreecommitdiff
path: root/camera.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-01-17 18:54:26 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-01-17 18:54:26 +0000
commit43a87590f45aa6e55724d30d0c2d0d34b407a57e (patch)
tree21ce8e8886f8aa58b159419b7d885f57d9a37580 /camera.h
parentInitial commit (diff)
downloadilt-43a87590f45aa6e55724d30d0c2d0d34b407a57e.tar.bz2
ilt-43a87590f45aa6e55724d30d0c2d0d34b407a57e.tar.xz
ilt-43a87590f45aa6e55724d30d0c2d0d34b407a57e.zip
First cut modernizing and sanitizing
Diffstat (limited to 'camera.h')
-rw-r--r--camera.h49
1 files changed, 7 insertions, 42 deletions
diff --git a/camera.h b/camera.h
index 86b59d1..3c1e40c 100644
--- a/camera.h
+++ b/camera.h
@@ -2,53 +2,18 @@
#define CAMERA_INCLUDED_H
#include <glm/glm.hpp>
-#include <glm/gtx/transform.hpp>
-struct Camera {
+class Camera {
public:
- Camera(const glm::vec3 & pos, float fov, float aspect, float zNear, float zFar)
- {
- this->pos = pos;
- this->forward = glm::vec3(0.0f, 0.0f, 1.0f);
- this->up = glm::vec3(0.0f, 1.0f, 0.0f);
- this->projection = glm::perspective(fov, aspect, zNear, zFar);
- }
+ Camera(glm::vec3 pos, float fov, float aspect, float zNear, float zFar);
- inline glm::mat4
- GetViewProjection() const
- {
- return projection * glm::lookAt(pos, pos + forward, up);
- }
+ glm::mat4 GetViewProjection() const;
- // void MoveForward(float amt)
- //{
- // pos += forward * amt;
- //}
+ void MoveForward(float amt);
+ void MoveRight(float amt);
+ void Pitch(float angle);
+ void RotateY(float angle);
- // void MoveRight(float amt)
- //{
- // pos += glm::cross(up, forward) * amt;
- //}
-
- // void Pitch(float angle)
- //{
- // glm::vec3 right = glm::normalize(glm::cross(up, forward));
-
- // forward = glm::vec3(glm::normalize(glm::rotate(angle, right) * glm::vec4(forward, 0.0)));
- // up = glm::normalize(glm::cross(forward, right));
- //}
-
- // void RotateY(float angle)
- //{
- // static const glm::vec3 UP(0.0f, 1.0f, 0.0f);
-
- // glm::mat4 rotation = glm::rotate(angle, UP);
-
- // forward = glm::vec3(glm::normalize(rotation * glm::vec4(forward, 0.0)));
- // up = glm::vec3(glm::normalize(rotation * glm::vec4(up, 0.0)));
- //}
-
-protected:
private:
glm::mat4 projection;
glm::vec3 pos;