/
Camera.h
63 lines (49 loc) · 1.25 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
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef CAMERA_H
#define CAMERA_H
#include "Types.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#define DEG_TO_RAD 0.0174532
enum CameraMovement {
FORWARD,
BACKWARD,
LEFT,
RIGHT,
UP,
DOWN
};
class Camera {
public:
// constructor
Camera(const Eigen::Vector3f& pos0 = Eigen::Vector3f(0.0, 0.0, 3.5),
const Eigen::Vector3f& up0 = Eigen::Vector3f(0.0, 1.0, 0.0),
const float& fov0 = 60.0, const float& near0 = 0.1, const float& far0 = 100);
// process keyboard
void processKeyboard(CameraMovement key, const float& dt);
// process mouse
void processMouse(const float& dx, const float& dy);
// process scroll
void processScroll(const float& scroll);
// returns projection matrix
glm::mat4 projectionMatrix(float x, float y);
// returns view matrix
glm::mat4 viewMatrix();
// member variables
Eigen::Vector3f pos;
Eigen::Vector3f dir;
Eigen::Vector3f up;
float fov;
float aspect;
float near;
float far;
private:
// update
void updateDirection();
// member variables
Eigen::Vector3f right;
float yaw;
float pitch;
float speed;
};
#endif