-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamera.h
95 lines (76 loc) · 1.68 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
#ifndef CAMERA_H
#define CAMERA_H
#include "GLIncludes.h"
#include "Vector.h"
#include "Point.h"
#include "Point.cpp" //TODO: fix this 3
class Camera
{
private:
Point3f position;
Vector3f up, forward, right;
public:
Camera(const Point3f &p = Point3f(0.0, 0.0, 0.0)) : position(p), up(0.0, 1.0, 0.0), forward(0.0, 0.0, -1.0), right(1.0, 0.0, 0.0) { }
void orient(bool translate = true) const;
void orientBefore() const
{
orient(false);
}
void rotateX(GLfloat x);
void rotateY(GLfloat y);
void rotateZ(GLfloat z);
void advance(GLfloat scalar)
{
position += forward * scalar;
}
void moveTo(const Point3f &pos)
{
position = pos;
}
void movePos(const Vector3f &vec)
{
position += vec;
}
void move(const Vector3f &vec)
{
position += (vec.getX() * right + vec.getY() * up + vec.getZ() * forward);
}
void lookAt(const Point3f &);
Point3f getPos() const
{
return position;
}
Vector3f getUp() const
{
return up;
}
void setUp(const Vector3f &_up)
{
up = _up;
}
Vector3f getForward() const
{
return forward;
}
void setForward(const Vector3f &_forward)
{
forward = _forward;
}
Vector3f getRight() const
{
return right;
}
void setRight(const Vector3f &_right)
{
right = _right;
}
bool operator==(const Camera &cam) const
{
return (position == cam.position && up == cam.up && forward == cam.forward && right == cam.right);
}
bool operator!=(const Camera &cam) const
{
return !(*this == cam);
}
};
#endif