added camera movement
This commit is contained in:
31
include/Camera.hpp
Normal file
31
include/Camera.hpp
Normal 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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user