Skip to content

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
enumCameraMode { ORBIT, TRACKBALL, NONE}

Public Functions ​

Name
AggregateCamera()
virtual voidcenterOnBox(glm::vec3 boxMin, glm::vec3 boxMax, bool interpolate) override<br>Moves camera so that the specified axis aligned bounding box is visible.
virtual voidcenterOnObjects(const std::vector< const GameObject * > objects) override<br>Moves camera so that the specified objects are visible.
virtual voidcenterOnScene(const Scene & scene) override<br>Moves camera so that all objects in the scene are visible.
virtual voidcenterOnSelection(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::vec3getDirection() const override
virtual floatgetFov() const override
virtual intgetHeight() const override
CameraModegetMode() const
const std::shared_ptr< OrbitCamera > &getOrbitCamera() const
virtual glm::vec3getPosition() const override
virtual glm::mat4getProjection() const override
virtual glm::vec3getRight() const override
const std::shared_ptr< TrackballCamera > &getTrackballCamera() const
virtual glm::vec3getUp() const override
virtual glm::mat4getView() const override
virtual intgetWidth() const override
virtual floatgetZFar() const override
virtual floatgetZNear() const override
voidloadSettings(CameraSettings & stg)
voidloadSettings(GlobalCameraSettings & stg)
virtual voidprocessInput(double dt, glm::vec2 mousePos, glm::ivec2 windowSize) override<br>Updates the internal camera state with user input.
voidsaveSettings(CameraSettings & stg)
voidsaveSettings(GlobalCameraSettings & stg)
virtual voidsetFov(float fov) override
virtual voidsetZFar(float zFar) override
virtual voidsetZNear(float zNear) override
virtual voidsize(int width, int height) override<br>Sets the camera resolution in pixels.
voidswitchMode(CameraMode newMode)
virtual voidupdate() override<br>Recalculates the view and projection matrices based on the internal camera state.
virtual voidviewpoint(AbstractCamera::Viewpoint viewpoint) override<br>Moves the camera to the specified viewpoint.

Protected Attributes ​

Name
std::shared_ptr< AbstractCamera >m_activeCamera
CameraModem_activeMode
std::shared_ptr< OrbitCamera >m_orbitCamera
std::shared_ptr< TrackballCamera >m_trackballCamera

Additional inherited members ​

Public Types inherited from Vp::AbstractCamera

Name
enum classViewpoint { LEFT, RIGHT, TOP, BOTTOM, FRONT, BACK}

Public Functions inherited from Vp::AbstractCamera

Name
virtual~AbstractCamera() =default
voidinterpolate(glm::mat4 from, glm::mat4 to)<br>Begin interpolation from one view matrix to another, the interpolation will take m_interpolationPeriod seconds in realtime.
boolisInterpolating(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::mat4createProjectionMatrix(bool nonShrinking) const

Protected Attributes inherited from Vp::AbstractCamera

Name
glm::mat4interpolationFrom
doubleinterpolationPeriod
std::chrono::time_point< std::chrono::steady_clock, std::chrono::duration< double > >interpolationStart
glm::mat4interpolationTo
glm::vec3m_direction
floatm_fov <br>Vertical field of vision in degrees.
intm_height <br>Camera resolution height in pixels.
glm::vec3m_position
glm::mat4m_projection
glm::vec3m_right
glm::vec3m_up
glm::mat4m_view
intm_width <br>Camera resolution width in pixels.
floatm_zFar <br>Distance to the far clipping pane.
floatm_zNear <br>Distance to the near clipping pane.
boolrightHanded

Detailed Description ​

cpp
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 ​

EnumeratorValueDescription
ORBIT
TRACKBALL
NONE

Public Functions Documentation ​

function AggregateCamera ​

cpp
AggregateCamera()

function centerOnBox ​

cpp
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 ​

cpp
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 ​

cpp
virtual void centerOnScene(
    const Scene & scene
) override

Moves camera so that all objects in the scene are visible.

Reimplements: Vp::AbstractCamera::centerOnScene

function centerOnSelection ​

cpp
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 ​

cpp
const std::shared_ptr< AbstractCamera > & getActiveCamera() const

function getDirection ​

cpp
virtual glm::vec3 getDirection() const override

Reimplements: Vp::AbstractCamera::getDirection

function getFov ​

cpp
virtual float getFov() const override

Reimplements: Vp::AbstractCamera::getFov

function getHeight ​

cpp
virtual int getHeight() const override

Reimplements: Vp::AbstractCamera::getHeight

function getMode ​

cpp
CameraMode getMode() const

function getOrbitCamera ​

cpp
const std::shared_ptr< OrbitCamera > & getOrbitCamera() const

function getPosition ​

cpp
virtual glm::vec3 getPosition() const override

Reimplements: Vp::AbstractCamera::getPosition

function getProjection ​

cpp
virtual glm::mat4 getProjection() const override

Return: The camera projection matrix

Reimplements: Vp::AbstractCamera::getProjection

function getRight ​

cpp
virtual glm::vec3 getRight() const override

Reimplements: Vp::AbstractCamera::getRight

function getTrackballCamera ​

cpp
const std::shared_ptr< TrackballCamera > & getTrackballCamera() const

function getUp ​

cpp
virtual glm::vec3 getUp() const override

Reimplements: Vp::AbstractCamera::getUp

function getView ​

cpp
virtual glm::mat4 getView() const override

Return: The camera view matrix

Reimplements: Vp::AbstractCamera::getView

function getWidth ​

cpp
virtual int getWidth() const override

Reimplements: Vp::AbstractCamera::getWidth

function getZFar ​

cpp
virtual float getZFar() const override

Reimplements: Vp::AbstractCamera::getZFar

function getZNear ​

cpp
virtual float getZNear() const override

Reimplements: Vp::AbstractCamera::getZNear

function loadSettings ​

cpp
void loadSettings(
    CameraSettings & stg
)

function loadSettings ​

cpp
void loadSettings(
    GlobalCameraSettings & stg
)

function processInput ​

cpp
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 saveSettings ​

cpp
void saveSettings(
    CameraSettings & stg
)

function saveSettings ​

cpp
void saveSettings(
    GlobalCameraSettings & stg
)

function setFov ​

cpp
virtual void setFov(
    float fov
) override

Reimplements: Vp::AbstractCamera::setFov

function setZFar ​

cpp
virtual void setZFar(
    float zFar
) override

Reimplements: Vp::AbstractCamera::setZFar

function setZNear ​

cpp
virtual void setZNear(
    float zNear
) override

Reimplements: Vp::AbstractCamera::setZNear

function size ​

cpp
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 ​

cpp
void switchMode(
    CameraMode newMode
)

function update ​

cpp
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 ​

cpp
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 ​

cpp
std::shared_ptr< AbstractCamera > m_activeCamera = nullptr;

variable m_activeMode ​

cpp
CameraMode m_activeMode = CameraMode::NONE;

variable m_orbitCamera ​

cpp
std::shared_ptr< OrbitCamera > m_orbitCamera = nullptr;

variable m_trackballCamera ​

cpp
std::shared_ptr< TrackballCamera > m_trackballCamera = nullptr;

Updated on 2026-09-11 at 21:24:25 +0000