This commit is contained in:
Jackson H committed 2024-06-04 10:31:34 -05:00
commit 46df79ca2a
10 files changed
+1054

No files matched your search

+58
View File
@@ -0,0 +1,58 @@
#ifndef CAMERA_H
#define CAMERA_H
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
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