Vp::TrackballCamera
Camera turning around a point using a virtual screen-space trackball.
#include "Viewport/camera/TrackballCamera.h"
Inherits from Vp::AbstractOrbitCamera, Vp::AbstractCamera
Public Functions
Name | |
---|---|
float | getRotateSpeed() const |
glm::mat4 | getRotation() const |
bool | getSmoothScroll() const |
float | getTranslateSpeed() const |
float | getZoomSpeed() const |
virtual void | processInput(double dt, glm::vec2 mousePos, glm::ivec2 windowSize) override<br>Updates the internal camera state with user input. |
void | setRotateSpeed(float rotateSpeed) |
void | setRotation(glm::mat4 rotation) |
void | setSmoothScroll(bool b) |
void | setTranslateSpeed(float translateSpeed) |
void | setZoomSpeed(float zoomSpeed) |
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 Functions
Name | |
---|---|
virtual void | mouseWheel(float scroll) |
Protected Attributes
Name | |
---|---|
glm::mat4 | m_accumulatedRotation |
float | m_dScroll |
float | m_rotateSpeed |
bool | m_smoothScroll |
float | m_translateSpeed |
float | m_zoomSpeed |
Additional inherited members
Public Functions inherited from Vp::AbstractOrbitCamera
Name | |
---|---|
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. |
glm::vec3 | getPivot() const |
float | getRadius() const |
void | setPivot(const glm::vec3 & pivot) |
void | setRadius(float radius) |
Protected Attributes inherited from Vp::AbstractOrbitCamera
Name | |
---|---|
glm::vec3 | m_pivot |
float | m_radius |
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 |
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 | 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. |
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. |
Public Functions Documentation
function getRotateSpeed
float getRotateSpeed() const
float getRotateSpeed() const
function getRotation
glm::mat4 getRotation() const
glm::mat4 getRotation() const
function getSmoothScroll
bool getSmoothScroll() const
bool getSmoothScroll() const
function getTranslateSpeed
float getTranslateSpeed() const
float getTranslateSpeed() const
function getZoomSpeed
float getZoomSpeed() const
float getZoomSpeed() const
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 setRotateSpeed
void setRotateSpeed(
float rotateSpeed
)
void setRotateSpeed(
float rotateSpeed
)
function setRotation
void setRotation(
glm::mat4 rotation
)
void setRotation(
glm::mat4 rotation
)
function setSmoothScroll
void setSmoothScroll(
bool b
)
void setSmoothScroll(
bool b
)
function setTranslateSpeed
void setTranslateSpeed(
float translateSpeed
)
void setTranslateSpeed(
float translateSpeed
)
function setZoomSpeed
void setZoomSpeed(
float zoomSpeed
)
void setZoomSpeed(
float zoomSpeed
)
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 Functions Documentation
function mouseWheel
virtual void mouseWheel(
float scroll
)
virtual void mouseWheel(
float scroll
)
Protected Attributes Documentation
variable m_accumulatedRotation
glm::mat4 m_accumulatedRotation = glm::mat4(1);
glm::mat4 m_accumulatedRotation = glm::mat4(1);
variable m_dScroll
float m_dScroll = 0.0f;
float m_dScroll = 0.0f;
variable m_rotateSpeed
float m_rotateSpeed = 0.29f;
float m_rotateSpeed = 0.29f;
variable m_smoothScroll
bool m_smoothScroll = true;
bool m_smoothScroll = true;
variable m_translateSpeed
float m_translateSpeed = 0.02f;
float m_translateSpeed = 0.02f;
variable m_zoomSpeed
float m_zoomSpeed = 0.8f;
float m_zoomSpeed = 0.8f;
Updated on 2025-01-07 at 13:40:44 +0000