Visualization Library v1.0.3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Types | Public Member Functions | Protected Attributes

vl::TrackballManipulator Class Reference

This class lets you rotate a Camera or a Transform node using a virtual trackball. More...

#include <TrackballManipulator.hpp>

Inheritance diagram for vl::TrackballManipulator:
vl::UIEventListener vl::Object

List of all members.

Public Types

enum  ETrackballMode { NoMode, RotationMode, TranslationMode, ZoomMode }

Public Member Functions

 TrackballManipulator ()
 Constructor.
virtual void mouseDownEvent (EMouseButton, int x, int y)
 Event generated when one of the mouse buttons is pressed.
virtual void mouseUpEvent (EMouseButton, int x, int y)
 Event generated when one of the mouse buttons is released.
virtual void mouseMoveEvent (int x, int y)
 Event generated when the mouse moves.
virtual void enableEvent (bool enabled)
 Event generated whenever setEnabled() is called.
virtual void initEvent ()
 Event generated when the bound OpenGLContext bocomes initialized or when the event listener is bound to an initialized OpenGLContext.
virtual void destroyEvent ()
 Event generated right before the bound OpenGLContext is destroyed.
virtual void updateEvent ()
 Event generated when the bound OpenGLContext does not have any other message to process and OpenGLContext::continuousUpdate() is set to true or somebody calls OpenGLContext::update().
virtual void addedListenerEvent (OpenGLContext *)
 Event generated whenever a listener is bound to an OpenGLContext context.
virtual void removedListenerEvent (OpenGLContext *)
 Event generated whenever a listener is unbound from an OpenGLContext context.
virtual void mouseWheelEvent (int)
 Event generated when the mouse wheel rotated.
virtual void keyPressEvent (unsigned short, EKey)
 Event generated when a key is pressed.
virtual void keyReleaseEvent (unsigned short, EKey)
 Event generated when a key is released.
virtual void resizeEvent (int, int)
 Event generated when the bound OpenGLContext is resized.
virtual void fileDroppedEvent (const std::vector< String > &)
 Event generated when one or more files are dropped on the bound OpenGLContext's area.
virtual void visibilityEvent (bool)
 Event generated when the bound OpenGLContext is shown or hidden.
void setCamera (Camera *camera)
 The camera through which the trackball manipulator is used.
Cameracamera ()
 The camera through which the trackball manipulator is used.
void setPivot (vec3 pivot)
 The center point around which the camera will rotate.
vec3 pivot () const
 The center point around which the camera will rotate.
void setTransform (Transform *tr)
 If NULL the trackball will manipulate the camera transform, if non NULL the trackball will manipulate the specified transform.
Transformtransform ()
 If NULL the trackball will manipulate the camera transform, if non NULL the trackball will manipulate the specified transform.
int rotationButton () const
 Mouse button used to rotate.
void setRotationButton (int mouse_button)
 Mouse button used to rotate.
int zoomButton () const
 Mouse button used to zoom.
void setZoomButton (int mouse_button)
 Mouse button used to zoom.
int translationButton () const
 Mouse button used to translate the view.
void setTranslationButton (int mouse_button)
 Mouse button used to translate the view.
float rotationSpeed () const
 Rotation speed multiplicative factor (default = 1).
void setRotationSpeed (float speed)
 Rotation speed multiplicative factor (default = 1).
float zoomSpeed () const
 Zoom speed multiplicative factor (default = 1).
void setZoomSpeed (float speed)
 Zoom speed multiplicative factor (default = 1).
float translationSpeed () const
 Translation speed multiplicative factor (default = 1).
void setTranslationSpeed (float speed)
 Translation speed multiplicative factor (default = 1).
void adjustView (const AABB &aabb, const vec3 &dir, const vec3 &up, real bias=1.0f)
 Adjusts the camera position in order to nicely see the scene. It also position the rotation pivot to the center of the AABB. See also Camera::adjustView().
void adjustView (ActorCollection &actors, const vec3 &dir, const vec3 &up, real bias=1.0f)
 Adjusts the camera position in order to nicely see the scene. It also position the rotation pivot to the center of the AABB containing the Actor[s]. See also Camera::adjustView().
void adjustView (SceneManager *scene, const vec3 &dir, const vec3 &up, real bias=1.0f)
 Adjusts the camera position in order to nicely see the scene. It also position the rotation pivot to the center of the AABB containing the given scene manager. See also Camera::adjustView().
void adjustView (Rendering *rendering, const vec3 &dir, const vec3 &up, real bias=1.0f)
 Adjusts the camera position in order to nicely see the scene. It also position the rotation pivot to the center of the AABB containing all the scene managers part of the given rendering. See also Camera::adjustView().
mat4 trackballRotation (int x, int y)
vec3 computeVector (int x, int y)
ETrackballMode mode () const
 Returns the current trackball manipulator state.

Protected Attributes

ref< CameramCamera
ivec2 mMouseStart
mat4 mStartMatrix
vec3 mPivot
vec3 mStartCameraPos
vec3 mStartPivot
ref< TransformmTransform
ETrackballMode mMode
int mRotationButton
int mTranslationButton
int mZoomButton
float mRotationSpeed
float mTranslationSpeed
float mZoomSpeed

Detailed Description

This class lets you rotate a Camera or a Transform node using a virtual trackball.

If you set a Transform node to manipulate, using the function setTransform(), the trackball will manipulate the given Transform (rotation only, panning and zooming will always affect the bound Camera). If no Transform is specified or a NULL one is passed to the function setTransform() then the trackball will manipulate the current camera.

Note:
In any case, before using a TrackballManipulator you have to specify a Camera object using the function setCamera().
The Transform is expected to contain only rotation and translation information. Other transformations like shearing, scaling, projection, and so on can produce unspecified results.
See also:
GhostCameraManipulator

Definition at line 61 of file TrackballManipulator.hpp.


Member Enumeration Documentation

Enumerator:
NoMode 
RotationMode 
TranslationMode 
ZoomMode 

Definition at line 66 of file TrackballManipulator.hpp.


Constructor & Destructor Documentation

vl::TrackballManipulator::TrackballManipulator (  ) [inline]

Constructor.

Definition at line 70 of file TrackballManipulator.hpp.

References VL_DEBUG_SET_OBJECT_NAME.


Member Function Documentation

void TrackballManipulator::mouseDownEvent ( EMouseButton  button,
int  x,
int  y 
) [virtual]
void TrackballManipulator::mouseUpEvent ( EMouseButton  button,
int  x,
int  y 
) [virtual]

Event generated when one of the mouse buttons is released.

Implements vl::UIEventListener.

Definition at line 88 of file TrackballManipulator.cpp.

References camera(), mMode, mode(), NoMode, NULL, rotationButton(), RotationMode, translationButton(), TranslationMode, zoomButton(), and ZoomMode.

void TrackballManipulator::mouseMoveEvent ( int  x,
int  y 
) [virtual]
void TrackballManipulator::enableEvent ( bool  enabled ) [virtual]
virtual void vl::TrackballManipulator::initEvent (  ) [inline, virtual]

Event generated when the bound OpenGLContext bocomes initialized or when the event listener is bound to an initialized OpenGLContext.

Implements vl::UIEventListener.

Definition at line 87 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::destroyEvent (  ) [inline, virtual]

Event generated right before the bound OpenGLContext is destroyed.

Implements vl::UIEventListener.

Definition at line 89 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::updateEvent (  ) [inline, virtual]

Event generated when the bound OpenGLContext does not have any other message to process and OpenGLContext::continuousUpdate() is set to true or somebody calls OpenGLContext::update().

Implements vl::UIEventListener.

Definition at line 91 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::addedListenerEvent ( OpenGLContext  ) [inline, virtual]

Event generated whenever a listener is bound to an OpenGLContext context.

Implements vl::UIEventListener.

Definition at line 93 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::removedListenerEvent ( OpenGLContext  ) [inline, virtual]

Event generated whenever a listener is unbound from an OpenGLContext context.

Implements vl::UIEventListener.

Definition at line 95 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::mouseWheelEvent ( int  n ) [inline, virtual]

Event generated when the mouse wheel rotated.

Implements vl::UIEventListener.

Definition at line 97 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::keyPressEvent ( unsigned  unicode_ch,
EKey  key 
) [inline, virtual]

Event generated when a key is pressed.

Implements vl::UIEventListener.

Definition at line 99 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::keyReleaseEvent ( unsigned  unicode_ch,
EKey  key 
) [inline, virtual]

Event generated when a key is released.

Implements vl::UIEventListener.

Definition at line 101 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::resizeEvent ( int  x,
int  y 
) [inline, virtual]

Event generated when the bound OpenGLContext is resized.

Implements vl::UIEventListener.

Definition at line 103 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::fileDroppedEvent ( const std::vector< String > &  files ) [inline, virtual]

Event generated when one or more files are dropped on the bound OpenGLContext's area.

Implements vl::UIEventListener.

Definition at line 105 of file TrackballManipulator.hpp.

virtual void vl::TrackballManipulator::visibilityEvent ( bool  visible ) [inline, virtual]

Event generated when the bound OpenGLContext is shown or hidden.

Implements vl::UIEventListener.

Definition at line 107 of file TrackballManipulator.hpp.

void vl::TrackballManipulator::setCamera ( Camera camera ) [inline]

The camera through which the trackball manipulator is used.

Definition at line 112 of file TrackballManipulator.hpp.

Camera* vl::TrackballManipulator::camera (  ) [inline]

The camera through which the trackball manipulator is used.

Definition at line 115 of file TrackballManipulator.hpp.

Referenced by adjustView(), computeVector(), mouseDownEvent(), mouseMoveEvent(), mouseUpEvent(), and trackballRotation().

void vl::TrackballManipulator::setPivot ( vec3  pivot ) [inline]

The center point around which the camera will rotate.

Definition at line 118 of file TrackballManipulator.hpp.

Referenced by adjustView().

vec3 vl::TrackballManipulator::pivot (  ) const [inline]

The center point around which the camera will rotate.

Definition at line 121 of file TrackballManipulator.hpp.

void vl::TrackballManipulator::setTransform ( Transform tr ) [inline]

If NULL the trackball will manipulate the camera transform, if non NULL the trackball will manipulate the specified transform.

Definition at line 124 of file TrackballManipulator.hpp.

Transform* vl::TrackballManipulator::transform (  ) [inline]

If NULL the trackball will manipulate the camera transform, if non NULL the trackball will manipulate the specified transform.

Definition at line 127 of file TrackballManipulator.hpp.

int vl::TrackballManipulator::rotationButton (  ) const [inline]

Mouse button used to rotate.

Definition at line 130 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), and mouseUpEvent().

void vl::TrackballManipulator::setRotationButton ( int  mouse_button ) [inline]

Mouse button used to rotate.

Definition at line 133 of file TrackballManipulator.hpp.

int vl::TrackballManipulator::zoomButton (  ) const [inline]

Mouse button used to zoom.

Definition at line 136 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), and mouseUpEvent().

void vl::TrackballManipulator::setZoomButton ( int  mouse_button ) [inline]

Mouse button used to zoom.

Definition at line 139 of file TrackballManipulator.hpp.

int vl::TrackballManipulator::translationButton (  ) const [inline]

Mouse button used to translate the view.

Definition at line 142 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), and mouseUpEvent().

void vl::TrackballManipulator::setTranslationButton ( int  mouse_button ) [inline]

Mouse button used to translate the view.

Definition at line 145 of file TrackballManipulator.hpp.

float vl::TrackballManipulator::rotationSpeed (  ) const [inline]

Rotation speed multiplicative factor (default = 1).

Definition at line 148 of file TrackballManipulator.hpp.

Referenced by trackballRotation().

void vl::TrackballManipulator::setRotationSpeed ( float  speed ) [inline]

Rotation speed multiplicative factor (default = 1).

Definition at line 151 of file TrackballManipulator.hpp.

float vl::TrackballManipulator::zoomSpeed (  ) const [inline]

Zoom speed multiplicative factor (default = 1).

Definition at line 154 of file TrackballManipulator.hpp.

Referenced by mouseMoveEvent().

void vl::TrackballManipulator::setZoomSpeed ( float  speed ) [inline]

Zoom speed multiplicative factor (default = 1).

Definition at line 157 of file TrackballManipulator.hpp.

float vl::TrackballManipulator::translationSpeed (  ) const [inline]

Translation speed multiplicative factor (default = 1).

Definition at line 160 of file TrackballManipulator.hpp.

Referenced by mouseMoveEvent().

void vl::TrackballManipulator::setTranslationSpeed ( float  speed ) [inline]

Translation speed multiplicative factor (default = 1).

Definition at line 163 of file TrackballManipulator.hpp.

void TrackballManipulator::adjustView ( const AABB aabb,
const vec3 dir,
const vec3 up,
real  bias = 1.0f 
)

Adjusts the camera position in order to nicely see the scene. It also position the rotation pivot to the center of the AABB. See also Camera::adjustView().

Definition at line 217 of file TrackballManipulator.cpp.

References vl::Camera::adjustView(), camera(), vl::AABB::center(), vl::AABB::isNull(), setPivot(), and VL_CHECK.

Referenced by adjustView().

void TrackballManipulator::adjustView ( ActorCollection actors,
const vec3 dir,
const vec3 up,
real  bias = 1.0f 
)

Adjusts the camera position in order to nicely see the scene. It also position the rotation pivot to the center of the AABB containing the Actor[s]. See also Camera::adjustView().

Definition at line 226 of file TrackballManipulator.cpp.

References adjustView(), vl::Collection< T >::at(), vl::Actor::boundingBox(), vl::Actor::computeBounds(), vl::Transform::computeWorldMatrix(), vl::Collection< T >::empty(), vl::Collection< T >::size(), and vl::Actor::transform().

void TrackballManipulator::adjustView ( SceneManager scene,
const vec3 dir,
const vec3 up,
real  bias = 1.0f 
)

Adjusts the camera position in order to nicely see the scene. It also position the rotation pivot to the center of the AABB containing the given scene manager. See also Camera::adjustView().

Definition at line 243 of file TrackballManipulator.cpp.

References adjustView(), and vl::SceneManager::extractActors().

void TrackballManipulator::adjustView ( Rendering rendering,
const vec3 dir,
const vec3 up,
real  bias = 1.0f 
)

Adjusts the camera position in order to nicely see the scene. It also position the rotation pivot to the center of the AABB containing all the scene managers part of the given rendering. See also Camera::adjustView().

Definition at line 250 of file TrackballManipulator.cpp.

References adjustView(), vl::Collection< T >::at(), vl::SceneManager::extractActors(), vl::Rendering::sceneManagers(), and vl::Collection< T >::size().

mat4 TrackballManipulator::trackballRotation ( int  x,
int  y 
)
vec3 TrackballManipulator::computeVector ( int  x,
int  y 
)
ETrackballMode vl::TrackballManipulator::mode (  ) const [inline]

Returns the current trackball manipulator state.

Definition at line 184 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), mouseMoveEvent(), and mouseUpEvent().


Member Data Documentation

Definition at line 187 of file TrackballManipulator.hpp.

Definition at line 188 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), mouseMoveEvent(), and trackballRotation().

Definition at line 189 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), and mouseMoveEvent().

Definition at line 190 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), and mouseMoveEvent().

Definition at line 191 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), and mouseMoveEvent().

Definition at line 192 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), and mouseMoveEvent().

Definition at line 193 of file TrackballManipulator.hpp.

Referenced by mouseDownEvent(), mouseMoveEvent(), and trackballRotation().

Definition at line 194 of file TrackballManipulator.hpp.

Referenced by enableEvent(), mouseDownEvent(), and mouseUpEvent().

Definition at line 195 of file TrackballManipulator.hpp.

Definition at line 196 of file TrackballManipulator.hpp.

Definition at line 197 of file TrackballManipulator.hpp.

Definition at line 198 of file TrackballManipulator.hpp.

Definition at line 199 of file TrackballManipulator.hpp.

Definition at line 200 of file TrackballManipulator.hpp.


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

Visualization Library v1.0.3 Reference Documentation
Copyright Michele Bosi. All rights reserved.
Updated on Tue Feb 7 2017 00:55:12.
Permission is granted to use this page to write and publish articles regarding Visualization Library.