vsg: vsg::Trackball Class Reference

vsg 1.1.8 VulkanSceneGraph library

Loading...
Searching...
No Matches
Classes | Public Member Functions | Public Attributes | Protected Types | Protected Attributes | List of all members
vsg::Trackball Class Reference

Trackball is an event handler that provides mouse and touch controlled 3d trackball camera view manipulation. More...

`#include <Trackball.h>`

Inheritance diagram for vsg::Trackball:
[legend]
Collaboration diagram for vsg::Trackball:
[legend]

## Classes
struct | Viewpoint

## Public Member Functions
| Trackball (ref_ptr< Camera > camera, ref_ptr< EllipsoidModel > ellipsoidModel={})
dvec2 | ndc (const PointerEvent &event)
| compute non dimensional window coordinate (-1,1) from event coords
dvec3 | tbc (const PointerEvent &event)
| compute trackball coordinate from event coords
void | apply (KeyPressEvent &keyPress) override
void | apply (KeyReleaseEvent &keyRelease) override
void | apply (FocusInEvent &focusIn) override
void | apply (FocusOutEvent &focusOut) override
void | apply (ButtonPressEvent &buttonPress) override
void | apply (ButtonReleaseEvent &buttonRelease) override
void | apply (MoveEvent &moveEvent) override
void | apply (ScrollWheelEvent &scrollWheel) override
void | apply (TouchDownEvent &touchDown) override
void | apply (TouchUpEvent &touchUp) override
void | apply (TouchMoveEvent &touchMove) override
void | apply (FrameEvent &frame) override
virtual void | rotate (double angle, const dvec3 &axis)
virtual void | zoom (double ratio)
virtual void | pan (const dvec2 &delta)
std::pair< int32_t, int32_t > | cameraRenderAreaCoordinates (const PointerEvent &pointerEvent) const
bool | withinRenderArea (const PointerEvent &pointerEvent) const
bool | eventRelevant (const WindowEvent &event) const
void | clampToGlobe ()
void | addWindow (ref_ptr< Window > window, const ivec2 &offset={})
| add a Window to respond events for, with mouse coordinate offset to treat all associated windows
void | addKeyViewpoint (KeySymbol key, ref_ptr< LookAt > lookAt, double duration=1.0)
| add Key to Viewpoint binding using a LookAt to define the viewpoint
void | addKeyViewpoint (KeySymbol key, double latitude, double longitude, double altitude, double duration=1.0)
| add Key to Viewpoint binding using a latitude, longitude and altitude to define the viewpoint. Requires an EllipsoidModel to be assigned when constructing the Trackball
void | setViewpoint (ref_ptr< LookAt > lookAt, double duration=1.0)
Public Member Functions inherited from vsg::Inherit< Visitor, Trackball >
| Inherit (Args &&... args)
std::size_t | sizeofObject () const noexcept override
const char * | className () const noexcept override
const std::type_info & | type_info () const noexcept override
bool | is_compatible (const std::type_info &type) const noexcept override
int | compare (const Object &rhs) const override
void | accept (Visitor &visitor) override
void | accept (ConstVisitor &visitor) const override
void | accept (RecordTraversal &visitor) const override
Public Member Functions inherited from vsg::Visitor
| Visitor (const Visitor &rhs, const CopyOp &copyop={})
virtual Instrumentation * | getInstrumentation ()
virtual void | apply (Object &)
virtual void | apply (Objects &)
virtual void | apply (External &)
virtual void | apply (Data &)
virtual void | apply (stringValue &)
virtual void | apply (wstringValue &)
virtual void | apply (boolValue &)
virtual void | apply (intValue &)
virtual void | apply (uintValue &)
virtual void | apply (floatValue &)
virtual void | apply (doubleValue &)
virtual void | apply (vec2Value &)
virtual void | apply (vec3Value &)
virtual void | apply (vec4Value &)
virtual void | apply (dvec2Value &)
virtual void | apply (dvec3Value &)
virtual void | apply (dvec4Value &)
virtual void | apply (bvec2Value &)
virtual void | apply (bvec3Value &)
virtual void | apply (bvec4Value &)
virtual void | apply (ubvec2Value &)
virtual void | apply (ubvec3Value &)
virtual void | apply (ubvec4Value &)
virtual void | apply (svec2Value &)
virtual void | apply (svec3Value &)
virtual void | apply (svec4Value &)
virtual void | apply (usvec2Value &)
virtual void | apply (usvec3Value &)
virtual void | apply (usvec4Value &)
virtual void | apply (ivec2Value &)
virtual void | apply (ivec3Value &)
virtual void | apply (ivec4Value &)
virtual void | apply (uivec2Value &)
virtual void | apply (uivec3Value &)
virtual void | apply (uivec4Value &)
virtual void | apply (mat4Value &)
virtual void | apply (dmat4Value &)
virtual void | apply (byteArray &)
virtual void | apply (ubyteArray &)
virtual void | apply (shortArray &)
virtual void | apply (ushortArray &)
virtual void | apply (intArray &)
virtual void | apply (uintArray &)
virtual void | apply (floatArray &)
virtual void | apply (doubleArray &)
virtual void | apply (vec2Array &)
virtual void | apply (vec3Array &)
virtual void | apply (vec4Array &)
virtual void | apply (dvec2Array &)
virtual void | apply (dvec3Array &)
virtual void | apply (dvec4Array &)
virtual void | apply (bvec2Array &)
virtual void | apply (bvec3Array &)
virtual void | apply (bvec4Array &)
virtual void | apply (svec2Array &)
virtual void | apply (svec3Array &)
virtual void | apply (svec4Array &)
virtual void | apply (ivec2Array &)
virtual void | apply (ivec3Array &)
virtual void | apply (ivec4Array &)
virtual void | apply (ubvec2Array &)
virtual void | apply (ubvec3Array &)
virtual void | apply (ubvec4Array &)
virtual void | apply (usvec2Array &)
virtual void | apply (usvec3Array &)
virtual void | apply (usvec4Array &)
virtual void | apply (uivec2Array &)
virtual void | apply (uivec3Array &)
virtual void | apply (uivec4Array &)
virtual void | apply (mat4Array &)
virtual void | apply (dmat4Array &)
virtual void | apply (block64Array &)
virtual void | apply (block128Array &)
virtual void | apply (ubyteArray2D &)
virtual void | apply (ushortArray2D &)
virtual void | apply (uintArray2D &)
virtual void | apply (floatArray2D &)
virtual void | apply (doubleArray2D &)
virtual void | apply (vec2Array2D &)
virtual void | apply (vec3Array2D &)
virtual void | apply (vec4Array2D &)
virtual void | apply (dvec2Array2D &)
virtual void | apply (dvec3Array2D &)
virtual void | apply (dvec4Array2D &)
virtual void | apply (bvec2Array2D &)
virtual void | apply (bvec3Array2D &)
virtual void | apply (bvec4Array2D &)
virtual void | apply (svec2Array2D &)
virtual void | apply (svec3Array2D &)
virtual void | apply (svec4Array2D &)
virtual void | apply (ivec2Array2D &)
virtual void | apply (ivec3Array2D &)
virtual void | apply (ivec4Array2D &)
virtual void | apply (ubvec2Array2D &)
virtual void | apply (ubvec3Array2D &)
virtual void | apply (ubvec4Array2D &)
virtual void | apply (usvec2Array2D &)
virtual void | apply (usvec3Array2D &)
virtual void | apply (usvec4Array2D &)
virtual void | apply (uivec2Array2D &)
virtual void | apply (uivec3Array2D &)
virtual void | apply (uivec4Array2D &)
virtual void | apply (block64Array2D &)
virtual void | apply (block128Array2D &)
virtual void | apply (ubyteArray3D &)
virtual void | apply (ushortArray3D &)
virtual void | apply (uintArray3D &)
virtual void | apply (floatArray3D &)
virtual void | apply (doubleArray3D &)
virtual void | apply (vec2Array3D &)
virtual void | apply (vec3Array3D &)
virtual void | apply (vec4Array3D &)
virtual void | apply (dvec2Array3D &)
virtual void | apply (dvec3Array3D &)
virtual void | apply (dvec4Array3D &)
virtual void | apply (ubvec2Array3D &)
virtual void | apply (ubvec3Array3D &)
virtual void | apply (ubvec4Array3D &)
virtual void | apply (block64Array3D &)
virtual void | apply (block128Array3D &)
virtual void | apply (Node &)
virtual void | apply (Compilable &)
virtual void | apply (Commands &)
virtual void | apply (Group &)
virtual void | apply (QuadGroup &)
virtual void | apply (LOD &)
virtual void | apply (PagedLOD &)
virtual void | apply (StateGroup &)
virtual void | apply (CullGroup &)
virtual void | apply (CullNode &)
virtual void | apply (MatrixTransform &)
virtual void | apply (Transform &)
virtual void | apply (Geometry &)
virtual void | apply (VertexDraw &)
virtual void | apply (VertexIndexDraw &)
virtual void | apply (DepthSorted &)
virtual void | apply (Layer &)
virtual void | apply (Bin &)
virtual void | apply (Switch &)
virtual void | apply (Light &)
virtual void | apply (AmbientLight &)
virtual void | apply (DirectionalLight &)
virtual void | apply (PointLight &)
virtual void | apply (SpotLight &)
virtual void | apply (InstrumentationNode &)
virtual void | apply (RegionOfInterest &)
virtual void | apply (Text &)
virtual void | apply (TextGroup &)
virtual void | apply (TextTechnique &)
virtual void | apply (TextLayout &)
virtual void | apply (Animation &)
virtual void | apply (AnimationGroup &)
virtual void | apply (AnimationSampler &)
virtual void | apply (JointSampler &)
virtual void | apply (MorphSampler &)
virtual void | apply (TransformSampler &)
virtual void | apply (Joint &)
virtual void | apply (BufferInfo &)
virtual void | apply (ImageInfo &)
virtual void | apply (ImageView &)
virtual void | apply (Image &)
virtual void | apply (Command &)
virtual void | apply (StateCommand &)
virtual void | apply (StateSwitch &)
virtual void | apply (CommandBuffer &)
virtual void | apply (RenderPass &)
virtual void | apply (BindDescriptorSet &)
virtual void | apply (BindDescriptorSets &)
virtual void | apply (BindViewDescriptorSets &)
virtual void | apply (Descriptor &)
virtual void | apply (DescriptorBuffer &)
virtual void | apply (DescriptorImage &)
virtual void | apply (DescriptorSet &)
virtual void | apply (BindVertexBuffers &)
virtual void | apply (BindIndexBuffer &)
virtual void | apply (BindComputePipeline &)
virtual void | apply (BindGraphicsPipeline &)
virtual void | apply (BindRayTracingPipeline &)
virtual void | apply (GraphicsPipeline &)
virtual void | apply (ComputePipeline &)
virtual void | apply (RayTracingPipeline &)
virtual void | apply (GraphicsPipelineState &)
virtual void | apply (ShaderStage &)
virtual void | apply (VertexInputState &)
virtual void | apply (InputAssemblyState &)
virtual void | apply (TessellationState &)
virtual void | apply (ViewportState &)
virtual void | apply (RasterizationState &)
virtual void | apply (MultisampleState &)
virtual void | apply (DepthStencilState &)
virtual void | apply (ColorBlendState &)
virtual void | apply (DynamicState &)
virtual void | apply (ResourceHints &)
virtual void | apply (Draw &)
virtual void | apply (DrawIndexed &)
virtual void | apply (ClearAttachments &)
virtual void | apply (ClearColorImage &)
virtual void | apply (ClearDepthStencilImage &)
virtual void | apply (QueryPool &)
virtual void | apply (ResetQueryPool &)
virtual void | apply (BeginQuery &)
virtual void | apply (EndQuery &)
virtual void | apply (WriteTimestamp &)
virtual void | apply (CopyQueryPoolResults &)
virtual void | apply (DrawMeshTasks &)
virtual void | apply (DrawMeshTasksIndirect &)
virtual void | apply (DrawMeshTasksIndirectCount &)
virtual void | apply (UIEvent &)
virtual void | apply (WindowEvent &)
virtual void | apply (ExposeWindowEvent &)
virtual void | apply (ConfigureWindowEvent &)
virtual void | apply (CloseWindowEvent &)
virtual void | apply (KeyEvent &)
virtual void | apply (PointerEvent &)
virtual void | apply (TouchEvent &)
virtual void | apply (TerminateEvent &)
virtual void | apply (ShaderCompileSettings &)
virtual void | apply (Camera &)
virtual void | apply (CommandGraph &)
virtual void | apply (SecondaryCommandGraph &)
virtual void | apply (RenderGraph &)
virtual void | apply (View &)
virtual void | apply (Viewer &)
virtual void | apply (ViewMatrix &)
virtual void | apply (LookAt &)
virtual void | apply (RelativeViewMatrix &)
virtual void | apply (TrackingViewMatrix &)
virtual void | apply (ProjectionMatrix &)
virtual void | apply (Perspective &)
virtual void | apply (Orthographic &)
virtual void | apply (RelativeProjection &)
virtual void | apply (EllipsoidPerspective &)
virtual void | apply (FrameStamp &)
bool | is_compatible (const std::type_info &type) const noexcept override
Public Member Functions inherited from vsg::Object
| Object (const Object &object, const CopyOp &copyop={})
Object & | operator= (const Object &)
template<class T >
T * | cast ()
template<class T >
const T * | cast () const
virtual ref_ptr< Object > | clone (const CopyOp &copyop={}) const
virtual void | traverse (Visitor &)
virtual void | traverse (ConstVisitor &) const
virtual void | traverse (RecordTraversal &) const
virtual void | read (Input &input)
virtual void | write (Output &output) const
void | ref () const noexcept
void | unref () const noexcept
void | unref_nodelete () const noexcept
unsigned int | referenceCount () const noexcept
template<typename T >
void | setValue (const std::string &key, const T &value)
void | setValue (const std::string &key, const char *value)
| specialization of setValue to handle passing C strings
template<typename T >
bool | getValue (const std::string &key, T &value) const
| get specified value type, return false if value associated with key is not assigned or is not the correct type
void | setObject (const std::string &key, ref_ptr< Object > object)
| assign an Object associated with key
Object * | getObject (const std::string &key)
| get Object pointer associated with key, return nullptr if no object associated with key has been assigned
const Object * | getObject (const std::string &key) const
| get const Object pointer associated with key, return nullptr if no object associated with key has been assigned
template<class T >
T * | getObject (const std::string &key)
| get object pointer of specified type associated with key, return nullptr if no object associated with key has been assigned
template<class T >
const T * | getObject (const std::string &key) const
| get const object pointer of specified type associated with key, return nullptr if no object associated with key has been assigned
ref_ptr< Object > | getRefObject (const std::string &key)
| get ref_ptr<Object> associated with key, return nullptr if no object associated with key has been assigned
ref_ptr< const Object > | getRefObject (const std::string &key) const
| get ref_ptr<const Object> pointer associated with key, return nullptr if no object associated with key has been assigned
template<class T >
ref_ptr< T > | getRefObject (const std::string &key)
| get ref_ptr<T> of specified type associated with key, return nullptr if no object associated with key has been assigned
template<class T >
const ref_ptr< const T > | getRefObject (const std::string &key) const
| get ref_ptr<const T> of specified type associated with key, return nullptr if no object associated with key has been assigned
void | removeObject (const std::string &key)
| remove meta object or value associated with key
Auxiliary * | getOrCreateAuxiliary ()
Auxiliary * | getAuxiliary ()
const Auxiliary * | getAuxiliary () const

## Public Attributes
std::map< observer_ptr< Window >, ivec2 > | windowOffsets
| list of windows that this Trackball should respond to events from, and the points xy offsets to apply
std::map< KeySymbol, Viewpoint > | keyViewpointMap
| container that maps key symbol bindings with the Viewpoint that should move the LookAt to when pressed.
KeySymbol | turnLeftKey = KEY_a
| Key that turns the view left around the eye points.
KeySymbol | turnRightKey = KEY_d
| Key that turns the view right around the eye points.
KeySymbol | pitchUpKey = KEY_w
| Key that pitches up the view around the eye point.
KeySymbol | pitchDownKey = KEY_s
| Key that pitches down the view around the eye point.
KeySymbol | rollLeftKey = KEY_q
| Key that rools the view anti-clockwise/left.
KeySymbol | rollRightKey = KEY_e
| Key that rolls the view clockwise/right.
KeySymbol | moveForwardKey = KEY_o
| Key that moves the view forward.
KeySymbol | moveBackwardKey = KEY_i
| Key that moves the view backwards.
KeySymbol | moveLeftKey = KEY_Left
| Key that moves the view left.
KeySymbol | moveRightKey = KEY_Right
| Key that moves the view right.
KeySymbol | moveUpKey = KEY_Up
| Key that moves the view upward.
KeySymbol | moveDownKey = KEY_Down
| Key that moves the view downward.
ButtonMask | rotateButtonMask = BUTTON_MASK_1
| Button mask value used to enable panning of the view, defaults to left mouse button.
ButtonMask | panButtonMask = BUTTON_MASK_2
| Button mask value used to enable panning of the view, defaults to middle mouse button.
ButtonMask | zoomButtonMask = BUTTON_MASK_3
| Button mask value used to enable zooming of the view, defaults to right mouse button.
ButtonMask | touchMappedToButtonMask = BUTTON_MASK_1
| Button mask value used used for touch events.
double | zoomScale = 1.0
| Scale for controlling how rapidly the view zooms in/out. Positive value zooms in when mouse moves downwards.
bool | supportsThrow = true
| Toggle on/off whether the view should continue moving when the mouse buttons are released while the mouse is in motion.
Public Attributes inherited from vsg::Visitor
Mask | traversalMask = MASK_ALL
Mask | overrideMask = MASK_OFF

## Protected Types
enum | UpdateMode { INACTIVE = 0 , ROTATE , PAN , ZOOM }

## Protected Attributes
ref_ptr< Camera > | _camera
ref_ptr< LookAt > | _lookAt
ref_ptr< EllipsoidModel > | _ellipsoidModel
bool | _hasKeyboardFocus = false
bool | _hasPointerFocus = false
bool | _lastPointerEventWithinRenderArea = false
UpdateMode | _updateMode = INACTIVE
double | _zoomPreviousRatio = 0.0
dvec2 | _pan
double | _rotateAngle = 0.0
dvec3 | _rotateAxis
time_point | _previousTime
ref_ptr< PointerEvent > | _previousPointerEvent
double | _previousDelta = 0.0
double | _prevZoomTouchDistance = 0.0
bool | _thrown = false
time_point | _startTime
ref_ptr< LookAt > | _startLookAt
ref_ptr< LookAt > | _endLookAt
std::map< uint32_t, ref_ptr< TouchEvent > > | _previousTouches
ref_ptr< Keyboard > | _keyboard
double | _animationDuration = 0.0

## Additional Inherited Members
Static Public Member Functions inherited from vsg::Inherit< Visitor, Trackball >
static ref_ptr< Trackball > | create (Args &&... args)
static ref_ptr< Trackball > | create_if (bool flag, Args &&... args)
Static Public Member Functions inherited from vsg::Object
static ref_ptr< Object > | create ()
static ref_ptr< Object > | create_if (bool flag)
static void * | operator new (std::size_t count)
| provide new and delete to enable custom memory management via the vsg::Allocator singleton, using the MEMORY_AFFINTY_OBJECTS
static void | operator delete (void *ptr)
Protected Member Functions inherited from vsg::Object
virtual void | _attemptDelete () const
void | setAuxiliary (Auxiliary *auxiliary)

## Detailed Description

Trackball is an event handler that provides mouse and touch controlled 3d trackball camera view manipulation.

## Member Function Documentation

## ◆ apply() [1/12]

void vsg::Trackball::apply | ( | ButtonPressEvent & | buttonPress | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [2/12]

void vsg::Trackball::apply | ( | ButtonReleaseEvent & | buttonRelease | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [3/12]

void vsg::Trackball::apply | ( | FocusInEvent & | focusIn | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [4/12]

void vsg::Trackball::apply | ( | FocusOutEvent & | focusOut | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [5/12]

void vsg::Trackball::apply | ( | FrameEvent & | frame | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [6/12]

void vsg::Trackball::apply | ( | KeyPressEvent & | keyPress | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [7/12]

void vsg::Trackball::apply | ( | KeyReleaseEvent & | keyRelease | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [8/12]

void vsg::Trackball::apply | ( | MoveEvent & | moveEvent | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [9/12]

void vsg::Trackball::apply | ( | ScrollWheelEvent & | scrollWheel | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [10/12]

void vsg::Trackball::apply | ( | TouchDownEvent & | touchDown | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [11/12]

void vsg::Trackball::apply | ( | TouchMoveEvent & | touchMove | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ apply() [12/12]

void vsg::Trackball::apply | ( | TouchUpEvent & | touchUp | ) |
| overridevirtual

Reimplemented from vsg::Visitor.

## ◆ setViewpoint()

void vsg::Trackball::setViewpoint | ( | ref_ptr< LookAt > | lookAt,
|  | double | duration = 1.0 )

set the LookAt viewport to the specified lookAt, animating the movements from the current lookAt to the new one. A value of 0.0 instantly moves the lookAt to the new value.

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

- include/vsg/app/Trackball.h