Visualization Library 2.0.0
A lightweight C++ OpenGL middleware for 2D/3D graphics
|
[Download] [Tutorials] [All Classes] [Grouped Classes] |
This class lets you rotate a Camera or a Transform node using a virtual trackball. More...
#include <TrackballManipulator.hpp>
Public Types | |
enum | ETrackballMode { NoMode, RotationMode, TranslationMode, ZoomMode } |
Public Member Functions | |
TrackballManipulator () | |
Constructor. More... | |
virtual void | mouseDownEvent (EMouseButton, int x, int y) |
Event generated when one of the mouse buttons is pressed. More... | |
virtual void | mouseUpEvent (EMouseButton, int x, int y) |
Event generated when one of the mouse buttons is released. More... | |
virtual void | mouseMoveEvent (int x, int y) |
Event generated when the mouse moves. More... | |
virtual void | enableEvent (bool enabled) |
Event generated whenever setEnabled() is called. More... | |
virtual void | initEvent () |
Event generated when the bound OpenGLContext bocomes initialized or when the event listener is bound to an initialized OpenGLContext. More... | |
virtual void | destroyEvent () |
Event generated right before the bound OpenGLContext is destroyed. More... | |
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(). More... | |
virtual void | addedListenerEvent (OpenGLContext *) |
Event generated whenever a listener is bound to an OpenGLContext context. More... | |
virtual void | removedListenerEvent (OpenGLContext *) |
Event generated whenever a listener is unbound from an OpenGLContext context. More... | |
virtual void | mouseWheelEvent (int) |
Event generated when the mouse wheel rotated. More... | |
virtual void | keyPressEvent (unsigned short, EKey) |
Event generated when a key is pressed. More... | |
virtual void | keyReleaseEvent (unsigned short, EKey) |
Event generated when a key is released. More... | |
virtual void | resizeEvent (int, int) |
Event generated when the bound OpenGLContext is resized. More... | |
virtual void | fileDroppedEvent (const std::vector< String > &) |
Event generated when one or more files are dropped on the bound OpenGLContext's area. More... | |
virtual void | visibilityEvent (bool) |
Event generated when the bound OpenGLContext is shown or hidden. More... | |
void | setCamera (Camera *camera) |
The camera through which the trackball manipulator is used. More... | |
Camera * | camera () |
The camera through which the trackball manipulator is used. More... | |
void | setPivot (vec3 pivot) |
The center point around which the camera will rotate. More... | |
vec3 | pivot () const |
The center point around which the camera will rotate. More... | |
void | setTransform (Transform *tr) |
If NULL the trackball will manipulate the camera transform, if non NULL the trackball will manipulate the specified transform. More... | |
Transform * | transform () |
If NULL the trackball will manipulate the camera transform, if non NULL the trackball will manipulate the specified transform. More... | |
int | rotationButton () const |
Mouse button used to rotate. More... | |
void | setRotationButton (int mouse_button) |
Mouse button used to rotate. More... | |
int | zoomButton () const |
Mouse button used to zoom. More... | |
void | setZoomButton (int mouse_button) |
Mouse button used to zoom. More... | |
int | translationButton () const |
Mouse button used to translate the view. More... | |
void | setTranslationButton (int mouse_button) |
Mouse button used to translate the view. More... | |
float | rotationSpeed () const |
Rotation speed multiplicative factor (default = 1). More... | |
void | setRotationSpeed (float speed) |
Rotation speed multiplicative factor (default = 1). More... | |
float | zoomSpeed () const |
Zoom speed multiplicative factor (default = 1). More... | |
void | setZoomSpeed (float speed) |
Zoom speed multiplicative factor (default = 1). More... | |
float | translationSpeed () const |
Translation speed multiplicative factor (default = 1). More... | |
void | setTranslationSpeed (float speed) |
Translation speed multiplicative factor (default = 1). More... | |
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(). More... | |
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 Actors. See also Camera::adjustView(). More... | |
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(). More... | |
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(). More... | |
mat4 | trackballRotation (int x, int y) |
vec3 | computeVector (int x, int y) |
ETrackballMode | mode () const |
Returns the current trackball manipulator state. More... | |
Public Member Functions inherited from vl::UIEventListener | |
UIEventListener () | |
Constructor. More... | |
virtual void | setEnabled (bool enabled) |
Enables or disables a UIEventListener. More... | |
bool | isEnabled () const |
Returns whether the UIEventListener is currently enabled or not. More... | |
OpenGLContext * | openglContext () |
Returns the OpenGLContext to which this UIEventListener is bound or NULL if no context is bound. More... | |
const OpenGLContext * | openglContext () const |
Returns the OpenGLContext to which this UIEventListener is bound or NULL if no context is bound. More... | |
Public Member Functions inherited from vl::Object | |
Object () | |
Constructor. More... | |
Object (const Object &other) | |
Copy constructor: copies the name, ref count mutex and user data. More... | |
Object & | operator= (const Object &other) |
Copy operator: copies the object's name, ref count mutex and user data. More... | |
const std::string & | objectName () const |
The name of the object, by default set to the object's class name. More... | |
void | setObjectName (const char *name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setObjectName (const std::string &name) |
The name of the object, by default set to the object's class name in debug builds. More... | |
void | setRefCountMutex (IMutex *mutex) |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
IMutex * | refCountMutex () |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
const IMutex * | refCountMutex () const |
The mutex used to protect the reference counting of an Object across multiple threads. More... | |
int | referenceCount () const |
Returns the number of references of an object. More... | |
void | incReference () const |
Increments the reference count of an object. More... | |
void | decReference () |
Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More... | |
void | setAutomaticDelete (bool autodel_on) |
If set to true the Object is deleted when its reference count reaches 0. More... | |
bool | automaticDelete () const |
If set to true the Object is deleted when its reference count reaches 0. More... | |
template<class T > | |
T * | as () |
Casts an Object to the specified class. More... | |
template<class T > | |
const T * | as () const |
Casts an Object to the specified class. More... | |
Protected Attributes | |
ref< Camera > | mCamera |
ivec2 | mMouseStart |
mat4 | mStartMatrix |
vec3 | mPivot |
vec3 | mStartCameraPos |
vec3 | mStartPivot |
ref< Transform > | mTransform |
ETrackballMode | mMode |
int | mRotationButton |
int | mTranslationButton |
int | mZoomButton |
float | mRotationSpeed |
float | mTranslationSpeed |
float | mZoomSpeed |
Protected Attributes inherited from vl::Object | |
std::string | mObjectName |
IMutex * | mRefCountMutex |
int | mReferenceCount |
bool | mAutomaticDelete |
Additional Inherited Members | |
Protected Member Functions inherited from vl::Object | |
virtual | ~Object () |
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.
Definition at line 61 of file TrackballManipulator.hpp.
Enumerator | |
---|---|
NoMode | |
RotationMode | |
TranslationMode | |
ZoomMode |
Definition at line 66 of file TrackballManipulator.hpp.
|
inline |
Constructor.
Definition at line 70 of file TrackballManipulator.hpp.
|
inlinevirtual |
Event generated whenever a listener is bound to an OpenGLContext context.
Implements vl::UIEventListener.
Definition at line 93 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 Actors. 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::Actor::lod(), vl::Renderable::setBoundsDirty(), 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 244 of file TrackballManipulator.cpp.
References adjustView(), vl::SceneManager::extractVisibleActors(), and NULL.
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 251 of file TrackballManipulator.cpp.
References adjustView(), NULL, and vl::Rendering::sceneManagers().
|
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().
vec3 TrackballManipulator::computeVector | ( | int | x, |
int | y | ||
) |
Definition at line 193 of file TrackballManipulator.cpp.
References camera(), vl::Viewport::height(), vl::Vector3< T_Scalar >::normalize(), vl::sqrt(), vl::Camera::viewport(), VL_CHECK, vl::Viewport::width(), vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().
Referenced by trackballRotation().
|
inlinevirtual |
Event generated right before the bound OpenGLContext is destroyed.
Implements vl::UIEventListener.
Definition at line 89 of file TrackballManipulator.hpp.
|
virtual |
Event generated whenever setEnabled() is called.
Implements vl::UIEventListener.
Definition at line 260 of file TrackballManipulator.cpp.
References mMode, NoMode, vl::UIEventListener::openglContext(), vl::OpenGLContext::setContinuousUpdate(), and vl::OpenGLContext::setMouseVisible().
|
inlinevirtual |
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.
|
inlinevirtual |
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.
|
inlinevirtual |
Event generated when a key is pressed.
Implements vl::UIEventListener.
Definition at line 99 of file TrackballManipulator.hpp.
|
inlinevirtual |
Event generated when a key is released.
Implements vl::UIEventListener.
Definition at line 101 of file TrackballManipulator.hpp.
|
inline |
Returns the current trackball manipulator state.
Definition at line 184 of file TrackballManipulator.hpp.
Referenced by mouseDownEvent(), mouseMoveEvent(), and mouseUpEvent().
|
virtual |
Event generated when one of the mouse buttons is pressed.
Implements vl::UIEventListener.
Definition at line 41 of file TrackballManipulator.cpp.
References camera(), vl::OpenGLContext::framebuffer(), vl::Matrix4< T_Scalar >::getT(), vl::Viewport::height(), vl::Framebuffer::height(), mMode, mMouseStart, mode(), vl::Camera::modelingMatrix(), mPivot, mStartCameraPos, mStartMatrix, mStartPivot, mTransform, NoMode, NULL, vl::UIEventListener::openglContext(), rotationButton(), RotationMode, translationButton(), TranslationMode, vl::Camera::viewport(), VL_CHECK, vl::Viewport::width(), vl::Viewport::x(), vl::Vector2< T_Scalar >::x(), vl::Viewport::y(), vl::Vector2< T_Scalar >::y(), zoomButton(), and ZoomMode.
|
virtual |
Event generated when the mouse moves.
Implements vl::UIEventListener.
Definition at line 108 of file TrackballManipulator.cpp.
References camera(), vl::distance(), vl::OpenGLContext::framebuffer(), vl::Matrix4< float >::getTranslation(), vl::Matrix4< T_Scalar >::getX(), vl::Matrix4< T_Scalar >::getY(), vl::Matrix4< T_Scalar >::getZ(), vl::Viewport::height(), vl::Framebuffer::height(), vl::length(), mMouseStart, mode(), vl::Camera::modelingMatrix(), mPivot, mStartCameraPos, mStartMatrix, mStartPivot, mTransform, NoMode, NULL, vl::UIEventListener::openglContext(), RotationMode, vl::Camera::setModelingMatrix(), vl::Matrix4< T_Scalar >::setT(), trackballRotation(), TranslationMode, translationSpeed(), vl::OpenGLContext::update(), vl::Camera::viewport(), VL_CHECK, vl::Viewport::x(), vl::Vector2< T_Scalar >::x(), vl::Viewport::y(), vl::Vector2< T_Scalar >::y(), ZoomMode, and zoomSpeed().
|
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.
|
inlinevirtual |
Event generated when the mouse wheel rotated.
Implements vl::UIEventListener.
Definition at line 97 of file TrackballManipulator.hpp.
|
inline |
The center point around which the camera will rotate.
Definition at line 121 of file TrackballManipulator.hpp.
|
inlinevirtual |
Event generated whenever a listener is unbound from an OpenGLContext context.
Implements vl::UIEventListener.
Definition at line 95 of file TrackballManipulator.hpp.
|
inlinevirtual |
Event generated when the bound OpenGLContext is resized.
Implements vl::UIEventListener.
Definition at line 103 of file TrackballManipulator.hpp.
|
inline |
Mouse button used to rotate.
Definition at line 130 of file TrackballManipulator.hpp.
Referenced by mouseDownEvent(), and mouseUpEvent().
|
inline |
Rotation speed multiplicative factor (default = 1).
Definition at line 148 of file TrackballManipulator.hpp.
Referenced by trackballRotation().
|
inline |
The camera through which the trackball manipulator is used.
Definition at line 112 of file TrackballManipulator.hpp.
|
inline |
The center point around which the camera will rotate.
Definition at line 118 of file TrackballManipulator.hpp.
Referenced by adjustView().
|
inline |
Mouse button used to rotate.
Definition at line 133 of file TrackballManipulator.hpp.
|
inline |
Rotation speed multiplicative factor (default = 1).
Definition at line 151 of file TrackballManipulator.hpp.
|
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.
|
inline |
Mouse button used to translate the view.
Definition at line 145 of file TrackballManipulator.hpp.
|
inline |
Translation speed multiplicative factor (default = 1).
Definition at line 163 of file TrackballManipulator.hpp.
|
inline |
Mouse button used to zoom.
Definition at line 139 of file TrackballManipulator.hpp.
|
inline |
Zoom speed multiplicative factor (default = 1).
Definition at line 157 of file TrackballManipulator.hpp.
mat4 TrackballManipulator::trackballRotation | ( | int | x, |
int | y | ||
) |
Definition at line 170 of file TrackballManipulator.cpp.
References vl::acos(), camera(), vl::clamp(), computeVector(), vl::cross(), vl::dot(), vl::dRAD_TO_DEG, vl::Matrix4< T_Scalar >::get3x3(), vl::Matrix4< float >::getRotation(), mMouseStart, vl::Camera::modelingMatrix(), mTransform, vl::Vector3< T_Scalar >::normalize(), rotationSpeed(), VL_CHECK, vl::Vector2< T_Scalar >::x(), and vl::Vector2< T_Scalar >::y().
Referenced by mouseMoveEvent().
|
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.
|
inline |
Mouse button used to translate the view.
Definition at line 142 of file TrackballManipulator.hpp.
Referenced by mouseDownEvent(), and mouseUpEvent().
|
inline |
Translation speed multiplicative factor (default = 1).
Definition at line 160 of file TrackballManipulator.hpp.
Referenced by mouseMoveEvent().
|
inlinevirtual |
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.
|
inlinevirtual |
Event generated when the bound OpenGLContext is shown or hidden.
Implements vl::UIEventListener.
Definition at line 107 of file TrackballManipulator.hpp.
|
inline |
Mouse button used to zoom.
Definition at line 136 of file TrackballManipulator.hpp.
Referenced by mouseDownEvent(), and mouseUpEvent().
|
inline |
Zoom speed multiplicative factor (default = 1).
Definition at line 154 of file TrackballManipulator.hpp.
Referenced by mouseMoveEvent().
Definition at line 187 of file TrackballManipulator.hpp.
|
protected |
Definition at line 194 of file TrackballManipulator.hpp.
Referenced by enableEvent(), mouseDownEvent(), and mouseUpEvent().
|
protected |
Definition at line 188 of file TrackballManipulator.hpp.
Referenced by mouseDownEvent(), mouseMoveEvent(), and trackballRotation().
|
protected |
Definition at line 190 of file TrackballManipulator.hpp.
Referenced by mouseDownEvent(), and mouseMoveEvent().
|
protected |
Definition at line 195 of file TrackballManipulator.hpp.
|
protected |
Definition at line 198 of file TrackballManipulator.hpp.
|
protected |
Definition at line 191 of file TrackballManipulator.hpp.
Referenced by mouseDownEvent(), and mouseMoveEvent().
|
protected |
Definition at line 189 of file TrackballManipulator.hpp.
Referenced by mouseDownEvent(), and mouseMoveEvent().
|
protected |
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().
|
protected |
Definition at line 196 of file TrackballManipulator.hpp.
|
protected |
Definition at line 199 of file TrackballManipulator.hpp.
|
protected |
Definition at line 197 of file TrackballManipulator.hpp.
|
protected |
Definition at line 200 of file TrackballManipulator.hpp.
Visualization Library 2.0.0 Reference Documentation
Updated on Wed Dec 23 2020 12:44:12.
© Copyright Michele Bosi. All rights reserved.