-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCamera.h
75 lines (71 loc) · 3.53 KB
/
Camera.h
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
68
69
70
71
72
73
74
75
// Copyright 2022, University of Freiburg
// Author: Joel Stanciu
#ifndef CAMERA_H_
#define CAMERA_H_
#include <cmath>
#include <vector>
#include "Matrix.h"
/*
This class represents a Camera Object, which is used as a Camera in the
dimensions of the Terminal. It acts as a viewport from which further
calculations for representing an Object in 3Dimensional Space are
dependent on. It also affects the view of an rotated object in space
*/
class Camera {
public:
// ____________________________________________________________________________
// Constructor
Camera();
// ____________________________________________________________________________
// Getter for private member projectionMatrix_
Matrix& getProjectionMatrix() { return projectionMatrix_; }
// ____________________________________________________________________________
// Getter for private memver viewMatrix_
Matrix& getViewMatrix() { return viewMatrix_; }
// ____________________________________________________________________________
// Getter for the Projection View Matrix which gets calculated
// by multiplying the Projection Matrix with the View Matrix
Matrix& getProjectionViewMatrix() {
return projectionMatrix_ * viewMatrix_; }
// ____________________________________________________________________________
// Getter for the private member position_ (only used in tests)
std::vector<float>& getPosition() { return position_; }
// ____________________________________________________________________________
// Getter for the private member rotation_ (only used in tests)
std::vector<float>& getRotation() { return rotation_; }
// ____________________________________________________________________________
// Getter for the private member fieldOfView_ (only used in tests)
float getFieldOfView() { return fieldOfView_; }
// ____________________________________________________________________________
// Getter for the private member aspectRatio_ (only used in tests)
float getAspectRatio() { return aspectRatio_; }
// ____________________________________________________________________________
// Getter for the private member nearPlane_ (only used in tests)
float getNearPlane() { return nearPlane_; }
// ____________________________________________________________________________
// Getter for the private member farPlane_ (only used in tests)
float getFarPlane() { return farPlane_; }
// ____________________________________________________________________________
// Setter for the private member position_ (only used in tests)
void setPosition(std::vector<float> position);
// ____________________________________________________________________________
// Setter for the private member rotation_ (only used in tests)
void setRotation(std::vector<float> rotation);
// ____________________________________________________________________________
// Setter for the Projection described for further calculations of the
// rotation relative to the camera's setting (setting variables
// as private members)
void setProjection(float fov, float aspectRatio,
float nearPlane, float farPlane);
// ____________________________________________________________________________
// Setter for the viewmatrix, describing the cameras settings as a matrix
void setViewMatrix();
// ____________________________________________________________________________
private:
float fieldOfView_, aspectRatio_, nearPlane_, farPlane_;
std::vector<float> position_;
std::vector<float> rotation_;
Matrix viewMatrix_;
Matrix projectionMatrix_;
};
#endif // CAMERA_H_