Vp::AbstractCamera
Abstract camera base class. More...
#include "Viewport/camera/AbstractCamera.h"
Inherited by Vp::AbstractOrbitCamera, Vp::AggregateCamera
Public Types
Name | |
---|---|
enum class | Viewpoint { LEFT, RIGHT, TOP, BOTTOM, FRONT, BACK} |
Public Functions
Name | |
---|---|
virtual | ~AbstractCamera() =default |
virtual void | centerOnBox(glm::vec3 boxMin, glm::vec3 boxMax, bool interpolate)<br>Moves camera so that the specified axis aligned bounding box is visible. |
virtual void | centerOnObjects(const std::vector< const GameObject * > objects)<br>Moves camera so that the specified objects are visible. |
virtual void | centerOnScene(const Scene & scene)<br>Moves camera so that all objects in the scene are visible. |
virtual void | centerOnSelection(const Scene & scene)<br>Moves camera so that all selected objects in the scene are visible. |
virtual glm::vec3 | getDirection() const |
virtual float | getFov() const |
virtual int | getHeight() const |
virtual glm::vec3 | getPosition() const |
virtual glm::mat4 | getProjection() const |
virtual glm::vec3 | getRight() const |
virtual glm::vec3 | getUp() const |
virtual glm::mat4 | getView() const |
virtual int | getWidth() const |
virtual float | getZFar() const |
virtual float | getZNear() const |
void | interpolate(glm::mat4 from, glm::mat4 to)<br>Begin interpolation from one view matrix to another, the interpolation will take m_interpolationPeriod seconds in realtime. |
bool | isInterpolating(float & progress) const<br>Checks whether interpolation between view matrices is currently happening. |
virtual void | processInput(double dt, glm::vec2 mousePos, glm::ivec2 windowSize) =0<br>Updates the internal camera state with user input. |
virtual void | setFov(float fov) |
virtual void | setZFar(float zFar) |
virtual void | setZNear(float zNear) |
virtual void | size(int width, int height)<br>Sets the camera resolution in pixels. |
virtual void | update() =0<br>Recalculates the view and projection matrices based on the internal camera state. |
virtual void | viewpoint(AbstractCamera::Viewpoint viewpoint)<br>Moves the camera to the specified viewpoint. |
Protected Functions
Name | |
---|---|
std::vector< glm::vec3 > | createBoundingBoxWorldPoints(glm::vec3 boxMin, glm::vec3 boxMax, glm::mat4 modelMatrix) |
glm::mat4 | createProjectionMatrix(bool nonShrinking) const |
Protected Attributes
Name | |
---|---|
glm::mat4 | interpolationFrom |
double | interpolationPeriod |
std::chrono::time_point< std::chrono::steady_clock, std::chrono::duration< double > > | interpolationStart |
glm::mat4 | interpolationTo |
glm::vec3 | m_direction |
float | m_fov <br>Vertical field of vision in degrees. |
int | m_height <br>Camera resolution height in pixels. |
glm::vec3 | m_position |
glm::mat4 | m_projection |
glm::vec3 | m_right |
glm::vec3 | m_up |
glm::mat4 | m_view |
int | m_width <br>Camera resolution width in pixels. |
float | m_zFar <br>Distance to the far clipping pane. |
float | m_zNear <br>Distance to the near clipping pane. |
Detailed Description
class Vp::AbstractCamera;
class Vp::AbstractCamera;
Abstract camera base class.
Holds a view matrix and projection information. Also contains further information about its view space (position, direction, up and right vectors)
Public Types Documentation
enum Viewpoint
Enumerator | Value | Description |
---|---|---|
LEFT | ||
RIGHT | ||
TOP | ||
BOTTOM | ||
FRONT | ||
BACK |
Public Functions Documentation
function ~AbstractCamera
virtual ~AbstractCamera() =default
virtual ~AbstractCamera() =default
function centerOnBox
virtual void centerOnBox(
glm::vec3 boxMin,
glm::vec3 boxMax,
bool interpolate
)
virtual void centerOnBox(
glm::vec3 boxMin,
glm::vec3 boxMax,
bool interpolate
)
Moves camera so that the specified axis aligned bounding box is visible.
Reimplemented by: Vp::AbstractOrbitCamera::centerOnBox, Vp::AggregateCamera::centerOnBox
function centerOnObjects
virtual void centerOnObjects(
const std::vector< const GameObject * > objects
)
virtual void centerOnObjects(
const std::vector< const GameObject * > objects
)
Moves camera so that the specified objects are visible.
Reimplemented by: Vp::AggregateCamera::centerOnObjects
function centerOnScene
virtual void centerOnScene(
const Scene & scene
)
virtual void centerOnScene(
const Scene & scene
)
Moves camera so that all objects in the scene are visible.
Reimplemented by: Vp::AggregateCamera::centerOnScene
function centerOnSelection
virtual void centerOnSelection(
const Scene & scene
)
virtual void centerOnSelection(
const Scene & scene
)
Moves camera so that all selected objects in the scene are visible.
Reimplemented by: Vp::AggregateCamera::centerOnSelection
function getDirection
virtual glm::vec3 getDirection() const
virtual glm::vec3 getDirection() const
Reimplemented by: Vp::AggregateCamera::getDirection
function getFov
virtual float getFov() const
virtual float getFov() const
Reimplemented by: Vp::AggregateCamera::getFov
function getHeight
virtual int getHeight() const
virtual int getHeight() const
Reimplemented by: Vp::AggregateCamera::getHeight
function getPosition
virtual glm::vec3 getPosition() const
virtual glm::vec3 getPosition() const
Reimplemented by: Vp::AggregateCamera::getPosition
function getProjection
virtual glm::mat4 getProjection() const
virtual glm::mat4 getProjection() const
Return: The camera projection matrix
Reimplemented by: Vp::AggregateCamera::getProjection
function getRight
virtual glm::vec3 getRight() const
virtual glm::vec3 getRight() const
Reimplemented by: Vp::AggregateCamera::getRight
function getUp
virtual glm::vec3 getUp() const
virtual glm::vec3 getUp() const
Reimplemented by: Vp::AggregateCamera::getUp
function getView
virtual glm::mat4 getView() const
virtual glm::mat4 getView() const
Return: The camera view matrix
Reimplemented by: Vp::AggregateCamera::getView
function getWidth
virtual int getWidth() const
virtual int getWidth() const
Reimplemented by: Vp::AggregateCamera::getWidth
function getZFar
virtual float getZFar() const
virtual float getZFar() const
Reimplemented by: Vp::AggregateCamera::getZFar
function getZNear
virtual float getZNear() const
virtual float getZNear() const
Reimplemented by: Vp::AggregateCamera::getZNear
function interpolate
void interpolate(
glm::mat4 from,
glm::mat4 to
)
void interpolate(
glm::mat4 from,
glm::mat4 to
)
Begin interpolation from one view matrix to another, the interpolation will take m_interpolationPeriod seconds in realtime.
Parameters:
- from Start view matrix
- to End view matrix
During that period the getView() method will be returning the interpolated view matrix rather than the one actually stored. This interpolation is independent from any internal parameters of the camera and does not modify it.
function isInterpolating
bool isInterpolating(
float & progress
) const
bool isInterpolating(
float & progress
) const
Checks whether interpolation between view matrices is currently happening.
Parameters:
- progress Reference to which progress is written.
Return: true if interpolating, false otherwise
If interpolating, the progress argument is set to the current progress in range <0, 1>.
function processInput
virtual void processInput(
double dt,
glm::vec2 mousePos,
glm::ivec2 windowSize
) =0
virtual void processInput(
double dt,
glm::vec2 mousePos,
glm::ivec2 windowSize
) =0
Updates the internal camera state with user input.
Parameters:
- mousePos Mouse position relative to the window size.
- windowSize The window size in pixels.
Reimplemented by: Vp::AggregateCamera::processInput, Vp::OrbitCamera::processInput, Vp::TrackballCamera::processInput
function setFov
virtual void setFov(
float fov
)
virtual void setFov(
float fov
)
Reimplemented by: Vp::AggregateCamera::setFov
function setZFar
virtual void setZFar(
float zFar
)
virtual void setZFar(
float zFar
)
Reimplemented by: Vp::AggregateCamera::setZFar
function setZNear
virtual void setZNear(
float zNear
)
virtual void setZNear(
float zNear
)
Reimplemented by: Vp::AggregateCamera::setZNear
function size
virtual void size(
int width,
int height
)
virtual void size(
int width,
int height
)
Sets the camera resolution in pixels.
Parameters:
- width Screen width in pixels
- height Screen height in pixels
Reimplemented by: Vp::AggregateCamera::size
Should be called prior to the Camera::update() method.
function update
virtual void update() =0
virtual void update() =0
Recalculates the view and projection matrices based on the internal camera state.
Reimplemented by: Vp::AggregateCamera::update, Vp::OrbitCamera::update, Vp::TrackballCamera::update
Generally this method should build up a new view matrix from scratch using some arbitrary internal variables. From the calculated view matrix, direction, up, right and position information should be updated.
function viewpoint
virtual void viewpoint(
AbstractCamera::Viewpoint viewpoint
)
virtual void viewpoint(
AbstractCamera::Viewpoint viewpoint
)
Moves the camera to the specified viewpoint.
Parameters:
- viewpoint
Reimplemented by: Vp::AggregateCamera::viewpoint, Vp::OrbitCamera::viewpoint, Vp::TrackballCamera::viewpoint
Subclasses need to provide their own implementations.
Protected Functions Documentation
function createBoundingBoxWorldPoints
std::vector< glm::vec3 > createBoundingBoxWorldPoints(
glm::vec3 boxMin,
glm::vec3 boxMax,
glm::mat4 modelMatrix
)
std::vector< glm::vec3 > createBoundingBoxWorldPoints(
glm::vec3 boxMin,
glm::vec3 boxMax,
glm::mat4 modelMatrix
)
function createProjectionMatrix
glm::mat4 createProjectionMatrix(
bool nonShrinking
) const
glm::mat4 createProjectionMatrix(
bool nonShrinking
) const
Protected Attributes Documentation
variable interpolationFrom
glm::mat4 interpolationFrom;
glm::mat4 interpolationFrom;
variable interpolationPeriod
double interpolationPeriod {0.14f};
double interpolationPeriod {0.14f};
variable interpolationStart
std::chrono::time_point< std::chrono::steady_clock, std::chrono::duration< double > > interpolationStart {};
std::chrono::time_point< std::chrono::steady_clock, std::chrono::duration< double > > interpolationStart {};
variable interpolationTo
glm::mat4 interpolationTo;
glm::mat4 interpolationTo;
variable m_direction
glm::vec3 m_direction = glm::vec3(1.0f, 0.0f, 0.0f);
glm::vec3 m_direction = glm::vec3(1.0f, 0.0f, 0.0f);
variable m_fov
float m_fov = 90.0f;
float m_fov = 90.0f;
Vertical field of vision in degrees.
variable m_height
int m_height {200};
int m_height {200};
Camera resolution height in pixels.
variable m_position
glm::vec3 m_position = glm::vec3(3.0f, 0.0f, 0.0f);
glm::vec3 m_position = glm::vec3(3.0f, 0.0f, 0.0f);
variable m_projection
glm::mat4 m_projection {1.0f};
glm::mat4 m_projection {1.0f};
variable m_right
glm::vec3 m_right = glm::vec3(0.0f, 1.0f, 0.0f);
glm::vec3 m_right = glm::vec3(0.0f, 1.0f, 0.0f);
variable m_up
glm::vec3 m_up = glm::vec3(0.0f, 0.0f, 1.0f);
glm::vec3 m_up = glm::vec3(0.0f, 0.0f, 1.0f);
variable m_view
glm::mat4 m_view {1.0f};
glm::mat4 m_view {1.0f};
variable m_width
int m_width {200};
int m_width {200};
Camera resolution width in pixels.
variable m_zFar
float m_zFar = 270.0f;
float m_zFar = 270.0f;
Distance to the far clipping pane.
variable m_zNear
float m_zNear = 0.2f;
float m_zNear = 0.2f;
Distance to the near clipping pane.
Updated on 2024-11-06 at 20:16:53 +0000