added more camera movement
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include "glm/glm.hpp"
|
||||
#include "glm/ext/matrix_transform.hpp"
|
||||
#include "glm/gtc/matrix_transform.hpp"
|
||||
|
||||
class Camera {
|
||||
private:
|
||||
protected:
|
||||
glm::vec3 position;
|
||||
glm::mat4 projection;
|
||||
glm::mat4 view;
|
||||
glm::mat4 viewProj;
|
||||
@@ -14,6 +14,7 @@ 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);
|
||||
position = glm::vec3(0.0f);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -21,11 +22,12 @@ public:
|
||||
return viewProj;
|
||||
}
|
||||
|
||||
void update() {
|
||||
virtual void update() {
|
||||
viewProj = projection * view;
|
||||
}
|
||||
|
||||
void translate(glm::vec3 v) {
|
||||
virtual void translate(glm::vec3 v) {
|
||||
position += v;
|
||||
view = glm::translate(view, v*-1.0f);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user