#ifndef CAMERA_H #define CAMERA_H #include #include class Camera { public: glm::vec3 position; glm::vec3 target; glm::vec3 direction; glm::vec3 up; float speed; glm::vec3 worldUp; Camera(float speed) { this->speed = speed; this->position = glm::vec3(0.0f, 0.0f, 3.0f); this->target = glm::vec3(0.0f, 0.0f, -1.0f); this->direction = glm::normalize(this->position); this->worldUp = glm::vec3(0.0f, 1.0f, 0.0f); glm::vec3 right = glm::normalize(glm::cross(up, this->direction)); this->up = glm::cross(this->direction, right); } Camera(glm::vec3 pos, glm::vec3 target, float speed) { this->speed = speed; this->position = pos; this->target = target; this->direction = glm::normalize(this->position - this->target); this->worldUp = glm::vec3(0.0f, 1.0f, 0.0f); glm::vec3 right = glm::normalize(glm::cross(up, this->direction)); this->up = glm::cross(this->direction, right); } glm::mat4 getView() { return glm::lookAt(this->position, this->target + this->position, this->worldUp); } }; #endif