# Visualization Library

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

[Home] [Tutorials] [All Classes] [Grouped Classes]

Public Member Functions | Protected Member Functions | Protected Attributes

# vl::GhostCameraManipulator Class Reference

The GhostCameraManipulator class is an UIEventListener that controls the position and orientation of a Camera. More...

`#include <GhostCameraManipulator.hpp>`

Inheritance diagram for vl::GhostCameraManipulator:

List of all members.

## Public Member Functions

virtual const char * | className ()
| Returns the name of the class.
| 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]

## Detailed Description

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:

- Forward = `Key_W`
- Backward = `Key_S`
- Left = `Key_A`
- Right = `Key_D`
- Up = `Key_W` + `Key_Shift`
- Down = `Key_S` + `Key_Shift`
  See also:
    TrackballManipulator

Definition at line 55 of file GhostCameraManipulator.hpp.

## Constructor & Destructor Documentation

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.

## Member Function Documentation

virtual const char* vl::GhostCameraManipulator::className | ( | ) | `[inline, virtual]`

Returns the name of the class.

Reimplemented from vl::UIEventListener.

Definition at line 58 of file GhostCameraManipulator.hpp.

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::Viewport::height(), vl::RenderTarget::height(), vl::OpenGLContext::ignoreNextMouseMoveEvent(), mRotationSpeed, mXDegrees, mYDegrees, vl::UIEventListener::openglContext(), vl::OpenGLContext::renderTarget(), 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::Matrix4< T_Scalar >::getYXRotationAngles(), vl::Viewport::height(), vl::RenderTarget::height(), vl::OpenGLContext::ignoreNextMouseMoveEvent(), vl::Camera::inverseViewMatrix(), vl::UIEventListener::openglContext(), vl::OpenGLContext::renderTarget(), 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< GLfloat >::getRotation(), vl::Matrix4< GLfloat >::getTranslation(), vl::Matrix4< T_Scalar >::getX(), vl::Matrix4< T_Scalar >::getY(), vl::Matrix4< T_Scalar >::getZ(), vl::Camera::inverseViewMatrix(), vl::OpenGLContext::isKeyPressed(), vl::Key_Alt, vl::Key_Ctrl, vl::Key_None, vl::Key_Shift, mKeysBackward, mKeysDown, mKeysForward, mKeysLeft, mKeysRight, mKeysUp, mLastTime, mMovementSpeed, mPosition, mXDegrees, mYDegrees, vl::Vector3< T_Scalar >::normalize(), vl::UIEventListener::openglContext(), vl::Camera::setInverseViewMatrix(), 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.

References camera(), and mCamera.

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.

void vl::GhostCameraManipulator::setKeysForward | ( | EKey | key,
|  | EKey | modifier = `Key_None`
| ) |  | `[inline]`

Key bindings to move forward (default = Key_W).

Definition at line 107 of file GhostCameraManipulator.hpp.

Referenced by GhostCameraManipulator().

void vl::GhostCameraManipulator::setKeysBackward | ( | EKey | key,
|  | EKey | modifier = `Key_None`
| ) |  | `[inline]`

Key bindings to move backward (default = Key_S).

Definition at line 110 of file GhostCameraManipulator.hpp.

Referenced by GhostCameraManipulator().

void vl::GhostCameraManipulator::setKeysLeft | ( | EKey | key,
|  | EKey | modifier = `Key_None`
| ) |  | `[inline]`

Key bindings to move left (default = Key_A).

Definition at line 113 of file GhostCameraManipulator.hpp.

Referenced by GhostCameraManipulator().

void vl::GhostCameraManipulator::setKeysRight | ( | EKey | key,
|  | EKey | modifier = `Key_None`
| ) |  | `[inline]`

Key bindings to move right (default = Key_D).

Definition at line 116 of file GhostCameraManipulator.hpp.

Referenced by GhostCameraManipulator().

void vl::GhostCameraManipulator::setKeysUp | ( | EKey | key,
|  | EKey | modifier = `Key_None`
| ) |  | `[inline]`

Key bindings to move up (default = Key_W + Key_Shift).

Definition at line 119 of file GhostCameraManipulator.hpp.

Referenced by GhostCameraManipulator().

void vl::GhostCameraManipulator::setKeysDown | ( | EKey | key,
|  | EKey | modifier = `Key_None`
| ) |  | `[inline]`

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.

## Member Data Documentation

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().

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

- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/GhostCameraManipulator.hpp
- D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/GhostCameraManipulator.cpp

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:41.
Permission is granted to use this page to write and publish articles regarding Visualization Library.