proland::BasicViewHandler Class Reference
[ui]

An EventHandler to control a TerrainViewController and a light source with the mouse and/or the keyboard. More...

#include <BasicViewHandler.h>

List of all members.

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

ViewManagerviewManager
 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.

Detailed Description

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.


Member Enumeration Documentation

A navigation mode.

Enumerator:
move 

moves the "look-at" point.

rotate 

rotates around the "look-at" point

light 

moves the light.


Constructor & Destructor Documentation

proland::BasicViewHandler::BasicViewHandler ( bool  smooth,
ViewManager view,
ptr< EventHandler >  next 
)

Creates a new BasicViewHandler.

Parameters:
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.


Member Function Documentation

void proland::BasicViewHandler::getPosition ( Position p,
bool  light = true 
)

Returns the current view and light positions.

Parameters:
[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.

Parameters:
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.

Parameters:
p the new view and light position.
void proland::BasicViewHandler::setPosition ( const Position p,
bool  light = true 
)

Sets the current view and light position.

Parameters:
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.


Member Data Documentation

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.

True if the DOWN key is currently pressed.

End position for an animation between two positions.

True if the PAGE_UP key is currently pressed.

True if the UP key is currently pressed.

True if the target position target is initialized.

True if the LEFT key is currently pressed.

The current navigation mode.

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.

The mouse x coordinate at the last call to mouseClick or mouseMotion.

The mouse x coordinate at the last call to mouseClick or mouseMotion.

True if the RIGHT key is currently pressed.

True to use exponential damping to go to target positions, false to go to target positions directly.

Start position for an animation between two positions.

The target position manipulated by the user via the mouse and keyboard.

The ViewManager to find the TerrainViewController, to find the light SceneNode, and to convert between screen and world coordinates.


Generated on Sat May 12 09:41:39 2012 for proland by  doxygen 1.6.1