Vp::AggregateCamera
Camera with multiple modes that it can seamlessly switch between. More...
#include "Viewport/camera/AggregateCamera.h"
Inherits from Vp::AbstractCamera
Public Types
Name | |
---|---|
enum | CameraMode { ORBIT, TRACKBALL, NONE} |
Public Functions
Name | |
---|---|
AggregateCamera() | |
virtual void | centerOnBox(glm::vec3 boxMin, glm::vec3 boxMax, bool interpolate) override<br>Moves camera so that the specified axis aligned bounding box is visible. |
virtual void | centerOnObjects(const std::vector< const GameObject * > objects) override<br>Moves camera so that the specified objects are visible. |
virtual void | centerOnScene(const Scene & scene) override<br>Moves camera so that all objects in the scene are visible. |
virtual void | centerOnSelection(const Scene & scene) override<br>Moves camera so that all selected objects in the scene are visible. |
const std::shared_ptr< AbstractCamera > & | getActiveCamera() const |
virtual glm::vec3 | getDirection() const override |
virtual float | getFov() const override |
virtual int | getHeight() const override |
CameraMode | getMode() const |
const std::shared_ptr< OrbitCamera > & | getOrbitCamera() const |
virtual glm::vec3 | getPosition() const override |
virtual glm::mat4 | getProjection() const override |
virtual glm::vec3 | getRight() const override |
const std::shared_ptr< TrackballCamera > & | getTrackballCamera() const |
virtual glm::vec3 | getUp() const override |
virtual glm::mat4 | getView() const override |
virtual int | getWidth() const override |
virtual float | getZFar() const override |
virtual float | getZNear() const override |
virtual void | processInput(double dt, glm::vec2 mousePos, glm::ivec2 windowSize) override<br>Updates the internal camera state with user input. |
virtual void | setFov(float fov) override |
virtual void | setZFar(float zFar) override |
virtual void | setZNear(float zNear) override |
virtual void | size(int width, int height) override<br>Sets the camera resolution in pixels. |
void | switchMode(CameraMode newMode) |
virtual void | update() override<br>Recalculates the view and projection matrices based on the internal camera state. |
virtual void | viewpoint(AbstractCamera::Viewpoint viewpoint) override<br>Moves the camera to the specified viewpoint. |
Protected Attributes
Name | |
---|---|
std::shared_ptr< AbstractCamera > | m_activeCamera |
CameraMode | m_activeMode |
std::shared_ptr< OrbitCamera > | m_orbitCamera |
std::shared_ptr< TrackballCamera > | m_trackballCamera |
Additional inherited members
Public Types inherited from Vp::AbstractCamera
Name | |
---|---|
enum class | Viewpoint { LEFT, RIGHT, TOP, BOTTOM, FRONT, BACK} |
Public Functions inherited from Vp::AbstractCamera
Name | |
---|---|
virtual | ~AbstractCamera() =default |
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. |
Protected Functions inherited from Vp::AbstractCamera
Name | |
---|---|
std::vector< glm::vec3 > | createBoundingBoxWorldPoints(glm::vec3 boxMin, glm::vec3 boxMax, glm::mat4 modelMatrix) |
glm::mat4 | createProjectionMatrix(bool nonShrinking) const |
Protected Attributes inherited from Vp::AbstractCamera
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::AggregateCamera;
class Vp::AggregateCamera;
Camera with multiple modes that it can seamlessly switch between.
Delegates actual "camera work" to one of the cameras that corresponds to the current mode.
Public Types Documentation
enum CameraMode
Enumerator | Value | Description |
---|---|---|
ORBIT | ||
TRACKBALL | ||
NONE |
Public Functions Documentation
function AggregateCamera
AggregateCamera()
AggregateCamera()
function centerOnBox
virtual void centerOnBox(
glm::vec3 boxMin,
glm::vec3 boxMax,
bool interpolate
) override
virtual void centerOnBox(
glm::vec3 boxMin,
glm::vec3 boxMax,
bool interpolate
) override
Moves camera so that the specified axis aligned bounding box is visible.
Reimplements: Vp::AbstractCamera::centerOnBox
function centerOnObjects
virtual void centerOnObjects(
const std::vector< const GameObject * > objects
) override
virtual void centerOnObjects(
const std::vector< const GameObject * > objects
) override
Moves camera so that the specified objects are visible.
Reimplements: Vp::AbstractCamera::centerOnObjects
function centerOnScene
virtual void centerOnScene(
const Scene & scene
) override
virtual void centerOnScene(
const Scene & scene
) override
Moves camera so that all objects in the scene are visible.
Reimplements: Vp::AbstractCamera::centerOnScene
function centerOnSelection
virtual void centerOnSelection(
const Scene & scene
) override
virtual void centerOnSelection(
const Scene & scene
) override
Moves camera so that all selected objects in the scene are visible.
Reimplements: Vp::AbstractCamera::centerOnSelection
function getActiveCamera
const std::shared_ptr< AbstractCamera > & getActiveCamera() const
const std::shared_ptr< AbstractCamera > & getActiveCamera() const
function getDirection
virtual glm::vec3 getDirection() const override
virtual glm::vec3 getDirection() const override
Reimplements: Vp::AbstractCamera::getDirection
function getFov
virtual float getFov() const override
virtual float getFov() const override
Reimplements: Vp::AbstractCamera::getFov
function getHeight
virtual int getHeight() const override
virtual int getHeight() const override
Reimplements: Vp::AbstractCamera::getHeight
function getMode
CameraMode getMode() const
CameraMode getMode() const
function getOrbitCamera
const std::shared_ptr< OrbitCamera > & getOrbitCamera() const
const std::shared_ptr< OrbitCamera > & getOrbitCamera() const
function getPosition
virtual glm::vec3 getPosition() const override
virtual glm::vec3 getPosition() const override
Reimplements: Vp::AbstractCamera::getPosition
function getProjection
virtual glm::mat4 getProjection() const override
virtual glm::mat4 getProjection() const override
Return: The camera projection matrix
Reimplements: Vp::AbstractCamera::getProjection
function getRight
virtual glm::vec3 getRight() const override
virtual glm::vec3 getRight() const override
Reimplements: Vp::AbstractCamera::getRight
function getTrackballCamera
const std::shared_ptr< TrackballCamera > & getTrackballCamera() const
const std::shared_ptr< TrackballCamera > & getTrackballCamera() const
function getUp
virtual glm::vec3 getUp() const override
virtual glm::vec3 getUp() const override
Reimplements: Vp::AbstractCamera::getUp
function getView
virtual glm::mat4 getView() const override
virtual glm::mat4 getView() const override
Return: The camera view matrix
Reimplements: Vp::AbstractCamera::getView
function getWidth
virtual int getWidth() const override
virtual int getWidth() const override
Reimplements: Vp::AbstractCamera::getWidth
function getZFar
virtual float getZFar() const override
virtual float getZFar() const override
Reimplements: Vp::AbstractCamera::getZFar
function getZNear
virtual float getZNear() const override
virtual float getZNear() const override
Reimplements: Vp::AbstractCamera::getZNear
function processInput
virtual void processInput(
double dt,
glm::vec2 mousePos,
glm::ivec2 windowSize
) override
virtual void processInput(
double dt,
glm::vec2 mousePos,
glm::ivec2 windowSize
) override
Updates the internal camera state with user input.
Parameters:
- mousePos Mouse position relative to the window size.
- windowSize The window size in pixels.
Reimplements: Vp::AbstractCamera::processInput
function setFov
virtual void setFov(
float fov
) override
virtual void setFov(
float fov
) override
Reimplements: Vp::AbstractCamera::setFov
function setZFar
virtual void setZFar(
float zFar
) override
virtual void setZFar(
float zFar
) override
Reimplements: Vp::AbstractCamera::setZFar
function setZNear
virtual void setZNear(
float zNear
) override
virtual void setZNear(
float zNear
) override
Reimplements: Vp::AbstractCamera::setZNear
function size
virtual void size(
int width,
int height
) override
virtual void size(
int width,
int height
) override
Sets the camera resolution in pixels.
Parameters:
- width Screen width in pixels
- height Screen height in pixels
Reimplements: Vp::AbstractCamera::size
Should be called prior to the Camera::update() method.
function switchMode
void switchMode(
CameraMode newMode
)
void switchMode(
CameraMode newMode
)
function update
virtual void update() override
virtual void update() override
Recalculates the view and projection matrices based on the internal camera state.
Reimplements: Vp::AbstractCamera::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
) override
virtual void viewpoint(
AbstractCamera::Viewpoint viewpoint
) override
Moves the camera to the specified viewpoint.
Parameters:
- viewpoint
Reimplements: Vp::AbstractCamera::viewpoint
Subclasses need to provide their own implementations.
Protected Attributes Documentation
variable m_activeCamera
std::shared_ptr< AbstractCamera > m_activeCamera = nullptr;
std::shared_ptr< AbstractCamera > m_activeCamera = nullptr;
variable m_activeMode
CameraMode m_activeMode = CameraMode::NONE;
CameraMode m_activeMode = CameraMode::NONE;
variable m_orbitCamera
std::shared_ptr< OrbitCamera > m_orbitCamera = nullptr;
std::shared_ptr< OrbitCamera > m_orbitCamera = nullptr;
variable m_trackballCamera
std::shared_ptr< TrackballCamera > m_trackballCamera = nullptr;
std::shared_ptr< TrackballCamera > m_trackballCamera = nullptr;
Updated on 2024-11-06 at 20:16:53 +0000