An EventHandler that can determine the position of the mouse in world space. More...
#include <MousePositionHandler.h>
Public Member Functions | |
MousePositionHandler (map< ptr< SceneNode >, ptr< TerrainNode > > terrains, ptr< EventHandler > next) | |
Creates a new MousePositionhandler. | |
virtual | ~MousePositionHandler () |
Deletes this MousePositionHandler. | |
ptr< TerrainQuad > | findTile (float x, float y, ptr< TerrainQuad > quad) |
Finds the TerrainQuad that contains the given coordinates. | |
void | getWorldCoordinates (int x, int y) |
Determines the terrain and the terrain tile that contains the given coordinates. | |
Protected Member Functions | |
MousePositionHandler () | |
Creates a new MousePositionHandler. | |
void | init (map< ptr< SceneNode >, ptr< TerrainNode > > terrains, ptr< EventHandler > next) |
Initializes this MousePositionHandler. | |
Protected Attributes | |
map< ptr< SceneNode >, ptr < TerrainNode > > | terrains |
The list of SceneNodes contained in the scene mapped to their TerrainNodes. | |
Private Attributes | |
vec2i | mousePosition |
Displayed mouse position. | |
int | currentTerrain |
The terrain pointed by the cursor. | |
vec3d | terrainPosition |
Local position inside the terrain pointer by the cursor. | |
vec3i | tile |
Coordinates of the tile (level, tx, ty) pointed inside the terrain. | |
ptr< EventHandler > | next |
The EventHandler that must handle the events. |
An EventHandler that can determine the position of the mouse in world space.
It can determine on which TerrainNode the cursor is, and the position inside it. This EventHandler is only for debug purpose, since it requires costly operations. (DepthBuffer read...). It then uses the ShowInfoTask to display the mouse position.
proland::MousePositionHandler::MousePositionHandler | ( | map< ptr< SceneNode >, ptr< TerrainNode > > | terrains, | |
ptr< EventHandler > | next | |||
) |
Creates a new MousePositionhandler.
terrains | the list of SceneNodes contained in the scene mapped to their TerrainNodes. These SceneNodes are used to determine the transformation matrices, and the TerrainNodes are used to determine if the point is inside the terrain. | |
next | the EventHandler that must handle the events. |
virtual proland::MousePositionHandler::~MousePositionHandler | ( | ) | [virtual] |
Deletes this MousePositionHandler.
proland::MousePositionHandler::MousePositionHandler | ( | ) | [protected] |
Creates a new MousePositionHandler.
ptr<TerrainQuad> proland::MousePositionHandler::findTile | ( | float | x, | |
float | y, | |||
ptr< TerrainQuad > | quad | |||
) |
Finds the TerrainQuad that contains the given coordinates.
void proland::MousePositionHandler::getWorldCoordinates | ( | int | x, | |
int | y | |||
) |
Determines the terrain and the terrain tile that contains the given coordinates.
It will set mousePosition, currentTerrain, terrainPosition, and tile.
void proland::MousePositionHandler::init | ( | map< ptr< SceneNode >, ptr< TerrainNode > > | terrains, | |
ptr< EventHandler > | next | |||
) | [protected] |
Initializes this MousePositionHandler.
See MousePositionHandler.
int proland::MousePositionHandler::currentTerrain [private] |
The terrain pointed by the cursor.
If no terrain is under the cursor, it will be set to -1 and no terrain coordinates will be displayed, only mouse coordinates.
vec2i proland::MousePositionHandler::mousePosition [private] |
Displayed mouse position.
Retrieved when the mouse moves.
ptr<EventHandler> proland::MousePositionHandler::next [private] |
The EventHandler that must handle the events.
vec3d proland::MousePositionHandler::terrainPosition [private] |
Local position inside the terrain pointer by the cursor.
map<ptr<SceneNode>, ptr<TerrainNode> > proland::MousePositionHandler::terrains [protected] |
The list of SceneNodes contained in the scene mapped to their TerrainNodes.
These SceneNodes are used to determine the transformation matrices, and the TerrainNodes are used to determine if the point is inside the terrain.
vec3i proland::MousePositionHandler::tile [private] |
Coordinates of the tile (level, tx, ty) pointed inside the terrain.