Radium Engine  1.5.0
Ra::Gui::TrackballCameraManipulator Class Reference

A Trackball manipulator for Cameras. More...

#include <Gui/Viewer/TrackballCameraManipulator.hpp>

+ Inheritance diagram for Ra::Gui::TrackballCameraManipulator:
+ Collaboration diagram for Ra::Gui::TrackballCameraManipulator:

Public Types

using KeyMapping = KeyMappingManageable< TrackballCameraManipulator >
 

Public Slots

void setCameraPosition (const Core::Vector3 &position) override
 
void setCameraTarget (const Core::Vector3 &target) override
 
void fitScene (const Core::Aabb &aabb) override
 
void resetCamera () override
 
- Public Slots inherited from Ra::Gui::CameraManipulator
void mapCameraBehaviourToAabb (const Core::Aabb &aabb)
 Set the AABB to restrain the camera behavior against.
 
void unmapCameraBehaviourToAabb ()
 Free the camera from AABB restriction.
 
virtual void fitScene (const Core::Aabb &aabb)=0
 Setup the Camera according to the AABB of the scene to render.
 
virtual void setCameraPosition (const Core::Vector3 &position)=0
 Set the Camera position to position.
 
virtual void setCameraTarget (const Core::Vector3 &target)=0
 Set the Camera target to target.
 
virtual void resetCamera ()=0
 Reset the Camera settings to default values.
 
void setCameraSensitivity (Scalar sensitivity)
 
void setCameraFov (Scalar fov)
 
void setCameraFovInDegrees (Scalar fov)
 
void setCameraZNear (Scalar zNear)
 
void setCameraZFar (Scalar zFar)
 

Public Member Functions

 TrackballCameraManipulator ()
 Default constructor.
 
 TrackballCameraManipulator (const CameraManipulator &other)
 
virtual ~TrackballCameraManipulator ()
 Destructor.
 
bool handleMousePressEvent (QMouseEvent *event, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key) override
 
bool handleMouseReleaseEvent (QMouseEvent *event) override
 
bool handleMouseMoveEvent (QMouseEvent *event, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key) override
 
bool handleWheelEvent (QWheelEvent *event, const Qt::MouseButtons &buttons, const Qt::KeyboardModifiers &modifiers, int key) override
 
bool handleKeyPressEvent (QKeyEvent *event, const KeyMappingManager::KeyMappingAction &action) override
 
void toggleRotateAround ()
 
void updateCamera () override
 
void setTrackballRadius (Scalar rad)
 
Scalar getTrackballRadius () const
 Return the distance from the camera to the target point.
 
const Core::Transform::ConstTranslationPart getTrackballCenter () const
 
KeyMappingManager::Context mappingContext () override
 
- Public Member Functions inherited from Ra::Gui::CameraManipulator
 CameraManipulator ()
 Initializes a manipulator for a given viewport size.
 
 CameraManipulator (const CameraManipulator &other)
 
virtual ~CameraManipulator ()
 
virtual bool handleKeyReleaseEvent (QKeyEvent *event, const KeyMappingManager::KeyMappingAction &action)
 
const Core::Asset::CameragetCamera () const
 Pointer access to the camera.
 
Core::Asset::CameragetCamera ()
 Pointer access to the camera.
 
void attachLight (Engine::Scene::Light *light)
 
bool hasLightAttached () const
 
Engine::Scene::LightgetLight ()
 pointer acces to the attached light if it exists, returns nullptr otherwise.
 

Protected Member Functions

virtual void handleCameraRotate (Scalar dx, Scalar dy)
 
virtual void handleCameraPan (Scalar dx, Scalar dy)
 
virtual void handleCameraZoom (Scalar dx, Scalar dy)
 
virtual void handleCameraZoom (Scalar z)
 
virtual void handleCameraMoveForward (Scalar dx, Scalar dy)
 
virtual void handleCameraMoveForward (Scalar z)
 
void updatePhiTheta ()
 Update the polar coordinates of the Camera w.r.t. the trackball center.
 
- Protected Member Functions inherited from Ra::Gui::CameraManipulator
std::pair< Scalar, Scalar > computeDeltaMouseMove (const QMouseEvent *mouseEvent)
 
- Protected Member Functions inherited from Ra::Gui::KeyMappingManageable< TrackballCameraManipulator >
TrackballCameraManipulatorself ()
 

Protected Attributes

Scalar m_phi { 0_ra }
 
Scalar m_theta { 0_ra }
 
Scalar m_phiDir { 1_ra }
 sign of m_theta at mousePressEvent, to guide the phi rotation direction.
 
Core::Transform m_referenceFrame
 initial frame of the camera, centered on target, to compute angles.
 
Scalar m_distFromCenter { 0_ra }
 The distance from the camera to the trackball center.
 
KeyMappingCallbackManager m_keyMappingCallbackManager
 
- Protected Attributes inherited from Ra::Gui::CameraManipulator
Scalar m_lastMouseX { 0_ra }
 x-position of the mouse on the screen at the manipulation start.
 
Scalar m_lastMouseY { 0_ra }
 y-position of the mouse on the screen at the manipulation start.
 
Scalar m_cameraSensitivity { 1_ra }
 the Camera sensitivity to manipulation.
 
Scalar m_quickCameraModifier { 1_ra }
 Additional factor for camera sensitivity.
 
Scalar m_wheelSpeedModifier { 0.02_ra }
 Speed modifier on mouse wheel events.
 
Core::Aabb m_targetedAabb
 Camera behavior restriction AABB.
 
Scalar m_targetedAabbVolume { 0_ra }
 Volume of the m_targetedAabb.
 
bool m_mapCameraBahaviourToAabb { false }
 whether the camera is restrained or not
 
Core::Vector3 m_target { 0_ra, 0_ra, 0_ra }
 
Core::Asset::Cameram_camera { nullptr }
 The Camera.
 
Engine::Scene::Lightm_light { nullptr }
 The light attached to the Camera.
 

Friends

class KeyMappingManageable< TrackballCameraManipulator >
 

Additional Inherited Members

- Static Public Member Functions inherited from Ra::Gui::KeyMappingManageable< TrackballCameraManipulator >
static KeyMappingManager::Context getContext ()
 
static void configureKeyMapping ()
 
- Static Protected Member Functions inherited from Ra::Gui::KeyMappingManageable< TrackballCameraManipulator >
static void setContext (const KeyMappingManager::Context &c)
 

Detailed Description

A Trackball manipulator for Cameras.

Definition at line 13 of file TrackballCameraManipulator.hpp.

Constructor & Destructor Documentation

◆ TrackballCameraManipulator()

Ra::Gui::TrackballCameraManipulator::TrackballCameraManipulator ( const CameraManipulator other)
explicit

Copy constructor used when switching camera manipulator Requires that m_target is on the line of sight of the camera.

Definition at line 79 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ getTrackballCenter()

Core::Transform::ConstTranslationPart Ra::Gui::TrackballCameraManipulator::getTrackballCenter ( ) const

Return the trackball center.

Note
doesn't modify the camera.

Definition at line 137 of file TrackballCameraManipulator.cpp.

◆ handleKeyPressEvent()

bool Ra::Gui::TrackballCameraManipulator::handleKeyPressEvent ( QKeyEvent *  event,
const KeyMappingManager::KeyMappingAction action 
)
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 249 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ handleMouseMoveEvent()

bool Ra::Gui::TrackballCameraManipulator::handleMouseMoveEvent ( QMouseEvent *  event,
const Qt::MouseButtons &  buttons,
const Qt::KeyboardModifiers &  modifiers,
int  key 
)
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 211 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ handleMousePressEvent()

bool Ra::Gui::TrackballCameraManipulator::handleMousePressEvent ( QMouseEvent *  event,
const Qt::MouseButtons &  buttons,
const Qt::KeyboardModifiers &  modifiers,
int  key 
)
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 197 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ handleMouseReleaseEvent()

bool Ra::Gui::TrackballCameraManipulator::handleMouseReleaseEvent ( QMouseEvent *  event)
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 228 of file TrackballCameraManipulator.cpp.

◆ handleWheelEvent()

bool Ra::Gui::TrackballCameraManipulator::handleWheelEvent ( QWheelEvent *  event,
const Qt::MouseButtons &  buttons,
const Qt::KeyboardModifiers &  modifiers,
int  key 
)
overridevirtual
Returns
true if the event has been taken into account, false otherwise

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 233 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ mappingContext()

KeyMappingManager::Context Ra::Gui::TrackballCameraManipulator::mappingContext ( )
overridevirtual
Returns
the mapping context for keymapping, Index::Invalid() if no mapping is available

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 141 of file TrackballCameraManipulator.cpp.

◆ resetCamera

void Ra::Gui::TrackballCameraManipulator::resetCamera ( )
overrideslot
Todo:
get rid of these light stuff

Definition at line 94 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ setTrackballRadius()

void Ra::Gui::TrackballCameraManipulator::setTrackballRadius ( Scalar  rad)

Set the distance from the camera to the target point. update target m_referenceFrame.translation();

Note
doesn't modify the camera.

Definition at line 127 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

◆ updateCamera()

void Ra::Gui::TrackballCameraManipulator::updateCamera ( )
overridevirtual

Reset manipulator internal data according to current active camera from manager. Call each time the active camera is changed to have coherent data.

Reimplemented from Ra::Gui::CameraManipulator.

Definition at line 111 of file TrackballCameraManipulator.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_phi

Scalar Ra::Gui::TrackballCameraManipulator::m_phi { 0_ra }
protected

Spherical coordinates (ISO 80000-2:2019 convention) https://en.wikipedia.org/wiki/Spherical_coordinate_system phi is azimutal theta is polar, from y which is world "up" direction rest pose correspond to camera view direction at m_referenceFrame -z;

Definition at line 95 of file TrackballCameraManipulator.hpp.


The documentation for this class was generated from the following files: