VkCV Framework
0.0.1
CV Vulkan framework
|
Used to create a camera which governs the view and projection matrices. More...
#include <Camera.hpp>
Public Member Functions | |
Camera () | |
The default constructor of the camera. | |
~Camera () | |
The destructor of the camera (default behavior) | |
void | setPerspective (float fov, float ratio, float near, float far) |
Sets the perspective object according to fov , ratio , near and far . This leads to changes in the projection matrix of the camera. More... | |
const glm::mat4 & | getView () const |
Gets the view matrix of the camera. More... | |
void | lookAt (const glm::vec3 &position, const glm::vec3 ¢er, const glm::vec3 &up) |
Sets the view matrix of the camera according to position , center and up . More... | |
const glm::mat4 & | getProjection () const |
Gets the current projection of the camera. More... | |
glm::mat4 | getMVP () const |
Gets the model-view-projection matrix of the camera with y-axis-correction applied. More... | |
void | getNearFar (float &near, float &far) const |
Gets the near and far bounds of the view frustum of the camera. More... | |
float | getFov () const |
Gets the current field of view of the camera in radians. More... | |
void | setFov (float fov) |
Sets the field of view of the camera to fov in radians. More... | |
float | getRatio () const |
Gets the current aspect ratio of the camera. More... | |
void | setRatio (float ratio) |
Updates the aspect ratio of the camera with ratio and, thus, changes the projection matrix. More... | |
void | setNearFar (float near, float far) |
Sets near and far as new values for the view frustum of the camera. This leads to changes in the projection matrix according to these two values. More... | |
glm::vec3 | getFront () const |
Gets the current front vector of the camera in world space. More... | |
void | setFront (const glm::vec3 &front) |
Sets the front vector of the camera in world space to front . More... | |
const glm::vec3 & | getPosition () const |
Gets the current position of the camera in world space. More... | |
void | setPosition (const glm::vec3 &position) |
Sets the position of the camera to position . More... | |
const glm::vec3 & | getCenter () const |
Gets the center point. More... | |
void | setCenter (const glm::vec3 ¢er) |
Sets center as the new center point. More... | |
void | getAngles (float &pitch, float &yaw) |
Gets the angles of the camera. More... | |
void | setAngles (float pitch, float yaw) |
Sets the angles of the camera. More... | |
float | getPitch () const |
Gets the pitch value of the camera in degrees. More... | |
void | setPitch (float pitch) |
Sets the pitch value of the camera to pitch in degrees. More... | |
float | getYaw () const |
Gets the yaw value of the camera in degrees. More... | |
void | setYaw (float yaw) |
Sets the yaw value of the camera to yaw . More... | |
const glm::vec3 & | getUp () const |
Gets the up vector. More... | |
void | setUp (const glm::vec3 &up) |
Sets up as the new up vector. More... | |
Protected Member Functions | |
void | setView (const glm::mat4 &view) |
Sets the view matrix of the camera to view . More... | |
void | setProjection (const glm::mat4 &projection) |
Sets the projection matrix of the camera to projection . More... | |
Protected Attributes | |
glm::mat4 | m_view |
glm::mat4 | m_projection |
float | m_near |
float | m_far |
glm::vec3 | m_up |
glm::vec3 | m_position |
glm::vec3 | m_center |
Used to create a camera which governs the view and projection matrices.
void vkcv::camera::Camera::getAngles | ( | float & | pitch, |
float & | yaw | ||
) |
Gets the angles of the camera.
[out] | pitch | The pitch value in radians |
[out] | yaw | The yaw value in radians |
References getFront().
const glm::vec3 & vkcv::camera::Camera::getCenter | ( | ) | const |
Gets the center point.
Referenced by vkcv::camera::TrackballCameraController::updateCamera(), and vkcv::camera::TrackballCameraController::updateRadius().
float vkcv::camera::Camera::getFov | ( | ) | const |
Gets the current field of view of the camera in radians.
Referenced by vkcv::camera::PilotCameraController::changeFov(), setNearFar(), and setRatio().
glm::vec3 vkcv::camera::Camera::getFront | ( | ) | const |
Gets the current front vector of the camera in world space.
Referenced by getAngles(), getPitch(), getYaw(), and vkcv::camera::PilotCameraController::updateCamera().
glm::mat4 vkcv::camera::Camera::getMVP | ( | ) | const |
Gets the model-view-projection matrix of the camera with y-axis-correction applied.
void vkcv::camera::Camera::getNearFar | ( | float & | near, |
float & | far | ||
) | const |
Gets the near and far bounds of the view frustum of the camera.
[out] | near | The near bound of the view frustum |
[out] | far | The far bound of the view frustum |
float vkcv::camera::Camera::getPitch | ( | ) | const |
Gets the pitch value of the camera in degrees.
References getFront().
Referenced by vkcv::camera::PilotCameraController::panView(), and setYaw().
const glm::vec3 & vkcv::camera::Camera::getPosition | ( | ) | const |
Gets the current position of the camera in world space.
Referenced by vkcv::camera::PilotCameraController::updateCamera(), and vkcv::camera::TrackballCameraController::updateRadius().
const glm::mat4 & vkcv::camera::Camera::getProjection | ( | ) | const |
Gets the current projection of the camera.
float vkcv::camera::Camera::getRatio | ( | ) | const |
Gets the current aspect ratio of the camera.
Referenced by setFov(), and setNearFar().
const glm::vec3 & vkcv::camera::Camera::getUp | ( | ) | const |
Gets the up vector.
Referenced by vkcv::camera::PilotCameraController::updateCamera().
const glm::mat4 & vkcv::camera::Camera::getView | ( | ) | const |
Gets the view matrix of the camera.
float vkcv::camera::Camera::getYaw | ( | ) | const |
Gets the yaw value of the camera in degrees.
References getFront().
Referenced by vkcv::camera::PilotCameraController::panView(), and setPitch().
void vkcv::camera::Camera::lookAt | ( | const glm::vec3 & | position, |
const glm::vec3 & | center, | ||
const glm::vec3 & | up | ||
) |
Sets the view matrix of the camera according to position
, center
and up
.
[in] | position | The position of the camera |
[in] | center | The target position the camera is looking at |
[in] | up | The vector that defines which direction is 'up' depending on the camera's orientation |
References setView().
Referenced by Camera(), setCenter(), setPosition(), setUp(), vkcv::camera::TrackballCameraController::updateCamera(), and vkcv::camera::PilotCameraController::updateCamera().
void vkcv::camera::Camera::setAngles | ( | float | pitch, |
float | yaw | ||
) |
Sets the angles of the camera.
pitch | The new pitch value in radians |
yaw | The new yaw value in radians |
References setFront().
Referenced by setPitch(), and setYaw().
void vkcv::camera::Camera::setCenter | ( | const glm::vec3 & | center | ) |
Sets center
as the new center point.
[in] | center | The new center point. |
References lookAt().
Referenced by setFront().
void vkcv::camera::Camera::setFov | ( | float | fov | ) |
Sets the field of view of the camera to fov
in radians.
[in] | fov | The new field of view in radians |
References getRatio(), and setPerspective().
Referenced by vkcv::camera::PilotCameraController::changeFov().
void vkcv::camera::Camera::setFront | ( | const glm::vec3 & | front | ) |
Sets the front vector of the camera in world space to front
.
[in] | front | The new front vector of the camera |
References setCenter().
Referenced by setAngles().
void vkcv::camera::Camera::setNearFar | ( | float | near, |
float | far | ||
) |
Sets near
and far
as new values for the view frustum of the camera. This leads to changes in the projection matrix according to these two values.
[in] | near | The new near bound of the view frustum |
[in] | far | The new far bound of the view frustum |
References getFov(), getRatio(), and setPerspective().
void vkcv::camera::Camera::setPerspective | ( | float | fov, |
float | ratio, | ||
float | near, | ||
float | far | ||
) |
Sets the perspective object according to fov
, ratio
, near
and far
. This leads to changes in the projection matrix of the camera.
[in] | fov | The desired field of view in radians |
[in] | ratio | The aspect ratio |
[in] | near | Distance to near clipping plane |
[in] | far | Distance to far clipping plane |
References setProjection().
Referenced by vkcv::camera::CameraManager::addCamera(), setFov(), setNearFar(), and setRatio().
void vkcv::camera::Camera::setPitch | ( | float | pitch | ) |
Sets the pitch value of the camera to pitch
in degrees.
[in] | pitch | The new pitch value in degrees. |
References getYaw(), and setAngles().
Referenced by vkcv::camera::PilotCameraController::panView().
void vkcv::camera::Camera::setPosition | ( | const glm::vec3 & | position | ) |
Sets the position of the camera to position
.
[in] | position | The new position of the camera |
References lookAt().
|
protected |
Sets the projection matrix of the camera to projection
.
[in] | projection | The projection matrix |
Referenced by setPerspective().
void vkcv::camera::Camera::setRatio | ( | float | ratio | ) |
Updates the aspect ratio of the camera with ratio
and, thus, changes the projection matrix.
[in] | ratio | The new aspect ratio of the camera |
References getFov(), and setPerspective().
Referenced by vkcv::camera::CameraManager::resizeCallback().
void vkcv::camera::Camera::setUp | ( | const glm::vec3 & | up | ) |
Sets up
as the new up vector.
[in] | up | The new up vector. |
References lookAt().
|
protected |
Sets the view matrix of the camera to view
.
[in] | view | The view matrix |
Referenced by lookAt().
void vkcv::camera::Camera::setYaw | ( | float | yaw | ) |
Sets the yaw value of the camera to yaw
.
[in] | yaw | The new yaw value in degrees. |
References getPitch(), and setAngles().
Referenced by vkcv::camera::PilotCameraController::panView().