51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
#ifndef CAMERA_H
|
|
#define CAMERA_H
|
|
|
|
#include <glm/mat4x4.hpp>
|
|
#include <glm/vec3.hpp>
|
|
#include <glm/vec2.hpp>
|
|
|
|
class Camera
|
|
{
|
|
bool m_projectionHasChanged;
|
|
bool m_viewHasChanged;
|
|
glm::mat4 m_projectionMatrix;
|
|
glm::mat4 m_viewMatrix;
|
|
float m_fov;
|
|
int m_width;
|
|
int m_height;
|
|
float m_near;
|
|
float m_far;
|
|
glm::vec3 m_position;
|
|
glm::vec2 m_rotation;
|
|
|
|
void computeProjectionMatrix();
|
|
void computeViewMatrix();
|
|
public:
|
|
//constructor
|
|
Camera(int width = 800, int height = 600, float fov_y = 45, float near = 0.1f, float far = 10.0f, glm::vec3 pos = glm::vec3());
|
|
|
|
// setters
|
|
// relative:
|
|
void translate(glm::vec3 vector);
|
|
void relativeTranslate(glm::vec3 vector);
|
|
void rotate(glm::vec2 rad_vector);
|
|
// absolute:
|
|
void zoom(float new_fov_y);
|
|
void resize(int width, int height);
|
|
void setNear(float near);
|
|
void setFar(float far);
|
|
void moveTo(glm::vec3 position);
|
|
void lookAt(glm::vec3 position);
|
|
void lookAt(glm::vec2 rotation);
|
|
|
|
// getters
|
|
glm::mat4 getProjectionMatrix();
|
|
glm::mat4 getViewMatrix();
|
|
|
|
glm::vec2 getRotation();
|
|
glm::vec3 getPosition();
|
|
};
|
|
|
|
#endif // CAMERA_H
|