Visual Computing Library
|
The TrackBall class implements a trackball camera. More...
#include <vclib/render/viewer/trackball.h>
Classes | |
struct | TransformArgs |
Public Types | |
enum | MotionType { ARC , PAN , ZMOVE , ROLL , SCALE , FOV , FOCUS , DIR_LIGHT_ARC , MOTION_NUMBER } |
using | AtomicMotionArg = std::variant< TransformArgs, Scalar, Point3< Scalar >, std::monostate > |
Public Member Functions | |
void | reset () |
void | reset (const Point3< Scalar > ¢er, Scalar scale) |
Reset the manipulator to a given center and scale. | |
void | resetDirectionalLight () |
Point3< Scalar > | center () const |
void | setCenter (const Point3< Scalar > ¢er) |
Scalar | scale () const |
void | setScale (Scalar scale) |
void | changeScale (Scalar factor) |
void | setRotation (const Quaternion< Scalar > &rotation) |
void | setRotation (const Point3< Scalar > &axis, Scalar angle) |
Scalar | fovDeg () const |
Get the vertical field of view. | |
void | setFovDeg (Scalar fov) |
Set the vertical field of view adapting the eye distance. | |
Camera< Scalar >::ProjectionMode::Enum | projectionMode () const |
void | setProjectionMode (Camera< Scalar >::ProjectionMode::Enum mode) |
void | setScreenSize (Scalar width, Scalar height) |
void | setScreenSize (const Point2< Scalar > &sz) |
DirectionalLight< Scalar > | light () const |
const vcl::Camera< Scalar > & | camera () const |
Matrix44< Scalar > | viewMatrix () const |
Matrix44< Scalar > | projectionMatrix () const |
Matrix44< Scalar > | gizmoMatrix () const |
Matrix44< Scalar > | lightGizmoMatrix () const |
bool | isDragging () const |
MotionType | currentMotion () const |
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 | applyScale (Scalar value) |
void | applyRoll (Scalar angleRad) |
void | applyPan (const Point3< Scalar > &translation) |
void | applyArc (const Point3< Scalar > &axis, Scalar angle) |
void | setMousePosition (Scalar x, Scalar y) |
void | setMousePosition (const Point2< Scalar > &point) |
void | beginDragMotion (MotionType motion) |
Starts a drag motion. | |
void | endDragMotion (MotionType motion) |
Ends a drag motion. | |
void | update () |
Updates the state of the trackball during a drag motion. | |
Private Member Functions | |
void | setDragMotionValue (MotionType motion, bool value) |
void | drag (MotionType motion) |
Scalar | trackballToPixelRatio () const |
Point3< Scalar > | pointOnTrackballPlane (Point2< Scalar > screenCoord) const |
Point3< Scalar > | pointOnArcball (Point2< Scalar > screenCoord) const |
void | rotate (const Quaternion< Scalar > &q) |
void | rotate (Point3< Scalar > axis, Scalar angleRad) |
void | translate (Point3< Scalar > t) |
Translate in the camera space. | |
void | rotateDirLight (const Quaternion< Scalar > &rotation) |
void | rotateDirLight (Point3< Scalar > axis, Scalar angle) |
void | dragArc () |
void | roll (Scalar delta) |
void | dragRoll () |
void | performPan (const Point2< Scalar > &pixelDelta) |
perform a pan operation | |
void | dragPan () |
void | performZmove (const Scalar &pixelDelta) |
translate in the camera z direction | |
void | dragZmove () |
void | performScale (Scalar pixelDelta) |
void | dragScale () |
void | dragDirLightArc () |
void | performFov (Scalar pixelDelta) |
Private Attributes | |
Camera< Scalar > | mCamera |
Affine3< Scalar > | mTransform = Affine3<Scalar>::Identity() |
Quaternion< Scalar > | mDirectionalLightTransform |
Point2< Scalar > | mScreenSize = {-1, -1} |
Scalar | mRadius = ARC_BALL_RADIUS_RATIO |
bool | mDragging = false |
MotionType | mCurrDragMotion = MOTION_NUMBER |
Point3< Scalar > | mInitialPoint |
Affine3< Scalar > | mInitialTransform = Affine3<Scalar>::Identity() |
Quaternion< Scalar > | mInitialDirRotation = Quaternion<Scalar>::Identity() |
Point2< Scalar > | mCurrMousePosition |
Point2< Scalar > | mPrevMousePosition |
Static Private Attributes | |
static constexpr Scalar | ARC_BALL_RADIUS_RATIO = 1.0 / 1.61803398875 |
static constexpr Scalar | FOCUS_SCALE_FACTOR = 1.15 |
static constexpr Scalar | DEFAULT_FOV_DEG = 54.0 |
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.