-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.h
57 lines (42 loc) · 1.3 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
#pragma once
#include <SDL.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
#include "player.h"
// Default camera values
const float SENSITIVITY = 0.1f;
const float ZOOM = 45.0f;
const bool INVERT = false;
class Camera
{
public:
Camera(const float mouseSensitivity = SENSITIVITY, float fov = ZOOM, bool invertMouse = INVERT)
: m_mouseSensitivity(mouseSensitivity)
, m_fov(fov)
, m_cursorEnabled(true)
, m_invertMouse(invertMouse)
, m_worldUp(glm::vec3(0.0f, 1.0f, 0.0f))
{
updateCameraVectors(glm::vec2(0.0f, 0.0f));
}
~Camera() {
}
void handleMouseMotion(SDL_MouseMotionEvent motion, glm::vec2& currentEulerAngles);
void handleMouseButtonDown(SDL_MouseButtonEvent mouseButtonEvent);
glm::mat4 getViewMatrix(glm::vec3 position);
glm::vec3 getFront() const { return m_front; }
glm::vec3 getUp() const { return m_up; }
glm::vec3 getRight() const { return m_right; }
float& getFov() { return m_fov; }
private:
glm::vec3 m_front;
glm::vec3 m_up;
glm::vec3 m_right;
glm::vec3 m_worldUp;
const float m_mouseSensitivity;
float m_fov;
bool m_cursorEnabled;
bool m_invertMouse;
void updateCameraVectors(glm::vec2 eulerAngles);
};