/
camera.h
111 lines (79 loc) · 2.49 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#pragma once
/*Published under The MIT License (MIT)
See LICENSE.TXT*/
// Definitions of the Camera/View port class methods and properties
//
// Sergey Safarov
//
#include <Windows.h>
#include "Libraries\glew\GL\glew.h"
#include "Libraries\freeglut\GL\freeglut.h"
#include "globals.h"
class Camera
{
private:
// A default vector pointing in the direction you are facing
float forwardDefaultVector[3];
// A default vector pointing to the right of where your facing (to describe orientation)
float rightDefaultVector[3];
// A default vector pointing upwards from where you are facing
float upDefaultVector[3];
// The default camera position point
float positionDefault[3];
// Service functions begin
void vectorSet(float* v, float x, float y, float z);
void vectorAdd(float* v1, float* v2);
void vectorCopy(float* v1, float* v2);
void vectorMultiple(float* v, float scalar);
float lengthOfVector(float* v);
void normaliseVector(float* v);
void rotationMatrix(float* matrix, float* axis, float angle);
void multipleVectorBy(float* v1, float* matrix, float* v2);
void rotateAroundVector(float* v1, float* v2, float angle, float* v3);
// Service functions end
public:
Camera(void);
// A vector pointing in the direction you are facing
float forwardVector[3];
// A vector pointing to the right of where your facing (to describe orientation)
float rightVector[3];
// A vector pointing upwards from where you are facing
float upVector[3];
// The camera position point
float position[3];
// The camera speeds
float cameraMoveSpeed;
float cameraTurnSpeed;
// Reset position and orientation to default
void reset(void);
// Transform the OpenGL view matrix for the orientation
void transformOrientation(void);
// Transform the OpenGL view matrix for the translation
void transformTranslation(void);
// Points the camera at the given point in 3d space
void pointAt(float *targetVector);
// Speed up the camera
void speedUp(void);
// Speed down the camera
void speedDown(void);
// Move the camera forward
void moveForward(void);
// Strafe the camera left
void slideLeft(void);
// Strafe the camera right
void slideRight(void);
// Move the camera backward
void moveBackward(void);
// Roll the camera to the right
void rollRight(void);
// Roll the camera to the left
void rollLeft(void);
// Pitch the camera up
void pitchUp(void);
// Pitch the camera down
void pitchDown(void);
// Yaw the camera left
void yawLeft(void);
// Yaw the camera right
void yawRight(void);
};