-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCamera.cpp
More file actions
43 lines (35 loc) · 841 Bytes
/
Camera.cpp
File metadata and controls
43 lines (35 loc) · 841 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
40
41
42
43
#include "Camera.h"
#include "glm/gtc/matrix_transform.hpp"
Camera::Camera() {
front = glm::vec3(0, 0, -1);
}
Camera::Camera(glm::vec3 position) {
this->position = position;
front = glm::vec3(0, 0, -1);
}
Camera::Camera(glm::vec3 position, glm::vec3 target) {
this->position = position;
front = target - position;
}
Camera::Camera(float x, float y, float z) {
position = glm::vec3(x, y, z);
front = glm::vec3(0, 0, -1);
}
void Camera::setPosition(glm::vec3 position) {
this->position = position;
}
void Camera::setPosition(float x, float y, float z) {
position = glm::vec3(x, y, z);
}
glm::mat4 Camera::getViewMatrix() {
return glm::lookAt(position, position + front, up);
}
glm::vec3 Camera::getFrontVec() {
return front;
}
glm::vec3 Camera::getUp() {
return up;
}
glm::vec3& Camera::getPosition() {
return position;
}