-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.h
67 lines (51 loc) · 1.55 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
63
64
65
66
67
#ifndef CAMERA_H
#define CAMERA_H
#include "mathLib3D.h"
#include <math.h>
#define CAMERA_MOVE_FORWARD 0
#define CAMERA_MOVE_BACKWARD 1
#define CAMERA_STRAFE_LEFT 2
#define CAMERA_STRAFE_RIGHT 3
/**
* Represents a camera which looks at a 3D scene.
*/
class Camera {
public:
// construct the camera object
Camera(Vec3D camPos, Vec3D camTgt);
// Represents position of the camera in 3D space
Vec3D camPos;
// Represents the point the camera is looking towards
Vec3D camTgt;
// Represents direction from camPos to camTgt
Vec3D camDir;
// Vector pointing directly upwards
Vec3D up;
// Vector pointing to the right from the camera's perspective
Vec3D camRight;
// Vector pointing up from the camera's perspective
Vec3D camUp;
// Vector representing the front of the camera (gets rotated as needed)
Vec3D camFront;
// Angles of rotation for the camera.
float pitch;
float yaw;
// camera movement/rotation speed.
float camSpeed;
float rotSpeed;
// sensitivity of camera rotations
float sens;
// Sets up perspective view
void setupPerspective();
// Looks at the point specified by camFront/camPos.
void lookAt();
// updates the rotation based on computed x/y offsets
void updateRotation(float xoff, float yoff);
// applies rotations to camFront based on the pitch/yaw.
void applyRotation();
// applies movements to camPos based on the input movement array.
void applyMovement(int movement, float speed);
// updates the camera's sensitivity
void setSensitivity(float sens);
};
#endif