-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.hpp
More file actions
69 lines (50 loc) · 1.31 KB
/
camera.hpp
File metadata and controls
69 lines (50 loc) · 1.31 KB
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
63
64
65
66
67
68
69
#ifndef CAMERA_H
#define CAMERA_H
#define GLFW_INCLUDE_NONE
#include <GLFW/glfw3.h>
#include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp"
#include "glm/gtc/type_ptr.hpp"
#include "shader.hpp"
extern bool showImGui;
class Camera {
public:
void Init(float curX, float curY);
void Update(float deltaTime);
void OnKeyPress(int key, int action);
void OnMouseMove(float xPos, float yPos);
void OnScroll(float yOffset);
void Disable();
void Enable();
glm::mat4 GetViewMatrix();
glm::mat4 GetProjectionMatrix();
glm::vec3 GetPosition();
glm::vec3 GetDirection();
private:
const float DISPLAY_WIDTH = 1200.0f;
const float DISPLAY_HEIGHT = 900.0f;
const float MOVE_SPEED = 2.5f;
const float MOUSE_SENSITIVITY = 0.1f;
bool enabled = true;
glm::mat4 view = glm::mat4(1.0f);
glm::mat4 projection = glm::mat4(1.0f);
// movement
bool upKeyDown = false;
bool downKeyDown = false;
bool leftKeyDown = false;
bool rightKeyDown = false;
glm::vec3 cameraPos = glm::vec3(-3.1f, 3.2f, 5.2f);
// camera direction
float yaw = -58.6f;
float pitch = -22.0f;
float lastX = 400;
float lastY = 300;
glm::vec3 cameraFront = glm::vec3(5.0f, 1.0f, -1.0f);
glm::vec3 cameraUp = glm::vec3(0.0f, 1.0f, 0.0f);
// Zoom
float fov = 45.0f;
void _Move(float deltaTime);
void _Tilt();
void _Zoom();
};
#endif CAMERA_H