summary refs log tree commit diff
path: root/src/Camera.cpp
blob: 59d677c04311293ff018bd7650cfdf680fb4691b (plain)
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
#include "Camera.hpp"

namespace MC {

Vector<3> Camera::position() {
    return m_position;
}

void Camera::set_position(Vector<3> position) {
    m_position = position;
}

void Camera::move(Vector<3> vector) {
    m_position = m_position + vector;
}

void Camera::move_relative(Vector<3> by) {
    auto rotation = Matrix<4, 4>::rotation(m_angles);

    auto result = rotation.transpose() * Vector<4>{by.x(), by.y(), by.z(), 1.0f};
    move(result.elements);
}

Rotation Camera::angles() {
    return m_angles;
}

void Camera::set_angles(Rotation angles) {
    m_angles = angles;
}

void Camera::rotate(Rotation by) {
    m_angles = m_angles + by;
}

}