-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.h
More file actions
64 lines (50 loc) · 1.74 KB
/
Camera.h
File metadata and controls
64 lines (50 loc) · 1.74 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
#ifndef CAMERA
#define CAMERA
#include <glm/glm.hpp>
class Camera {
public:
Camera() {}
~Camera() {}
void init(int screenWidth, int screenHeight);
void update();
void moveForward(float speed);
void moveBackward(float speed);
void moveRight(float speed);
void moveLeft(float speed);
void moveUp(float speed);
void moveDown(float speed);
void rotateUp(float speed);
void rotateDown(float speed);
void rotateLeft(float speed);
void rotateRight(float speed);
glm::vec3 screenToWorldCoords(float mouseX, float mouseY);
glm::vec2 screenToNDC();
float getPitch() { return _pitch; }
float getYaw() { return _yaw; }
float getRoll() { return _roll; }
float getSensitivity() { return _sensitivity;}
void setPitch(float pitch) { _pitch = pitch; }
void setYaw(float yaw) { _yaw = yaw; }
void setRoll(float roll) { _roll = roll; }
void setSensitivity(float sensitivity) { _sensitivity = sensitivity; }
float getScreenWidth() {return _screenWidth;}
float getScreenHeight() {return _screenHeight;}
glm::mat4 createProjectionMatrix();
glm::mat4 getProjectionMatrix();
glm::mat4 getViewMatrix();
glm::vec3 getPosition() { return _position; }
glm::vec3 getDirection() {return _direction;}
glm::ivec2 getMouseCoords() {return _mouseCoords;}
void setPosition(float x, float y, float z) { _position = glm::vec3(x,y,z); }
void setMouseCords(float x, float y) {_mouseCoords = glm::vec2(x,y);}
private:
int _screenWidth, _screenHeight;
float _fov;
float _zNear, _zFar;
float _pitch, _yaw, _roll;
float _sensitivity;
glm::vec3 _position, _direction, _up, _right;
glm::mat4 _projectionMatrix;
glm::ivec2 _mouseCoords;
};
#endif