t
Loading...
Searching...
No Matches
PerspectiveCamera.hpp
1#include "cameras/Camera.hpp"
2#include <cmath>
3
4#ifndef PERSPECTIVECAMERA_HPP
5#define PERSPECTIVECAMERA_HPP
6
7namespace t {
8
38class PerspectiveCamera : public Camera {
39public:
40 double verticalFov;
42 double aspectRatio;
43 double near;
44 double far;
58 PerspectiveCamera(double _verticalFov, double _aspectRatio, double _near,
59 double _far)
60 : Camera(Matrix4x4(1.0 / (_aspectRatio * std::tan(_verticalFov / 2.0)), 0,
61 0, 0, 0, 1.0 / std::tan(_verticalFov / 2), 0, 0, 0, 0,
62 -(_far + _near) / (_far - _near),
63 (-2.0 * _far * _near) / (_far - _near), 0, 0, -1, 0)),
64 verticalFov(_verticalFov), aspectRatio(_aspectRatio), near(_near),
65 far(_far) {}
66};
67
68} // namespace t
69
70#endif // PERSPECTIVECAMERA_HPP
The base camera class.
Definition Camera.hpp:26
The matrix class.
Definition Matrix4x4.hpp:35
The perspective projection camera.
Definition PerspectiveCamera.hpp:38
double aspectRatio
The aspect ratio of this camera.
Definition PerspectiveCamera.hpp:42
PerspectiveCamera(double _verticalFov, double _aspectRatio, double _near, double _far)
Creates a new perspective camera.
Definition PerspectiveCamera.hpp:58
double verticalFov
The vertical field-of-view of this camera in radians.
Definition PerspectiveCamera.hpp:40
double far
The far plane of this camera's view frustum.
Definition PerspectiveCamera.hpp:44
double near
The near plane of this camera's view frustum.
Definition PerspectiveCamera.hpp:43
The t software 3D graphics library namespace.
Definition algorithms.hpp:12