-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.cpp
More file actions
45 lines (37 loc) · 1.01 KB
/
Copy pathCamera.cpp
File metadata and controls
45 lines (37 loc) · 1.01 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
#include "Camera.h"
Camera::Camera()
: _xRotation(0.0f), _yRotation(0.0f), _zRotation(0.0f), _position(Vertex(0.0f, 0.0f, 0.0f))
{
}
Camera::Camera(float xRotation, float yRotation, float zRotation, const Vertex& position)
: _xRotation(xRotation), _yRotation(yRotation), _zRotation(zRotation), _position(position)
{
}
Camera::Camera(const Camera& other)
: _xRotation(other._xRotation), _yRotation(other._yRotation), _zRotation(other._zRotation), _position(other._position)
{
}
Camera::~Camera()
{
}
Camera& Camera::operator=(const Camera& rhs)
{
if (this != &rhs)
{
_xRotation = rhs._xRotation;
_yRotation = rhs._yRotation;
_zRotation = rhs._zRotation;
_position = rhs._position;
}
return *this;
}
Vertex Camera::GetPosition() const
{
return _position;
}
Matrix Camera::GetViewMatrix()
{
Matrix rotation = Matrix::XYZRotationMatrix(-_xRotation, -_yRotation, -_zRotation);
Matrix translation = Matrix::TranslationMatrix(-_position.GetX(), -_position.GetY(), -_position.GetZ());
return rotation * translation;
}