Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [Tutorials] [All Classes] [Grouped Classes] |
The GhostCameraManipulator class is an UIEventListener that controls the position and orientation of a Camera. More...
#include <GhostCameraManipulator.hpp>
Public Member Functions | |
GhostCameraManipulator () | |
Constructor. | |
virtual void | mouseMoveEvent (int x, int y) |
Event generated when the mouse moves. | |
void | enableEvent (bool enabled) |
Event generated whenever setEnabled() is called. | |
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 | 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 | 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 | mouseUpEvent (EMouseButton, int, int) |
Event generated when one of the mouse buttons is released. | |
virtual void | mouseDownEvent (EMouseButton, int, int) |
Event generated when one of the mouse buttons is pressed. | |
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 to be manipulated. | |
Camera * | camera () |
The camera to be manipulated. | |
const Camera * | camera () const |
The camera to be manipulated. | |
void | setKeysForward (EKey key, EKey modifier=Key_None) |
Key bindings to move forward (default = Key_W). | |
void | setKeysBackward (EKey key, EKey modifier=Key_None) |
Key bindings to move backward (default = Key_S). | |
void | setKeysLeft (EKey key, EKey modifier=Key_None) |
Key bindings to move left (default = Key_A). | |
void | setKeysRight (EKey key, EKey modifier=Key_None) |
Key bindings to move right (default = Key_D). | |
void | setKeysUp (EKey key, EKey modifier=Key_None) |
Key bindings to move up (default = Key_W + Key_Shift). | |
void | setKeysDown (EKey key, EKey modifier=Key_None) |
Key bindings to move down (default = Key_S + Key_Shift). | |
void | setRotationSpeed (real speed) |
The camera rotation speed (default = 0.5). | |
real | rotationSpeed () const |
The camera rotation speed (default = 0.5). | |
void | setMovementSpeed (real speed) |
The camera translation speed (default = 50). | |
real | movementSpeed () const |
The camera translation speed (default = 50). | |
Protected Member Functions | |
void | setPosition (vec3 position) |
const vec3 & | position () const |
void | setXDegrees (real degree) |
real | xDegrees () |
void | setYDegrees (real degree) |
real | yDegrees () |
Protected Attributes | |
ref< Camera > | mCamera |
vec3 | mPosition |
real | mLastTime |
real | mRotationSpeed |
real | mMovementSpeed |
real | mXDegrees |
real | mYDegrees |
EKey | mKeysForward [2] |
EKey | mKeysBackward [2] |
EKey | mKeysUp [2] |
EKey | mKeysDown [2] |
EKey | mKeysLeft [2] |
EKey | mKeysRight [2] |
The GhostCameraManipulator class is an UIEventListener that controls the position and orientation of a Camera.
Using the GhostCameraManipulator class the user can freely fly around in the scene as if it was a ghost. Default key bindings:
Key_W
Key_S
Key_A
Key_D
Key_W
+ Key_Shift
Key_S
+ Key_Shift
Definition at line 55 of file GhostCameraManipulator.hpp.
GhostCameraManipulator::GhostCameraManipulator | ( | ) |
Constructor.
Definition at line 41 of file GhostCameraManipulator.cpp.
References vl::Key_A, vl::Key_D, vl::Key_S, vl::Key_Shift, vl::Key_W, mLastTime, mMovementSpeed, mPosition, mRotationSpeed, mXDegrees, mYDegrees, setKeysBackward(), setKeysDown(), setKeysForward(), setKeysLeft(), setKeysRight(), setKeysUp(), and VL_DEBUG_SET_OBJECT_NAME.
void GhostCameraManipulator::mouseMoveEvent | ( | int | x, |
int | y | ||
) | [virtual] |
Event generated when the mouse moves.
Implements vl::UIEventListener.
Definition at line 59 of file GhostCameraManipulator.cpp.
References camera(), vl::Viewport::center(), vl::OpenGLContext::framebuffer(), vl::Viewport::height(), vl::Framebuffer::height(), vl::OpenGLContext::ignoreNextMouseMoveEvent(), mRotationSpeed, mXDegrees, mYDegrees, NULL, vl::UIEventListener::openglContext(), vl::OpenGLContext::setMousePosition(), vl::Camera::viewport(), VL_CHECK, vl::Vector2< T_Scalar >::x(), and vl::Viewport::y().
void GhostCameraManipulator::enableEvent | ( | bool | enabled ) | [virtual] |
Event generated whenever setEnabled() is called.
Implements vl::UIEventListener.
Definition at line 132 of file GhostCameraManipulator.cpp.
References camera(), vl::Viewport::center(), vl::OpenGLContext::framebuffer(), vl::Matrix4< T_Scalar >::getYXRotationAngles(), vl::Viewport::height(), vl::Framebuffer::height(), vl::OpenGLContext::ignoreNextMouseMoveEvent(), vl::Camera::modelingMatrix(), NULL, vl::UIEventListener::openglContext(), vl::OpenGLContext::setContinuousUpdate(), vl::OpenGLContext::setMousePosition(), vl::OpenGLContext::setMouseVisible(), setPosition(), setXDegrees(), setYDegrees(), vl::Camera::viewport(), vl::Vector2< T_Scalar >::x(), and vl::Viewport::y().
void GhostCameraManipulator::updateEvent | ( | ) | [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 74 of file GhostCameraManipulator.cpp.
References camera(), vl::Time::currentTime(), vl::Matrix4< float >::getRotation(), vl::Matrix4< float >::getTranslation(), vl::Matrix4< T_Scalar >::getX(), vl::Matrix4< T_Scalar >::getY(), vl::Matrix4< T_Scalar >::getZ(), vl::OpenGLContext::isKeyPressed(), vl::Key_Alt, vl::Key_Ctrl, vl::Key_None, vl::Key_Shift, mKeysBackward, mKeysDown, mKeysForward, mKeysLeft, mKeysRight, mKeysUp, mLastTime, mMovementSpeed, vl::Camera::modelingMatrix(), mPosition, mXDegrees, mYDegrees, vl::Vector3< T_Scalar >::normalize(), NULL, vl::UIEventListener::openglContext(), vl::Camera::setModelingMatrix(), vl::Vector3< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), and vl::Vector3< T_Scalar >::z().
virtual void vl::GhostCameraManipulator::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 71 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::destroyEvent | ( | ) | [inline, virtual] |
Event generated right before the bound OpenGLContext is destroyed.
Implements vl::UIEventListener.
Definition at line 73 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::addedListenerEvent | ( | OpenGLContext * | ) | [inline, virtual] |
Event generated whenever a listener is bound to an OpenGLContext context.
Implements vl::UIEventListener.
Definition at line 75 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::removedListenerEvent | ( | OpenGLContext * | ) | [inline, virtual] |
Event generated whenever a listener is unbound from an OpenGLContext context.
Implements vl::UIEventListener.
Definition at line 77 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::mouseUpEvent | ( | EMouseButton | button, |
int | x, | ||
int | y | ||
) | [inline, virtual] |
Event generated when one of the mouse buttons is released.
Implements vl::UIEventListener.
Definition at line 79 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::mouseDownEvent | ( | EMouseButton | button, |
int | x, | ||
int | y | ||
) | [inline, virtual] |
Event generated when one of the mouse buttons is pressed.
Implements vl::UIEventListener.
Definition at line 81 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::mouseWheelEvent | ( | int | n ) | [inline, virtual] |
Event generated when the mouse wheel rotated.
Implements vl::UIEventListener.
Definition at line 83 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::keyPressEvent | ( | unsigned | unicode_ch, |
EKey | key | ||
) | [inline, virtual] |
Event generated when a key is pressed.
Implements vl::UIEventListener.
Definition at line 85 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::keyReleaseEvent | ( | unsigned | unicode_ch, |
EKey | key | ||
) | [inline, virtual] |
Event generated when a key is released.
Implements vl::UIEventListener.
Definition at line 87 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::resizeEvent | ( | int | x, |
int | y | ||
) | [inline, virtual] |
Event generated when the bound OpenGLContext is resized.
Implements vl::UIEventListener.
Definition at line 89 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::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 91 of file GhostCameraManipulator.hpp.
virtual void vl::GhostCameraManipulator::visibilityEvent | ( | bool | visible ) | [inline, virtual] |
Event generated when the bound OpenGLContext is shown or hidden.
Implements vl::UIEventListener.
Definition at line 93 of file GhostCameraManipulator.hpp.
void GhostCameraManipulator::setCamera | ( | Camera * | camera ) |
The camera to be manipulated.
Definition at line 127 of file GhostCameraManipulator.cpp.
Camera * GhostCameraManipulator::camera | ( | ) |
The camera to be manipulated.
Definition at line 129 of file GhostCameraManipulator.cpp.
References vl::ref< T >::get(), and mCamera.
Referenced by enableEvent(), mouseMoveEvent(), setCamera(), and updateEvent().
const Camera * GhostCameraManipulator::camera | ( | ) | const |
The camera to be manipulated.
Definition at line 130 of file GhostCameraManipulator.cpp.
References vl::ref< T >::get(), and mCamera.
Key bindings to move forward (default = Key_W).
Definition at line 107 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator().
Key bindings to move backward (default = Key_S).
Definition at line 110 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator().
Key bindings to move left (default = Key_A).
Definition at line 113 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator().
Key bindings to move right (default = Key_D).
Definition at line 116 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator().
Key bindings to move up (default = Key_W + Key_Shift).
Definition at line 119 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator().
Key bindings to move down (default = Key_S + Key_Shift).
Definition at line 122 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator().
void vl::GhostCameraManipulator::setRotationSpeed | ( | real | speed ) | [inline] |
The camera rotation speed (default = 0.5).
Definition at line 125 of file GhostCameraManipulator.hpp.
real vl::GhostCameraManipulator::rotationSpeed | ( | ) | const [inline] |
The camera rotation speed (default = 0.5).
Definition at line 128 of file GhostCameraManipulator.hpp.
void vl::GhostCameraManipulator::setMovementSpeed | ( | real | speed ) | [inline] |
The camera translation speed (default = 50).
Definition at line 131 of file GhostCameraManipulator.hpp.
real vl::GhostCameraManipulator::movementSpeed | ( | ) | const [inline] |
The camera translation speed (default = 50).
Definition at line 134 of file GhostCameraManipulator.hpp.
void vl::GhostCameraManipulator::setPosition | ( | vec3 | position ) | [inline, protected] |
Definition at line 137 of file GhostCameraManipulator.hpp.
Referenced by enableEvent().
const vec3& vl::GhostCameraManipulator::position | ( | ) | const [inline, protected] |
Definition at line 139 of file GhostCameraManipulator.hpp.
void vl::GhostCameraManipulator::setXDegrees | ( | real | degree ) | [inline, protected] |
Definition at line 141 of file GhostCameraManipulator.hpp.
Referenced by enableEvent().
real vl::GhostCameraManipulator::xDegrees | ( | ) | [inline, protected] |
Definition at line 143 of file GhostCameraManipulator.hpp.
void vl::GhostCameraManipulator::setYDegrees | ( | real | degree ) | [inline, protected] |
Definition at line 145 of file GhostCameraManipulator.hpp.
Referenced by enableEvent().
real vl::GhostCameraManipulator::yDegrees | ( | ) | [inline, protected] |
Definition at line 147 of file GhostCameraManipulator.hpp.
ref<Camera> vl::GhostCameraManipulator::mCamera [protected] |
Definition at line 150 of file GhostCameraManipulator.hpp.
Referenced by camera(), and setCamera().
vec3 vl::GhostCameraManipulator::mPosition [protected] |
Definition at line 151 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator(), and updateEvent().
real vl::GhostCameraManipulator::mLastTime [protected] |
Definition at line 152 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator(), and updateEvent().
real vl::GhostCameraManipulator::mRotationSpeed [protected] |
Definition at line 153 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator(), and mouseMoveEvent().
real vl::GhostCameraManipulator::mMovementSpeed [protected] |
Definition at line 154 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator(), and updateEvent().
real vl::GhostCameraManipulator::mXDegrees [protected] |
Definition at line 155 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator(), mouseMoveEvent(), and updateEvent().
real vl::GhostCameraManipulator::mYDegrees [protected] |
Definition at line 156 of file GhostCameraManipulator.hpp.
Referenced by GhostCameraManipulator(), mouseMoveEvent(), and updateEvent().
EKey vl::GhostCameraManipulator::mKeysForward[2] [protected] |
Definition at line 157 of file GhostCameraManipulator.hpp.
Referenced by updateEvent().
EKey vl::GhostCameraManipulator::mKeysBackward[2] [protected] |
Definition at line 158 of file GhostCameraManipulator.hpp.
Referenced by updateEvent().
EKey vl::GhostCameraManipulator::mKeysUp[2] [protected] |
Definition at line 159 of file GhostCameraManipulator.hpp.
Referenced by updateEvent().
EKey vl::GhostCameraManipulator::mKeysDown[2] [protected] |
Definition at line 160 of file GhostCameraManipulator.hpp.
Referenced by updateEvent().
EKey vl::GhostCameraManipulator::mKeysLeft[2] [protected] |
Definition at line 161 of file GhostCameraManipulator.hpp.
Referenced by updateEvent().
EKey vl::GhostCameraManipulator::mKeysRight[2] [protected] |
Definition at line 162 of file GhostCameraManipulator.hpp.
Referenced by updateEvent().