#ifndef __CAMERA_H__ #define __CAMERA_H__ /* * just a way to conviniently store camera data * ->header only */ #define GLM_ENABLE_EXPERIMENTAL #include #include #include #include #include #include #include #include #include #include #include #include #include #include "largepos.hpp" class camera{ public: // view matrix (aka camera position) glm::mat4 view; // projection matrix (aka camera characteristics) glm::mat4 proj; glm::vec3 pos; //glm::vec3 front; //glm::vec3 up; glm::quat rotation= glm::quat(0.f,0.f,0.f,1.f); glm::vec3 forward; glm::vec3 up; glm::vec3 right; largePos spacePos; void update() { // Z IS ALLWAYS UP glm::quat corrRot=rotation*glm::angleAxis(glm::radians(90.f), glm::vec3(1.f, 0.f, 0.f) * rotation); view = glm::translate(glm::toMat4(corrRot), pos); forward = glm::vec3(0.f,1.f,0.f)*rotation; //view = glm::lookAt(pos, forward+pos, glm::vec3(0.f,0.f,1.f)); up = glm::vec3(0.f,0.f,1.f)*rotation; right = glm::vec3(1.f,0.f, 0.f)*rotation; } void rotate(float angle, const glm::vec3 &axis) { rotation *= glm::angleAxis(angle, axis * rotation); } void rotate(float angle, float x, float y, float z) { rotation *= glm::angleAxis(angle, glm::vec3(x, y, z) * rotation); } void rotateX(float angle) { rotate(glm::radians(angle), 1.f,0.f,0.f); } void rotateY(float angle) { rotate(glm::radians(angle), 0.f,1.f,0.f); } void rotateZ(float angle) { rotate(glm::radians(angle), 0.f,0.f,1.f); } }; #endif