aboutsummaryrefslogtreecommitdiff
path: root/src/camera/camera.cpp
blob: 78ae4832b691dc6fb817c695577fc58f9e0834cd (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
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
#include <stdexcept>
#include "camera.h"
#include "vec4ops/vec4ops.h"
#include "settings.h"

Camera::Camera(SceneCameraData cameraData) :
    m_pos(cameraData.pos),
    m_heightAngle(cameraData.heightAngle),
    m_focalLength(cameraData.focalLength),
    m_aperture(cameraData.aperture)
{
     m_viewMatrix = Vec4Ops::getViewMatrix4(cameraData.look, cameraData.up, cameraData.over);
     m_translationVector = -cameraData.pos;

     m_inverseViewMatrix = glm::inverse(m_viewMatrix);
     m_inverseTranslationVector = -m_translationVector;
     m_controlPoints = {
        {cameraData.pos[0], cameraData.pos[1], cameraData.pos[2]},
        {cameraData.pos[0], cameraData.pos[1] - 2.f, cameraData.pos[2] - 2.f},
        {cameraData.pos[0] + 2.f, cameraData.pos[1] + 2.f, cameraData.pos[2] -2.f},
        {cameraData.pos[0] + 2.f, cameraData.pos[1], cameraData.pos[2]}
     };
}

glm::mat4 Camera::getViewMatrix() const {
    // Optional TODO: implement the getter or make your own design
    return m_viewMatrix;
}

glm::mat4 Camera::getInverseViewMatrix() const {
    // Optional TODO: implement the getter or make your own design
    return m_inverseViewMatrix;
}

glm::vec4 Camera::getPos() const {
    // Optional TODO: implement the getter or make your own design
    return m_pos;
}

glm::vec4 Camera::getTranslationVector() const {
    return m_translationVector;
}

glm::vec4 Camera::getInverseTranslationVector() const {
    return m_inverseTranslationVector;
}

float Camera::getAspectRatio() const {
    // Optional TODO: implement the getter or make your own design
    throw std::runtime_error("not implemented");
}

float Camera::getHeightAngle() const {
    // Optional TODO: implement the getter or make your own design
    return m_heightAngle;
}

float Camera::getFocalLength() const {
    // Optional TODO: implement the getter or make your own design
    return m_focalLength;
}

float Camera::getAperture() const {
    // Optional TODO: implement the getter or make your own design
    return m_aperture;
}