-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamera.cpp
More file actions
39 lines (32 loc) · 692 Bytes
/
camera.cpp
File metadata and controls
39 lines (32 loc) · 692 Bytes
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
#include "camera.h"
Camera::Camera()
{
}
QVector3D Camera::getPosition() const
{
return this->position;
}
void Camera::setPosition(QVector3D position)
{
this->position = position;
}
void Camera::setOrientation(QVector3D front, QVector3D right, QVector3D up)
{
this->front = front;
this->right = right;
this->up = up;
}
QMatrix4x4 Camera::getViewMatrix()
{
QMatrix4x4 viewMatrix;
viewMatrix.setToIdentity();
viewMatrix.lookAt(position, position + front, up);
return viewMatrix;
}
QMatrix4x4 Camera::getProjectionMatrix()
{
QMatrix4x4 projectionMatrix;
projectionMatrix.setToIdentity();
projectionMatrix.perspective(fov, aspect_ratio, near, far);
return projectionMatrix;
}