|
Blobalizer
|
Implementation of Ken Shoemake's arcball camera with smooth navigation. More...
#include <ArcBall.h>
Public Member Functions | |
| ArcBall (const Vector3 &cameraPosition, const Vector3 &viewCenter, const Vector3 &upDir, Deg fov, const Vector2i &windowSize) | |
| Constructs a new instance. | |
| void | setViewParameters (const Vector3 &eye, const Vector3 &viewCenter, const Vector3 &upDir) |
| Set the camera view parameters: eye position, view center, up direction. | |
| void | reset () |
| Reset the camera to its initial position, view center, and up dir. | |
| void | reshape (const Vector2i &windowSize) |
| Update screen size after the window has been resized. | |
| bool | updateTransformation () |
| Update any unfinished transformation due to lagging. | |
| Float | lagging () const |
| Get the amount of lagging such that the camera will (slowly) smoothly navigate. | |
| void | setLagging (Float lagging) |
| Set the amount of lagging such that the camera will (slowly) smoothly navigate. Lagging must be in [0, 1). | |
| void | initTransformation (const Vector2i &mousePos) |
| Initialize the first (screen) mouse position for camera transformation. This should be called from the mouse pressed event. | |
| void | rotate (const Vector2i &mousePos) |
| Rotate the camera from the previous (screen) mouse position to the current(screen) position. | |
| void | translate (const Vector2i &mousePos) |
| Translate the camera from the previous (screen) mouse position to the current(screen) mouse position. | |
| void | translateDelta (const Vector2 &translationNDC) |
| Translate the camera by the delta amount of (NDC) mouse position. Note that NDC position must be in[-1, -1] to[1, 1]. | |
| void | zoom (Float delta) |
| Zoom the camera. | |
| Deg | fov () const |
| Field of view. | |
| const DualQuaternion & | view () const |
| Get the camera's view transformation as a dual quaternion. | |
| Matrix4 | viewMatrix () const |
| Get the camera's view transformation as a matrix. | |
| Matrix4 | inverseViewMatrix () const |
| Get the camera's inverse view matrix (which also produces transformation of the camera) | |
| const DualQuaternion & | transformation () const |
| Get the camera's transformation as a dual quaternion. | |
| Matrix4 | transformationMatrix () const |
| Get the camera's transformation matrix. | |
| Float | viewDistance () const |
| Return the distance from the camera position to the center view. | |
Protected Member Functions | |
| void | updateInternalTransformations () |
| Update the camera transformations-. | |
| Vector2 | screenCoordToNDC (const Vector2i &mousePos) const |
| Transform from screen coordinate to NDC - normalized device coordinate. The top - left of the screen corresponds to[-1, 1] NDC, and the bottom right is[1, -1] NDC. | |
Protected Attributes | |
| Deg | _fov |
| Vector2i | _windowSize |
| Vector2 | _prevMousePosNDC |
| Float | _lagging {} |
| Vector3 | _targetPosition |
| Vector3 | _currentPosition |
| Vector3 | _positionT0 |
| Quaternion | _targetQRotation |
| Quaternion | _currentQRotation |
| Quaternion | _qRotationT0 |
| Float | _targetZooming |
| Float | _currentZooming |
| Float | _zoomingT0 |
| DualQuaternion | _view |
| DualQuaternion | _inverseView |
Implementation of Ken Shoemake's arcball camera with smooth navigation.
| ArcBall::ArcBall | ( | const Vector3 & | cameraPosition, |
| const Vector3 & | viewCenter, | ||
| const Vector3 & | upDir, | ||
| Deg | fov, | ||
| const Vector2i & | windowSize | ||
| ) |
Constructs a new instance.
| cameraPosition | the position of the camera on the arc ball. |
| viewCenter | the position of the arc ball. |
| upDir | a vector representing the upwards direction. |
| fov | the fov of the camera. |
| windowSize | the size of the output window. |
|
inline |
Field of view.
| void ArcBall::initTransformation | ( | const Vector2i & | mousePos | ) |
Initialize the first (screen) mouse position for camera transformation. This should be called from the mouse pressed event.
| mousePos | the current mouse position. |
|
inline |
Get the camera's inverse view matrix (which also produces transformation of the camera)
|
inline |
Get the amount of lagging such that the camera will (slowly) smoothly navigate.
| void ArcBall::reset | ( | ) |
Reset the camera to its initial position, view center, and up dir.
|
inline |
Update screen size after the window has been resized.
| windowSize | the new window size. |
| void ArcBall::rotate | ( | const Vector2i & | mousePos | ) |
Rotate the camera from the previous (screen) mouse position to the current(screen) position.
| mousePos | the current mouse position. |
|
protected |
Transform from screen coordinate to NDC - normalized device coordinate. The top - left of the screen corresponds to[-1, 1] NDC, and the bottom right is[1, -1] NDC.
| mousePos | the mouse position in screen coordinates. |
| void ArcBall::setLagging | ( | Float | lagging | ) |
Set the amount of lagging such that the camera will (slowly) smoothly navigate. Lagging must be in [0, 1).
| void ArcBall::setViewParameters | ( | const Vector3 & | eye, |
| const Vector3 & | viewCenter, | ||
| const Vector3 & | upDir | ||
| ) |
Set the camera view parameters: eye position, view center, up direction.
| eye | the position of the camera on the arc ball. |
| viewCenter | the position of the arc ball. |
| upDir | a vector representing the upwards direction. |
|
inline |
Get the camera's transformation as a dual quaternion.
|
inline |
Get the camera's transformation matrix.
| void ArcBall::translate | ( | const Vector2i & | mousePos | ) |
Translate the camera from the previous (screen) mouse position to the current(screen) mouse position.
| mousePos | the current mouse position. |
| void ArcBall::translateDelta | ( | const Vector2 & | translationNDC | ) |
Translate the camera by the delta amount of (NDC) mouse position. Note that NDC position must be in[-1, -1] to[1, 1].
| translationNDC | the translation amount. |
|
protected |
Update the camera transformations-.
| bool ArcBall::updateTransformation | ( | ) |
Update any unfinished transformation due to lagging.
|
inline |
Get the camera's view transformation as a dual quaternion.
|
inline |
Return the distance from the camera position to the center view.
|
inline |
Get the camera's view transformation as a matrix.
| void ArcBall::zoom | ( | Float | delta | ) |
Zoom the camera.
| delta | the amount of zoom (positive delta = zoom in, negative = zoom out) |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |