|
Visual Computing Library
devel
|
The TrackBall class implements a trackball camera. More...
#include <vclib/render/viewer/trackball.h>
Classes | |
| struct | TransformArgs |
Public Types | |
| using | AtomicMotionArg = std::variant< TransformArgs, Scalar, Point3< Scalar >, std::monostate > |
| enum | MotionType { ARC , PAN , ZMOVE , ROLL , SCALE , FOV , FOCUS , DIR_LIGHT_ARC , MOTION_NUMBER } |
Public Member Functions | |
| void | applyArc (const Point3< Scalar > &axis, Scalar angle) |
| void | applyAtomicMotion (MotionType motion, AtomicMotionArg step=std::monostate()) |
| Applies an atomic motion to the trackball. Atomic motions are motions that are applied atomically to the camera. The step parameter is a std::variant that can store different values depending on the motion type. | |
| void | applyPan (const Point3< Scalar > &translation) |
| void | applyRoll (Scalar angleRad) |
| void | applyScale (Scalar value) |
| void | beginDragMotion (MotionType motion) |
| Starts a drag motion. | |
| const vcl::Camera< Scalar > & | camera () const |
| Point3< Scalar > | center () const |
| void | changeScale (Scalar factor) |
| MotionType | currentMotion () const |
| void | endDragMotion (MotionType motion) |
| Ends a drag motion. | |
| Scalar | fovDeg () const |
| Get the vertical field of view. | |
| Matrix44< Scalar > | gizmoMatrix () const |
| bool | isDragging () const |
| DirectionalLight< Scalar > | light () const |
| Matrix44< Scalar > | lightGizmoMatrix () const |
| Matrix44< Scalar > | projectionMatrix () const |
| Camera< Scalar >::ProjectionMode | projectionMode () const |
| void | reset () |
| void | reset (const Point3< Scalar > ¢er, Scalar scale) |
| Reset the manipulator to a given center and scale. | |
| void | resetDirectionalLight () |
| Scalar | scale () const |
| void | setCenter (const Point3< Scalar > ¢er) |
| void | setFovDeg (Scalar fov) |
| Set the vertical field of view adapting the eye distance. | |
| void | setLightDirection (const Point3< Scalar > &direction) |
| void | setMousePosition (const Point2< Scalar > &point) |
| void | setMousePosition (Scalar x, Scalar y) |
| void | setProjectionMode (Camera< Scalar >::ProjectionMode mode) |
| void | setRotation (const Point3< Scalar > &axis, Scalar angle) |
| void | setRotation (const Quaternion< Scalar > &rotation) |
| void | setScale (Scalar scale) |
| void | setScreenSize (const Point2< Scalar > &sz) |
| void | setScreenSize (Scalar width, Scalar height) |
| void | update () |
| Updates the state of the trackball during a drag motion. | |
| Matrix44< Scalar > | viewMatrix () const |
Private Member Functions | |
| void | drag (MotionType motion) |
| void | dragArc () |
| void | dragDirLightArc () |
| void | dragPan () |
| void | dragRoll () |
| void | dragScale () |
| void | dragZmove () |
| void | performFov (Scalar pixelDelta) |
| void | performPan (const Point2< Scalar > &pixelDelta) |
| perform a pan operation | |
| void | performScale (Scalar pixelDelta) |
| void | performZmove (const Scalar &pixelDelta) |
| translate in the camera z direction | |
| Point3< Scalar > | pointOnArcball (Point2< Scalar > screenCoord) const |
| Point3< Scalar > | pointOnTrackballPlane (Point2< Scalar > screenCoord) const |
| void | roll (Scalar delta) |
| void | rotate (const Quaternion< Scalar > &q) |
| void | rotate (Point3< Scalar > axis, Scalar angleRad) |
| void | rotateDirLight (const Quaternion< Scalar > &rotation) |
| void | rotateDirLight (Point3< Scalar > axis, Scalar angle) |
| void | setDragMotionValue (MotionType motion, bool value) |
| Scalar | trackballToPixelRatio () const |
| void | translate (Point3< Scalar > t) |
| Translate in the camera space. | |
Private Attributes | |
| Camera< Scalar > | mCamera |
| MotionType | mCurrDragMotion = MOTION_NUMBER |
| Point2< Scalar > | mCurrMousePosition |
| Quaternion< Scalar > | mDirectionalLightTransform |
| bool | mDragging = false |
| Quaternion< Scalar > | mInitialDirRotation = Quaternion<Scalar>::Identity() |
| Point3< Scalar > | mInitialPoint |
| Affine3< Scalar > | mInitialTransform = Affine3<Scalar>::Identity() |
| Point2< Scalar > | mPrevMousePosition |
| Scalar | mRadius = ARC_BALL_RADIUS_RATIO |
| Point2< Scalar > | mScreenSize = {-1, -1} |
| Affine3< Scalar > | mTransform = Affine3<Scalar>::Identity() |
Static Private Attributes | |
| static constexpr Scalar | ARC_BALL_RADIUS_RATIO = 1.0 / 1.61803398875 |
| static constexpr Scalar | DEFAULT_FOV_DEG = 54.0 |
| static constexpr Scalar | FOCUS_SCALE_FACTOR = 1.15 |
The TrackBall class implements a trackball camera.
The trackball class stores a camera and provides a set motions that allow the user to manipulate it.
There are two main types of motions:
begin/end member functions, and they update their state trough the change of the mouse position. An example of a drag motion is an arcball rotation.
|
inline |
Applies an atomic motion to the trackball. Atomic motions are motions that are applied atomically to the camera. The step parameter is a std::variant that can store different values depending on the motion type.
Possible motion types and supported step values are:
| motion | |
| step |
|
inline |
Starts a drag motion.
| [in] | motion | the motion type |
|
inlineprivate |
— User interaction functions — -----------— Arc -----------—
|
inlineprivate |
--— Directional Light Arc --—
|
inline |
Ends a drag motion.
| [in] | motion | the motion type |
|
inlineprivate |
--— Fov --—
|
inlineprivate |
perform a pan operation
-----------— Pan -----------—
| pixelDelta | the pan movement in pixels |
|
inlineprivate |
-----------— Scaling -----------—
|
inlineprivate |
translate in the camera z direction
-----------— Z-Move -----------—
| pixelDelta | the delta movement in pixels |
|
inline |
Reset the manipulator to a given center and scale.
| center | |
| scale |
|
inlineprivate |
-----------— Roll -----------—
|
inlineprivate |
------— Base functions ------—
|
inlineprivate |
-----------— Generic Functions -----------—
|
inline |
Set the vertical field of view adapting the eye distance.
| [in] | fov | the field of view in degrees. |
|
inlineprivate |
Translate in the camera space.
|
inline |
Updates the state of the trackball during a drag motion.