random_racer::LoaderGlue Class Reference

This is the glue class between TerrainLoader and ReloadPlane. More...

#include <LoaderGlue.h>

Inheritance diagram for random_racer::LoaderGlue:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 LoaderGlue (VRS::SO< vrsode::CollisionBody > collisionBody, VRS::SO< TerrainLoader > loader, float boxSize, float centerDiff, VRS::Vector position=VRS::Vector(0, 0, 0), VRS::SO< ItemDistributor > itemDistributor=NULL)
 Ctor.
virtual ~LoaderGlue ()
 Dtor.
void collisionCallback (unsigned int planeId)
 Gets called if a new collsion happens, this relocates the planes around a calculated new center point and calls replaceTerrain() of the TerrainLoader.
void registerPlanes (VRS::SO< ReloadPlane > *planeArray)
 Attaches the LoaderGlue to the 4 given ReloadPlanes, sets their normals according to their position in the array and then moves them to their initial position around the car.
VRS::SO< VRS::Callback1< unsigned
int > > 
getCallback ()
 Returns the callback object which should get connected to the ReloadPlanes.
void checkForCollisions ()
 Checks all 4 planes if one of them collided.

Private Member Functions

void relocatePlanesAround (double x, double y)
 Moves the 4 ReloadPlanes to a new position so that the Car again is in the center of a box.

Private Attributes

VRS::SO< VRS::Callback1< unsigned
int > > 
m_callback
VRS::Vector m_position
VRS::SO< ReloadPlanem_planes [4]
VRS::SO< vrsode::CollisionBodym_carBody
VRS::SO< TerrainLoaderm_loader
VRS::SO< ItemDistributorm_itemDistributor
float m_halfBoxSize
float m_centerDiff

Classes

struct  Point
 Just used internaly for calculating the nearest center points. More...

Detailed Description

This is the glue class between TerrainLoader and ReloadPlane.

Definition at line 24 of file LoaderGlue.h.


Constructor & Destructor Documentation

random_racer::LoaderGlue::LoaderGlue ( VRS::SO< vrsode::CollisionBody collisionBody,
VRS::SO< TerrainLoader loader,
float  boxSize,
float  centerDiff,
VRS::Vector  position = VRS::Vector(0, 0, 0),
VRS::SO< ItemDistributor itemDistributor = NULL 
)

Ctor.

Parameters:
collisionBody This 'is' the Car and we use its poistion to see where the car currently is at to calculate the new planes.
loader The TerrainLoader we tell to replaceTerrain() every time collisionCallback() is called after relocating the planes.
boxSize How big the effective box is which the 4 ReloadPlanes build.
centerDiff How far away the center points the of the 8 possible next plane locations are from the current center point, setting this to values which are bigger than boxSize / 2.0 makes reloading more efficient because it does happen less often.
position Is currently semi-unused.
itemDistributor this object distributes collectable items in in our world.

random_racer::LoaderGlue::~LoaderGlue (  )  [virtual]

Dtor.

Definition at line 43 of file LoaderGlue.cpp.


Member Function Documentation

void random_racer::LoaderGlue::relocatePlanesAround ( double  x,
double  y 
) [private]

Moves the 4 ReloadPlanes to a new position so that the Car again is in the center of a box.

Definition at line 142 of file LoaderGlue.cpp.

References m_halfBoxSize, and m_planes.

Referenced by collisionCallback().

Here is the caller graph for this function:

void random_racer::LoaderGlue::collisionCallback ( unsigned int  planeId  ) 

Gets called if a new collsion happens, this relocates the planes around a calculated new center point and calls replaceTerrain() of the TerrainLoader.

Definition at line 48 of file LoaderGlue.cpp.

References m_carBody, m_centerDiff, m_itemDistributor, m_loader, m_position, random_racer::TerrainLoader::nearestIndex(), relocatePlanesAround(), random_racer::LoaderGlue::Point::x, and random_racer::LoaderGlue::Point::y.

Here is the call graph for this function:

void random_racer::LoaderGlue::registerPlanes ( VRS::SO< ReloadPlane > *  planeArray  ) 

Attaches the LoaderGlue to the 4 given ReloadPlanes, sets their normals according to their position in the array and then moves them to their initial position around the car.

Parameters:
planeArray A C-Array containing 4 SOs of ReloadPlanes.

VRS::SO<VRS::Callback1<unsigned int> > random_racer::LoaderGlue::getCallback (  )  [inline]

Returns the callback object which should get connected to the ReloadPlanes.

Note:
The "get" is just there to prevent confusions and you don't think this actually calls a callback.

Definition at line 107 of file LoaderGlue.h.

References m_callback.

void random_racer::LoaderGlue::checkForCollisions (  ) 

Checks all 4 planes if one of them collided.

Definition at line 153 of file LoaderGlue.cpp.

References m_planes.


Member Data Documentation

VRS::SO<VRS::Callback1<unsigned int> > random_racer::LoaderGlue::m_callback [private]

Definition at line 35 of file LoaderGlue.h.

Referenced by getCallback().

VRS::Vector random_racer::LoaderGlue::m_position [private]

Definition at line 36 of file LoaderGlue.h.

Referenced by collisionCallback().

VRS::SO<ReloadPlane> random_racer::LoaderGlue::m_planes[4] [private]

Definition at line 37 of file LoaderGlue.h.

Referenced by checkForCollisions(), and relocatePlanesAround().

VRS::SO<vrsode::CollisionBody> random_racer::LoaderGlue::m_carBody [private]

Definition at line 38 of file LoaderGlue.h.

Referenced by collisionCallback().

VRS::SO<TerrainLoader> random_racer::LoaderGlue::m_loader [private]

Definition at line 39 of file LoaderGlue.h.

Referenced by collisionCallback().

VRS::SO<ItemDistributor> random_racer::LoaderGlue::m_itemDistributor [private]

Definition at line 40 of file LoaderGlue.h.

Referenced by collisionCallback().

float random_racer::LoaderGlue::m_halfBoxSize [private]

Definition at line 41 of file LoaderGlue.h.

Referenced by relocatePlanesAround().

float random_racer::LoaderGlue::m_centerDiff [private]

Definition at line 41 of file LoaderGlue.h.

Referenced by collisionCallback().


The documentation for this class was generated from the following files:
Generated on Fri May 11 21:02:08 2007 for Random Racer by  doxygen 1.5.1