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 |
| void | loadSettings(CameraSettings & stg) |
| void | loadSettings(GlobalCameraSettings & stg) |
| virtual void | processInput(double dt, glm::vec2 mousePos, glm::ivec2 windowSize) override<br>Updates the internal camera state with user input. |
| void | saveSettings(CameraSettings & stg) |
| void | saveSettings(GlobalCameraSettings & stg) |
| 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. |
| bool | rightHanded |
Detailed Description
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()function centerOnBox
virtual void centerOnBox(
glm::vec3 boxMin,
glm::vec3 boxMax,
bool interpolate
) overrideMoves 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
) overrideMoves camera so that the specified objects are visible.
Reimplements: Vp::AbstractCamera::centerOnObjects
function centerOnScene
virtual void centerOnScene(
const Scene & scene
) overrideMoves camera so that all objects in the scene are visible.
Reimplements: Vp::AbstractCamera::centerOnScene
function centerOnSelection
virtual void centerOnSelection(
const Scene & scene
) overrideMoves camera so that all selected objects in the scene are visible.
Reimplements: Vp::AbstractCamera::centerOnSelection
function getActiveCamera
const std::shared_ptr< AbstractCamera > & getActiveCamera() constfunction getDirection
virtual glm::vec3 getDirection() const overrideReimplements: Vp::AbstractCamera::getDirection
function getFov
virtual float getFov() const overrideReimplements: Vp::AbstractCamera::getFov
function getHeight
virtual int getHeight() const overrideReimplements: Vp::AbstractCamera::getHeight
function getMode
CameraMode getMode() constfunction getOrbitCamera
const std::shared_ptr< OrbitCamera > & getOrbitCamera() constfunction getPosition
virtual glm::vec3 getPosition() const overrideReimplements: Vp::AbstractCamera::getPosition
function getProjection
virtual glm::mat4 getProjection() const overrideReturn: The camera projection matrix
Reimplements: Vp::AbstractCamera::getProjection
function getRight
virtual glm::vec3 getRight() const overrideReimplements: Vp::AbstractCamera::getRight
function getTrackballCamera
const std::shared_ptr< TrackballCamera > & getTrackballCamera() constfunction getUp
virtual glm::vec3 getUp() const overrideReimplements: Vp::AbstractCamera::getUp
function getView
virtual glm::mat4 getView() const overrideReturn: The camera view matrix
Reimplements: Vp::AbstractCamera::getView
function getWidth
virtual int getWidth() const overrideReimplements: Vp::AbstractCamera::getWidth
function getZFar
virtual float getZFar() const overrideReimplements: Vp::AbstractCamera::getZFar
function getZNear
virtual float getZNear() const overrideReimplements: Vp::AbstractCamera::getZNear
function loadSettings
void loadSettings(
CameraSettings & stg
)function loadSettings
void loadSettings(
GlobalCameraSettings & stg
)function processInput
virtual void processInput(
double dt,
glm::vec2 mousePos,
glm::ivec2 windowSize
) overrideUpdates 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
void saveSettings(
CameraSettings & stg
)function saveSettings
void saveSettings(
GlobalCameraSettings & stg
)function setFov
virtual void setFov(
float fov
) overrideReimplements: Vp::AbstractCamera::setFov
function setZFar
virtual void setZFar(
float zFar
) overrideReimplements: Vp::AbstractCamera::setZFar
function setZNear
virtual void setZNear(
float zNear
) overrideReimplements: Vp::AbstractCamera::setZNear
function size
virtual void size(
int width,
int height
) overrideSets 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
)function update
virtual void update() overrideRecalculates 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
) overrideMoves 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;variable m_activeMode
CameraMode m_activeMode = CameraMode::NONE;variable m_orbitCamera
std::shared_ptr< OrbitCamera > m_orbitCamera = nullptr;variable m_trackballCamera
std::shared_ptr< TrackballCamera > m_trackballCamera = nullptr;Updated on 2026-09-11 at 21:24:25 +0000