added camera movement

This commit is contained in:
2026-04-24 13:23:15 +02:00
parent af1e96ce6d
commit d7efcff2c8
3 changed files with 83 additions and 14 deletions

31
include/Camera.hpp Normal file
View File

@@ -0,0 +1,31 @@
#pragma once
#include "glm/glm.hpp"
#include "glm/ext/matrix_transform.hpp"
#include "glm/gtc/matrix_transform.hpp"
class Camera {
private:
glm::mat4 projection;
glm::mat4 view;
glm::mat4 viewProj;
public:
Camera(float fov, float width, float height) {
projection = glm::perspective(fov/2.0f, width/height, 0.1f, 1000.f);
view = glm::mat4(1.0f);
update();
}
glm::mat4 getViewProj() {
return viewProj;
}
void update() {
viewProj = projection * view;
}
void translate(glm::vec3 v) {
view = glm::translate(view, v*-1.0f);
}
};