VkCV Framework  0.0.1
CV Vulkan framework
vkcv::camera::Camera Class Referencefinal

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 &center, 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 &center)
 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
 

Detailed Description

Used to create a camera which governs the view and projection matrices.

Member Function Documentation

◆ getAngles()

void vkcv::camera::Camera::getAngles ( float &  pitch,
float &  yaw 
)

Gets the angles of the camera.

Parameters
[out]pitchThe pitch value in radians
[out]yawThe yaw value in radians

References getFront().

Here is the call graph for this function:

◆ getCenter()

const glm::vec3 & vkcv::camera::Camera::getCenter ( ) const

Gets the center point.

Returns
The center point.

Referenced by vkcv::camera::TrackballCameraController::updateCamera(), and vkcv::camera::TrackballCameraController::updateRadius().

Here is the caller graph for this function:

◆ getFov()

float vkcv::camera::Camera::getFov ( ) const

Gets the current field of view of the camera in radians.

Returns
[in] The current field of view in radians

Referenced by vkcv::camera::PilotCameraController::changeFov(), setNearFar(), and setRatio().

Here is the caller graph for this function:

◆ getFront()

glm::vec3 vkcv::camera::Camera::getFront ( ) const

Gets the current front vector of the camera in world space.

Returns
The current front vector of the camera

Referenced by getAngles(), getPitch(), getYaw(), and vkcv::camera::PilotCameraController::updateCamera().

Here is the caller graph for this function:

◆ getMVP()

glm::mat4 vkcv::camera::Camera::getMVP ( ) const

Gets the model-view-projection matrix of the camera with y-axis-correction applied.

Returns
The model-view-projection matrix

◆ getNearFar()

void vkcv::camera::Camera::getNearFar ( float &  near,
float &  far 
) const

Gets the near and far bounds of the view frustum of the camera.

Parameters
[out]nearThe near bound of the view frustum
[out]farThe far bound of the view frustum

◆ getPitch()

float vkcv::camera::Camera::getPitch ( ) const

Gets the pitch value of the camera in degrees.

Returns
The pitch value in degrees.

References getFront().

Referenced by vkcv::camera::PilotCameraController::panView(), and setYaw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPosition()

const glm::vec3 & vkcv::camera::Camera::getPosition ( ) const

Gets the current position of the camera in world space.

Returns
The current position of the camera in world space

Referenced by vkcv::camera::PilotCameraController::updateCamera(), and vkcv::camera::TrackballCameraController::updateRadius().

Here is the caller graph for this function:

◆ getProjection()

const glm::mat4 & vkcv::camera::Camera::getProjection ( ) const

Gets the current projection of the camera.

Returns
The current projection matrix

◆ getRatio()

float vkcv::camera::Camera::getRatio ( ) const

Gets the current aspect ratio of the camera.

Returns
The current aspect ratio of the camera

Referenced by setFov(), and setNearFar().

Here is the caller graph for this function:

◆ getUp()

const glm::vec3 & vkcv::camera::Camera::getUp ( ) const

Gets the up vector.

Returns
The up vector.

Referenced by vkcv::camera::PilotCameraController::updateCamera().

Here is the caller graph for this function:

◆ getView()

const glm::mat4 & vkcv::camera::Camera::getView ( ) const

Gets the view matrix of the camera.

Returns
The view matrix of the camera

◆ getYaw()

float vkcv::camera::Camera::getYaw ( ) const

Gets the yaw value of the camera in degrees.

Returns
The yaw value in degrees.

References getFront().

Referenced by vkcv::camera::PilotCameraController::panView(), and setPitch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ lookAt()

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.

Parameters
[in]positionThe position of the camera
[in]centerThe target position the camera is looking at
[in]upThe 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setAngles()

void vkcv::camera::Camera::setAngles ( float  pitch,
float  yaw 
)

Sets the angles of the camera.

Parameters
pitchThe new pitch value in radians
yawThe new yaw value in radians

References setFront().

Referenced by setPitch(), and setYaw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCenter()

void vkcv::camera::Camera::setCenter ( const glm::vec3 &  center)

Sets center as the new center point.

Parameters
[in]centerThe new center point.

References lookAt().

Referenced by setFront().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFov()

void vkcv::camera::Camera::setFov ( float  fov)

Sets the field of view of the camera to fov in radians.

Parameters
[in]fovThe new field of view in radians

References getRatio(), and setPerspective().

Referenced by vkcv::camera::PilotCameraController::changeFov().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setFront()

void vkcv::camera::Camera::setFront ( const glm::vec3 &  front)

Sets the front vector of the camera in world space to front.

Parameters
[in]frontThe new front vector of the camera

References setCenter().

Referenced by setAngles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setNearFar()

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.

Parameters
[in]nearThe new near bound of the view frustum
[in]farThe new far bound of the view frustum

References getFov(), getRatio(), and setPerspective().

Here is the call graph for this function:

◆ 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.

Parameters
[in]fovThe desired field of view in radians
[in]ratioThe aspect ratio
[in]nearDistance to near clipping plane
[in]farDistance to far clipping plane

References setProjection().

Referenced by vkcv::camera::CameraManager::addCamera(), setFov(), setNearFar(), and setRatio().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPitch()

void vkcv::camera::Camera::setPitch ( float  pitch)

Sets the pitch value of the camera to pitch in degrees.

Parameters
[in]pitchThe new pitch value in degrees.

References getYaw(), and setAngles().

Referenced by vkcv::camera::PilotCameraController::panView().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPosition()

void vkcv::camera::Camera::setPosition ( const glm::vec3 &  position)

Sets the position of the camera to position.

Parameters
[in]positionThe new position of the camera

References lookAt().

Here is the call graph for this function:

◆ setProjection()

void vkcv::camera::Camera::setProjection ( const glm::mat4 &  projection)
protected

Sets the projection matrix of the camera to projection.

Parameters
[in]projectionThe projection matrix

Referenced by setPerspective().

Here is the caller graph for this function:

◆ setRatio()

void vkcv::camera::Camera::setRatio ( float  ratio)

Updates the aspect ratio of the camera with ratio and, thus, changes the projection matrix.

Parameters
[in]ratioThe new aspect ratio of the camera

References getFov(), and setPerspective().

Referenced by vkcv::camera::CameraManager::resizeCallback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setUp()

void vkcv::camera::Camera::setUp ( const glm::vec3 &  up)

Sets up as the new up vector.

Parameters
[in]upThe new up vector.

References lookAt().

Here is the call graph for this function:

◆ setView()

void vkcv::camera::Camera::setView ( const glm::mat4 &  view)
protected

Sets the view matrix of the camera to view.

Parameters
[in]viewThe view matrix

Referenced by lookAt().

Here is the caller graph for this function:

◆ setYaw()

void vkcv::camera::Camera::setYaw ( float  yaw)

Sets the yaw value of the camera to yaw.

Parameters
[in]yawThe new yaw value in degrees.

References getPitch(), and setAngles().

Referenced by vkcv::camera::PilotCameraController::panView().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: