Program Listing for File PerspectiveCamera.hpp
↰ Return to documentation for file (engine/include/Cacao/PerspectiveCamera.hpp
)
#pragma once
#include "Camera.hpp"
#include "DllHelper.hpp"
#include "glm/glm.hpp"
namespace Cacao {
class CACAO_API PerspectiveCamera : public Camera {
public:
PerspectiveCamera(float fov = 60);
glm::vec3 GetPosition() const override {
return position;
}
void SetPosition(glm::vec3 pos) override {
position = pos;
RecalculateViewMatrix();
}
glm::vec3 GetRotation() const override {
return rotation;
}
void SetRotation(glm::vec3 rot) override {
rotation = rot;
RecalculateViewMatrix();
}
float GetFOV() const {
return fov;
}
void SetFOV(float newFov) {
fov = newFov;
RecalculateProjectionMatrix();
}
glm::mat4 GetProjectionMatrix() const override {
return projectionMatrix;
}
glm::mat4 GetViewMatrix() const override {
return viewMatrix;
}
glm::vec3 GetFrontVector() const {
return frontVec;
}
glm::vec3 GetRightVector() const {
return rightVec;
}
glm::vec3 GetUpVector() const {
return upVec;
}
glm::vec3 GetLookTarget() const {
return position + frontVec;
}
void ResizeProjectionMatrix(Event& e) override;
private:
glm::mat4 projectionMatrix, viewMatrix, viewProjectionMatrix;
glm::vec3 position, rotation;
glm::vec3 frontVec, upVec, rightVec;
glm::uvec2 displaySize;
float fov;
//Recalculate the view matrix based on a new position and rotation
void RecalculateViewMatrix();
//Recalculate the projection matrix based on a new FOV and display size
void RecalculateProjectionMatrix();
//Recalculate camera rotation vectors
void RecalculateCameraVectors();
};
}