|
t
|
The perspective projection camera. More...
#include <PerspectiveCamera.hpp>
Public Member Functions | |
| PerspectiveCamera (double _verticalFov, double _aspectRatio, double _near, double _far) | |
| Creates a new perspective camera. | |
Public Member Functions inherited from t::Camera | |
| Camera (const Matrix4x4 &projectionMatrix) | |
| Creates a new camera instance with the specified projection matrix. | |
Public Member Functions inherited from t::Object3D | |
| virtual bool | isMesh () const |
| Returns whether this 3D object is a mesh. | |
| virtual bool | isLight () const |
| Returns whether this 3D object is a light. | |
| Object3D & | add (Object3D &child) |
| Adds another 3D object as a child of this 3D object. | |
| Object3D & | translate (double x, double y, double z) |
| Translates this 3D object by the specified amounts along the x, y, and z axes in local space. | |
| Object3D & | rotate (double x, double y, double z, EulerRotationOrder order) |
| Rotates this 3D object by the specified angles around the x, y, and z axes in local space. | |
| Object3D & | scale (double x, double y, double z) |
| Scales this 3D object by the specified amounts along the x, y, and z axes in local space. | |
| Object3D & | updateLocalMatrix () |
| Updates the local transformation matrix of this 3D object. | |
| Object3D & | updateModelMatrix () |
| Updates the model matrix of this 3D object. | |
Public Attributes | |
| double | verticalFov |
| The vertical field-of-view of this camera in radians. | |
| double | aspectRatio |
| The aspect ratio of this camera. | |
| double | near |
| The near plane of this camera's view frustum. | |
| double | far |
| The far plane of this camera's view frustum. | |
Public Attributes inherited from t::Camera | |
| Matrix4x4 | projectionMatrix |
| The projection matrix of this camera. | |
Public Attributes inherited from t::Object3D | |
| std::optional< std::reference_wrapper< Object3D > > | parent |
| The parent of this 3D object. | |
| Vector3 | up = DEFAULT_UP |
| The vector pointing to the up direction in object space. | |
| Vector3 | localPosition |
| The position of this 3D object relative to its parent. | |
| EulerRotation | localRotation |
| The rotation of this 3D object relative to its parent. | |
| Vector3 | localScale |
| The scale of this 3D object relative to its parent. | |
| Matrix4x4 | localMatrix |
| The matrix of the local transformation of this 3D object. | |
| Matrix4x4 | modelMatrix |
| The model matrix of this 3D object, transformating local space to world space. | |
| std::vector< std::reference_wrapper< Object3D > > | children |
| The children of this 3D object. | |
The perspective projection camera.
The perspective camera is technically a pinhole camera and is closer to what the human eye and cameras see compared to the orthographic camera. It is the common choice for rendering a 3D scene.
A typical perspective camera instantiation might look like the following:
…where width and height are the output image's width and height.
The perspective camera will use the following projection matrix:
\[ \begin{bmatrix} \frac{1}{a \cdot \tan(v / 2)} & 0 & 0 & 0 \\ 0 & \frac{1}{\tan(v / 2)} & 0 & 0 \\ 0 & 0 & -\frac{f + n}{f - n} & \frac{-2 \cdot f \cdot n}{f - n} \\ 0 & 0 & -1 & 0 \end{bmatrix} \]
…where \(a\), \(v\), \(f\), and \(n\) are the aspect ratio, vertical field-of-view in radians, far plane, and near plane of the camera respectively and define the camera's view frustum.
|
inline |
Creates a new perspective camera.
| _verticalFov | The vertical field-of-view, in radians, for the new camera. |
| _aspectRatio | The aspect ratio of the new camera, usually set to image width divided by image height. |
| _near | The near plane of the view frustum. Objects closer than this to the camera will not be rendered. |
| _far | The far plane of the view frustum. Objects further than this to the camera will not be rendererd. |