-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.h
More file actions
55 lines (46 loc) · 1.4 KB
/
Copy pathcamera.h
File metadata and controls
55 lines (46 loc) · 1.4 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
#ifndef CAMERA_H
#define CAMERA_H
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <vector>
#include <GLFW/glfw3.h>
#include <glm/gtc/quaternion.hpp>
#include <glm/gtx/quaternion.hpp>
#define WIN_WIDTH 1080
#define WIN_HEIGHT 720
class Camera {
public:
glm::vec3 position;
glm::vec3 front;
glm::vec3 up;
glm::vec3 right;
glm::vec3 worldup;
float fov;
float nearPlane;
float farPlane;
float speed;
float yaw;
float pitch;
float sensitivity;
float lastX = WIN_WIDTH / 2.0f;
float lastY = WIN_HEIGHT / 2.0f;
bool firstMouse = true;
Camera(glm::vec3 pos, glm::vec3 tgt, glm::vec3 upDir, float fieldOfView, float nearP, float farP, float spd, float sens)
: position(pos), front(tgt), up(upDir), worldup(upDir), fov(fieldOfView), nearPlane(nearP), farPlane(farP), speed(spd), yaw(-90.0f), pitch(0.0f), sensitivity(sens) {
updateCameraVectors();
}
glm::mat4 getViewMatrix() const {
return glm::lookAt(position, position + front, up);
}
void changefov(double y);
void rotateCamera(float xoffset, float yoffset);
void moveForward(float deltaTime);
void moveBackward(float deltaTime);
void moveLeft(float deltaTime);
void moveRight(float deltaTime);
void moveUp(float deltaTime);
void moveDown(float deltaTime);
private:
void updateCameraVectors();
};
#endif // CAMERA_H