2021-12-07 03:44:47 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "simpleengine/gfx/shader.h"
|
|
|
|
#include "event/event.h"
|
|
|
|
|
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
|
|
|
|
#include <glm/ext/matrix_clip_space.hpp>
|
|
|
|
#include <glm/ext/matrix_transform.hpp>
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
|
|
|
|
namespace simpleengine {
|
2022-10-15 03:17:22 +00:00
|
|
|
namespace gfx {
|
|
|
|
class Renderer;
|
|
|
|
}
|
|
|
|
|
2021-12-07 03:44:47 +00:00
|
|
|
class Camera : public simpleengine::Event {
|
2022-10-15 03:17:22 +00:00
|
|
|
friend gfx::Renderer;
|
2021-12-07 03:44:47 +00:00
|
|
|
private:
|
2022-08-19 04:20:53 +00:00
|
|
|
GLFWwindow* window;
|
2022-10-15 03:17:22 +00:00
|
|
|
|
|
|
|
glm::vec3 last_position;
|
|
|
|
glm::vec3 last_rotation;
|
|
|
|
glm::mat4 last_view_matrix;
|
|
|
|
glm::vec3 last_camera_front;
|
2021-12-07 03:44:47 +00:00
|
|
|
public:
|
2022-10-15 03:17:22 +00:00
|
|
|
|
2021-12-07 03:44:47 +00:00
|
|
|
glm::vec3 position;
|
|
|
|
glm::vec3 rotation;
|
|
|
|
gfx::Shader shader;
|
|
|
|
|
|
|
|
glm::mat4 projection_matrix;
|
|
|
|
glm::mat4 view_matrix;
|
2022-08-18 15:34:05 +00:00
|
|
|
glm::vec3 camera_front = glm::vec3(0.0f, 0.0f, -1.0f);
|
|
|
|
glm::vec3 camera_up = glm::vec3(0.0f, 1.0f, 0.0f);
|
2021-12-07 03:44:47 +00:00
|
|
|
|
|
|
|
float fov;
|
2022-08-18 15:34:05 +00:00
|
|
|
float near_plane;
|
2021-12-07 03:44:47 +00:00
|
|
|
float far_plane;
|
2022-08-18 15:34:05 +00:00
|
|
|
float movement_speed = 2.5f;
|
2021-12-07 03:44:47 +00:00
|
|
|
|
|
|
|
Camera(GLFWwindow* window, gfx::Shader shader, float fov = 70, glm::vec3 position = glm::vec3(0.f), glm::vec3 rotation = glm::vec3(0.f),
|
|
|
|
float near_plane = 0.1f, float far_plane = 1000.f, glm::vec3 world_up = glm::vec3(0.f, 1.f, 0.f),
|
|
|
|
glm::vec3 cam_front = glm::vec3(0.f, 0.f, -1.f));
|
|
|
|
|
2021-12-13 03:17:59 +00:00
|
|
|
Camera(GLFWwindow* window, GLuint shader_prog, float fov = 70, glm::vec3 position = glm::vec3(0.f),
|
2021-12-07 03:44:47 +00:00
|
|
|
glm::vec3 rotation = glm::vec3(0.f), float near_plane = 0.1f, float far_plane = 1000.f, glm::vec3 world_up = glm::vec3(0.f, 1.f, 0.f),
|
|
|
|
glm::vec3 cam_front = glm::vec3(0.f, 0.f, -1.f));
|
|
|
|
|
|
|
|
virtual void update(const float& delta_time) override;
|
|
|
|
};
|
|
|
|
}
|