1#ifndef Magnum_Examples_ArcBall_h
2#define Magnum_Examples_ArcBall_h
33#include <Magnum/Magnum.h>
34#include <Magnum/Math/Functions.h>
35#include <Magnum/Math/DualQuaternion.h>
36#include <Magnum/Math/Vector2.h>
37#include <Magnum/Math/Vector3.h>
39using namespace Magnum;
51 ArcBall(
const Vector3& cameraPosition,
const Vector3& viewCenter,
52 const Vector3& upDir, Deg
fov,
const Vector2i& windowSize);
59 const Vector3 &upDir);
85 void rotate(
const Vector2i &mousePos);
97 void zoom(Float delta);
Implementation of Ken Shoemake's arcball camera with smooth navigation.
Definition ArcBall.h:43
Quaternion _qRotationT0
Definition ArcBall.h:146
Vector3 _positionT0
Definition ArcBall.h:145
void reset()
Reset the camera to its initial position, view center, and up dir.
Definition ArcBall.cpp:85
Vector2 _prevMousePosNDC
Definition ArcBall.h:142
Quaternion _currentQRotation
Definition ArcBall.h:146
Float _zoomingT0
Definition ArcBall.h:147
Quaternion _targetQRotation
Definition ArcBall.h:146
Matrix4 viewMatrix() const
Get the camera's view transformation as a matrix.
Definition ArcBall.h:109
Vector3 _targetPosition
Definition ArcBall.h:145
Matrix4 transformationMatrix() const
Get the camera's transformation matrix.
Definition ArcBall.h:123
Float _lagging
Definition ArcBall.h:143
void updateInternalTransformations()
Update the camera transformations-.
Definition ArcBall.cpp:171
Float _targetZooming
Definition ArcBall.h:147
void rotate(const Vector2i &mousePos)
Rotate the camera from the previous (screen) mouse position to the current(screen) position.
Definition ArcBall.cpp:100
void setLagging(Float lagging)
Set the amount of lagging such that the camera will (slowly) smoothly navigate. Lagging must be in [0...
Definition ArcBall.cpp:91
Vector2 screenCoordToNDC(const Vector2i &mousePos) const
Transform from screen coordinate to NDC - normalized device coordinate. The top - left of the screen ...
Definition ArcBall.cpp:178
void zoom(Float delta)
Zoom the camera.
Definition ArcBall.cpp:126
Vector3 _currentPosition
Definition ArcBall.h:145
Float viewDistance() const
Return the distance from the camera position to the center view.
Definition ArcBall.h:127
Float lagging() const
Get the amount of lagging such that the camera will (slowly) smoothly navigate.
Definition ArcBall.h:74
Matrix4 inverseViewMatrix() const
Get the camera's inverse view matrix (which also produces transformation of the camera)
Definition ArcBall.h:113
const DualQuaternion & transformation() const
Get the camera's transformation as a dual quaternion.
Definition ArcBall.h:119
void initTransformation(const Vector2i &mousePos)
Initialize the first (screen) mouse position for camera transformation. This should be called from th...
Definition ArcBall.cpp:96
void reshape(const Vector2i &windowSize)
Update screen size after the window has been resized.
Definition ArcBall.h:66
DualQuaternion _inverseView
Definition ArcBall.h:148
Deg _fov
Definition ArcBall.h:139
void translateDelta(const Vector2 &translationNDC)
Translate the camera by the delta amount of (NDC) mouse position. Note that NDC position must be in[-...
Definition ArcBall.cpp:116
const DualQuaternion & view() const
Get the camera's view transformation as a dual quaternion.
Definition ArcBall.h:105
void translate(const Vector2i &mousePos)
Translate the camera from the previous (screen) mouse position to the current(screen) mouse position.
Definition ArcBall.cpp:109
Vector2i _windowSize
Definition ArcBall.h:140
Deg fov() const
Field of view.
Definition ArcBall.h:101
void setViewParameters(const Vector3 &eye, const Vector3 &viewCenter, const Vector3 &upDir)
Set the camera view parameters: eye position, view center, up direction.
Definition ArcBall.cpp:64
Float _currentZooming
Definition ArcBall.h:147
DualQuaternion _view
Definition ArcBall.h:148
bool updateTransformation()
Update any unfinished transformation due to lagging.
Definition ArcBall.cpp:133