An EventHandler to control a TerrainViewController and a light source with the mouse and/or the keyboard. More...
#include <BasicViewHandler.h>
Classes | |
struct | Position |
A TerrainViewController position and a light source position. More... | |
Public Member Functions | |
BasicViewHandler (bool smooth, ViewManager *view, ptr< EventHandler > next) | |
Creates a new BasicViewHandler. | |
virtual | ~BasicViewHandler () |
Deletes this BasicViewHandler. | |
void | getPosition (Position &p, bool light=true) |
Returns the current view and light positions. | |
void | setPosition (const Position &p, bool light=true) |
Sets the current view and light position. | |
virtual void | goToPosition (const Position &p) |
Starts an animation to go smoothly from the current position to the given position. | |
void | jumpToPosition (const Position &p) |
Goes immediately to the given position. | |
Protected Member Functions | |
BasicViewHandler () | |
Creates an uninitialized BasicViewHandler. | |
void | init (bool smooth, ViewManager *view, ptr< EventHandler > next) |
Initializes this BasicViewHandler. | |
virtual ViewManager * | getViewManager () |
Returns the ViewManager used by this BasicViewHandler to find the TerrainViewController, to find the light SceneNode, and to convert between screen and world coordinates. | |
virtual void | updateView (double t, double dt) |
Updates the view for the current frame based on user inputs. | |
Protected Attributes | |
ViewManager * | viewManager |
The ViewManager to find the TerrainViewController, to find the light SceneNode, and to convert between screen and world coordinates. | |
Private Types | |
enum | userMode { move, rotate, light } |
A navigation mode. More... | |
Private Attributes | |
ptr< EventHandler > | next |
The EventHandler to which the events not handled by this EventHandler must be forwarded. | |
bool | smooth |
True to use exponential damping to go to target positions, false to go to target positions directly. | |
bool | near |
True if the PAGE_DOWN key is currently pressed. | |
bool | far |
True if the PAGE_UP key is currently pressed. | |
bool | forward |
True if the UP key is currently pressed. | |
bool | backward |
True if the DOWN key is currently pressed. | |
bool | left |
True if the LEFT key is currently pressed. | |
bool | right |
True if the RIGHT key is currently pressed. | |
userMode | mode |
The current navigation mode. | |
int | oldx |
The mouse x coordinate at the last call to mouseClick or mouseMotion. | |
int | oldy |
The mouse x coordinate at the last call to mouseClick or mouseMotion. | |
Position | target |
The target position manipulated by the user via the mouse and keyboard. | |
bool | initialized |
True if the target position target is initialized. | |
Position | start |
Start position for an animation between two positions. | |
Position | end |
End position for an animation between two positions. | |
double | animation |
Animation status. |
An EventHandler to control a TerrainViewController and a light source with the mouse and/or the keyboard.
This EventHandler relies on a ViewManager to find the TerrainViewController, to find the light SceneNode (using a SceneManager), and to convert between screen and world coordinates. This implementation allows the user to move the view and the light with the mouse and the PAGE_UP and PAGE_DOWN keys. It also provides methods to instantly change the view and light positions, and to start an animation to go smoothly from one position to another.
enum proland::BasicViewHandler::userMode [private] |
proland::BasicViewHandler::BasicViewHandler | ( | bool | smooth, | |
ViewManager * | view, | |||
ptr< EventHandler > | next | |||
) |
Creates a new BasicViewHandler.
smooth | true to use exponential damping to go to target positions, false to go to target positions directly. | |
view | the object used to access the view controller. | |
next | the EventHandler to which the events not handled by this EventHandler must be forwarded. |
virtual proland::BasicViewHandler::~BasicViewHandler | ( | ) | [virtual] |
Deletes this BasicViewHandler.
proland::BasicViewHandler::BasicViewHandler | ( | ) | [protected] |
Creates an uninitialized BasicViewHandler.
void proland::BasicViewHandler::getPosition | ( | Position & | p, | |
bool | light = true | |||
) |
Returns the current view and light positions.
[out] | p | the current view and light position. |
virtual ViewManager* proland::BasicViewHandler::getViewManager | ( | ) | [protected, virtual] |
Returns the ViewManager used by this BasicViewHandler to find the TerrainViewController, to find the light SceneNode, and to convert between screen and world coordinates.
virtual void proland::BasicViewHandler::goToPosition | ( | const Position & | p | ) | [virtual] |
Starts an animation to go smoothly from the current position to the given position.
p | the target position. |
void proland::BasicViewHandler::init | ( | bool | smooth, | |
ViewManager * | view, | |||
ptr< EventHandler > | next | |||
) | [protected] |
Initializes this BasicViewHandler.
See BasicViewHandler.
void proland::BasicViewHandler::jumpToPosition | ( | const Position & | p | ) |
Goes immediately to the given position.
p | the new view and light position. |
void proland::BasicViewHandler::setPosition | ( | const Position & | p, | |
bool | light = true | |||
) |
Sets the current view and light position.
p | the new view and light position. |
virtual void proland::BasicViewHandler::updateView | ( | double | t, | |
double | dt | |||
) | [protected, virtual] |
Updates the view for the current frame based on user inputs.
double proland::BasicViewHandler::animation [private] |
Animation status.
Negative values mean no animation. 0 corresponds to the start position, 1 to the end position, and values between 0 and 1 to intermediate positions between the start and end positions.
bool proland::BasicViewHandler::backward [private] |
True if the DOWN key is currently pressed.
Position proland::BasicViewHandler::end [private] |
End position for an animation between two positions.
bool proland::BasicViewHandler::far [private] |
True if the PAGE_UP key is currently pressed.
bool proland::BasicViewHandler::forward [private] |
True if the UP key is currently pressed.
bool proland::BasicViewHandler::initialized [private] |
True if the target position target is initialized.
bool proland::BasicViewHandler::left [private] |
True if the LEFT key is currently pressed.
userMode proland::BasicViewHandler::mode [private] |
The current navigation mode.
bool proland::BasicViewHandler::near [private] |
True if the PAGE_DOWN key is currently pressed.
ptr<EventHandler> proland::BasicViewHandler::next [private] |
The EventHandler to which the events not handled by this EventHandler must be forwarded.
int proland::BasicViewHandler::oldx [private] |
The mouse x coordinate at the last call to mouseClick or mouseMotion.
int proland::BasicViewHandler::oldy [private] |
The mouse x coordinate at the last call to mouseClick or mouseMotion.
bool proland::BasicViewHandler::right [private] |
True if the RIGHT key is currently pressed.
bool proland::BasicViewHandler::smooth [private] |
True to use exponential damping to go to target positions, false to go to target positions directly.
Position proland::BasicViewHandler::start [private] |
Start position for an animation between two positions.
Position proland::BasicViewHandler::target [private] |
The target position manipulated by the user via the mouse and keyboard.
ViewManager* proland::BasicViewHandler::viewManager [protected] |
The ViewManager to find the TerrainViewController, to find the light SceneNode, and to convert between screen and world coordinates.