Skip to content

Vp::OrbitCamera

Camera turning around a point using an azimuth and elevation angle. More...

#include "Viewport/camera/OrbitCamera.h"

Inherits from Vp::AbstractOrbitCamera, Vp::AbstractCamera

Public Functions

Name
floatgetRotateSpeed() const
virtual floatgetRotationX() const
virtual floatgetRotationY() const
boolgetSmoothScroll() const
floatgetTranslateSpeed() const
floatgetZoomSpeed() const
virtual voidprocessInput(double dt, glm::vec2 mousePos, glm::ivec2 windowSize) override<br>Updates the internal camera state with user input.
voidsetRotateSpeed(float rotateSpeed)
virtual voidsetRotationX(float rotationX)
virtual voidsetRotationY(float rotationY)
voidsetSmoothScroll(bool b)
voidsetTranslateSpeed(float translateSpeed)
voidsetZoomSpeed(float zoomSpeed)
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 Functions

Name
virtual voidmouseDrag(float dx, float dy, bool rotate, bool pan)
virtual voidmouseWheel(float scroll)

Protected Attributes

Name
floatm_dScroll
boolm_isRotating
floatm_rotateSpeed
boolm_rotateStartedUpsideDown
floatm_rotationX <br>Horizontal rotation, 0 at +X, positive anti-clockwise.
floatm_rotationY
boolm_smoothScroll
floatm_translateSpeed
floatm_zoomSpeed

Additional inherited members

Public Functions inherited from Vp::AbstractOrbitCamera

Name
virtual voidcenterOnBox(glm::vec3 boxMin, glm::vec3 boxMax, bool interpolate) override<br>Moves camera so that the specified axis aligned bounding box is visible.
glm::vec3getPivot() const
floatgetRadius() const
voidsetPivot(const glm::vec3 & pivot)
voidsetRadius(float radius)

Protected Attributes inherited from Vp::AbstractOrbitCamera

Name
glm::vec3m_pivot
floatm_radius

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
virtual voidcenterOnBox(glm::vec3 boxMin, glm::vec3 boxMax, bool interpolate)<br>Moves camera so that the specified axis aligned bounding box is visible.
virtual voidcenterOnObjects(const std::vector< const GameObject * > objects)<br>Moves camera so that the specified objects are visible.
virtual voidcenterOnScene(const Scene & scene)<br>Moves camera so that all objects in the scene are visible.
virtual voidcenterOnSelection(const Scene & scene)<br>Moves camera so that all selected objects in the scene are visible.
virtual glm::vec3getDirection() const
virtual floatgetFov() const
virtual intgetHeight() const
virtual glm::vec3getPosition() const
virtual glm::mat4getProjection() const
virtual glm::vec3getRight() const
virtual glm::vec3getUp() const
virtual glm::mat4getView() const
virtual intgetWidth() const
virtual floatgetZFar() const
virtual floatgetZNear() const
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.
virtual voidsetFov(float fov)
virtual voidsetZFar(float zFar)
virtual voidsetZNear(float zNear)
virtual voidsize(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::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.

Detailed Description

cpp
class Vp::OrbitCamera;
class Vp::OrbitCamera;

Camera turning around a point using an azimuth and elevation angle.

It doesn't roll.

Public Functions Documentation

function getRotateSpeed

cpp
float getRotateSpeed() const
float getRotateSpeed() const

function getRotationX

cpp
virtual float getRotationX() const
virtual float getRotationX() const

function getRotationY

cpp
virtual float getRotationY() const
virtual float getRotationY() const

function getSmoothScroll

cpp
bool getSmoothScroll() const
bool getSmoothScroll() const

function getTranslateSpeed

cpp
float getTranslateSpeed() const
float getTranslateSpeed() const

function getZoomSpeed

cpp
float getZoomSpeed() const
float getZoomSpeed() const

function processInput

cpp
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

cpp
void setRotateSpeed(
    float rotateSpeed
)
void setRotateSpeed(
    float rotateSpeed
)

function setRotationX

cpp
virtual void setRotationX(
    float rotationX
)
virtual void setRotationX(
    float rotationX
)

function setRotationY

cpp
virtual void setRotationY(
    float rotationY
)
virtual void setRotationY(
    float rotationY
)

function setSmoothScroll

cpp
void setSmoothScroll(
    bool b
)
void setSmoothScroll(
    bool b
)

function setTranslateSpeed

cpp
void setTranslateSpeed(
    float translateSpeed
)
void setTranslateSpeed(
    float translateSpeed
)

function setZoomSpeed

cpp
void setZoomSpeed(
    float zoomSpeed
)
void setZoomSpeed(
    float zoomSpeed
)

function update

cpp
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

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

cpp
virtual void mouseDrag(
    float dx,
    float dy,
    bool rotate,
    bool pan
)
virtual void mouseDrag(
    float dx,
    float dy,
    bool rotate,
    bool pan
)

function mouseWheel

cpp
virtual void mouseWheel(
    float scroll
)
virtual void mouseWheel(
    float scroll
)

Protected Attributes Documentation

variable m_dScroll

cpp
float m_dScroll = 0.0f;
float m_dScroll = 0.0f;

variable m_isRotating

cpp
bool m_isRotating = false;
bool m_isRotating = false;

variable m_rotateSpeed

cpp
float m_rotateSpeed = 0.29f;
float m_rotateSpeed = 0.29f;

variable m_rotateStartedUpsideDown

cpp
bool m_rotateStartedUpsideDown = false;
bool m_rotateStartedUpsideDown = false;

variable m_rotationX

cpp
float m_rotationX = -90.0f;
float m_rotationX = -90.0f;

Horizontal rotation, 0 at +X, positive anti-clockwise.

variable m_rotationY

cpp
float m_rotationY = 30.0f;
float m_rotationY = 30.0f;

variable m_smoothScroll

cpp
bool m_smoothScroll = true;
bool m_smoothScroll = true;

variable m_translateSpeed

cpp
float m_translateSpeed = 0.02f;
float m_translateSpeed = 0.02f;

variable m_zoomSpeed

cpp
float m_zoomSpeed = 0.8f;
float m_zoomSpeed = 0.8f;

Updated on 2024-03-16 at 19:15:01 +0000