-
Notifications
You must be signed in to change notification settings - Fork 0
/
Camera.h
50 lines (34 loc) · 1.12 KB
/
Camera.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once
#include <numbers>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
namespace Vixen {
// TODO: Ideally, the camera should be quaternion based and not euler-angles based.
class Camera {
public:
explicit Camera(
glm::vec3 position = {},
glm::vec3 rotation = {std::numbers::pi, 0.0f, 0.0f},
float fieldOfView = 90.0f,
float nearPlane = 0.1f,
float farPlane = 1000.0f
);
void update(GLFWwindow* window, double deltaTime);
[[nodiscard]] glm::mat4 view() const;
[[nodiscard]] glm::mat4 perspective(float aspectRatio) const;
[[nodiscard]] const glm::vec3& getPosition() const;
[[nodiscard]] glm::vec3 getEulerRotation() const;
[[nodiscard]] float getNearPlane() const;
[[nodiscard]] float getFarPlane() const;
private:
double lastX;
double lastY;
glm::vec3 position;
glm::vec3 rotation;
float fieldOfView;
float nearPlane;
float farPlane;
};
}