random_racer::ODETerrainLoader Class Reference

This TerrainLoader is for ODE (vrsode) and manipulates a TrimeshShape so that ODE always has the right CollisionBody for the Terrain. More...

#include <ODETerrainLoader.h>

Inheritance diagram for random_racer::ODETerrainLoader:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 ODETerrainLoader (VRS::SO< VRS::SceneThing > thing, VRS::SO< VRSTerrainLoader > vrsLoader, double boxSize, double viewSize)
 Ctor, for the other params see TerrainLoader::TerrainLoader().
virtual ~ODETerrainLoader ()
 Dtor, clears m_thing.
virtual void replaceTerrain (const VRS::Vector &position, const VRS::Vector &center)
 Triggeres the replace for the ODE collision body under the car.
void setDebug (bool debug=true)
 Enables debug mode for the terrain or disables it.

Private Member Functions

void grabVertices (const VRS::Vector &position, std::vector< VRS::Vector > *target)
 Extracts the for the current position important vertices from the VRSTerrainLoaders mesh and stores them in target.
void doubleVertices (std::vector< VRS::Vector > &source, std::vector< VRS::Vector > &target, unsigned int sourceLod, unsigned int targetLod)
 Writes the double amount of vertices from source to target to produce a more fine grained mesh, we do this several times to get a extreme fine mesh for ode.
VRS::Vector interpolate (const VRS::Vector &a, const VRS::Vector &b)
 Just interpolates this 2 vectors and returns the average one.
unsigned int indexForTarget (unsigned int x, unsigned int y, unsigned int lod, unsigned int newLod, unsigned int offsetX, unsigned int offsetY)
 Used internally in doubleVertices() for generating the indezes in the target array.
template<class INDEX_ARRAY>
void fillIndexArray (unsigned int lod, INDEX_ARRAY *target)
 Fills a index array in a vrsode::TriangleData with indizes which are suitable for a vertex array which is generated by the Nurbs or which was produces by cutting it out of such one.
template<class ITER, class FLOAT_ARRAY>
void convertVertices (const ITER &begin, const ITER &end, FLOAT_ARRAY *target)
 Converts VRS::Vectors into plain old floats or something like that so we can give it to the Trimesh API.

Private Attributes

VRS::SO< vrsode::CollisionBodym_trimeshBody
VRS::SO< vrsode::TriangleDatam_triangleData
VRS::SO< VRSTerrainLoaderm_vrsLoader
 A SO to the VRSTerrainLoader so we can directly access its vertex array for the mesh access.

Detailed Description

This TerrainLoader is for ODE (vrsode) and manipulates a TrimeshShape so that ODE always has the right CollisionBody for the Terrain.

Definition at line 25 of file ODETerrainLoader.h.


Constructor & Destructor Documentation

random_racer::ODETerrainLoader::ODETerrainLoader ( VRS::SO< VRS::SceneThing >  thing,
VRS::SO< VRSTerrainLoader vrsLoader,
double  boxSize,
double  viewSize 
)

Ctor, for the other params see TerrainLoader::TerrainLoader().

Parameters:
thing The SceneThing into which our CollisionBody will be hanged, so it should not be used for something else.
vrsLoader The VRSTerrainLoader will be used to extract points from its mesh so we can generate a fine ODE Terrain.

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

Dtor, clears m_thing.

Definition at line 85 of file ODETerrainLoader.cpp.

References random_racer::TerrainLoader::m_thing.


Member Function Documentation

void random_racer::ODETerrainLoader::grabVertices ( const VRS::Vector &  position,
std::vector< VRS::Vector > *  target 
) [private]

Extracts the for the current position important vertices from the VRSTerrainLoaders mesh and stores them in target.

Definition at line 91 of file ODETerrainLoader.cpp.

References random_racer::TerrainLoader::m_viewSize, and m_vrsLoader.

Referenced by replaceTerrain().

Here is the caller graph for this function:

void random_racer::ODETerrainLoader::doubleVertices ( std::vector< VRS::Vector > &  source,
std::vector< VRS::Vector > &  target,
unsigned int  sourceLod,
unsigned int  targetLod 
) [private]

Writes the double amount of vertices from source to target to produce a more fine grained mesh, we do this several times to get a extreme fine mesh for ode.

Definition at line 182 of file ODETerrainLoader.cpp.

References indexForTarget(), and interpolate().

Referenced by replaceTerrain().

Here is the call graph for this function:

Here is the caller graph for this function:

VRS::Vector random_racer::ODETerrainLoader::interpolate ( const VRS::Vector &  a,
const VRS::Vector &  b 
) [private]

Just interpolates this 2 vectors and returns the average one.

Definition at line 156 of file ODETerrainLoader.cpp.

Referenced by doubleVertices().

Here is the caller graph for this function:

unsigned int random_racer::ODETerrainLoader::indexForTarget ( unsigned int  x,
unsigned int  y,
unsigned int  lod,
unsigned int  newLod,
unsigned int  offsetX,
unsigned int  offsetY 
) [private]

Used internally in doubleVertices() for generating the indezes in the target array.

Definition at line 164 of file ODETerrainLoader.cpp.

Referenced by doubleVertices().

Here is the caller graph for this function:

template<class INDEX_ARRAY>
void random_racer::ODETerrainLoader::fillIndexArray ( unsigned int  lod,
INDEX_ARRAY *  target 
) [private]

Fills a index array in a vrsode::TriangleData with indizes which are suitable for a vertex array which is generated by the Nurbs or which was produces by cutting it out of such one.

template<class ITER, class FLOAT_ARRAY>
void random_racer::ODETerrainLoader::convertVertices ( const ITER &  begin,
const ITER &  end,
FLOAT_ARRAY *  target 
) [private]

Converts VRS::Vectors into plain old floats or something like that so we can give it to the Trimesh API.

Referenced by replaceTerrain().

Here is the caller graph for this function:

void random_racer::ODETerrainLoader::replaceTerrain ( const VRS::Vector &  position,
const VRS::Vector &  center 
) [virtual]

Triggeres the replace for the ODE collision body under the car.

See TerrainLoader::replaceTerrain() for the params.

Implements random_racer::TerrainLoader.

Definition at line 232 of file ODETerrainLoader.cpp.

References convertVertices(), doubleVertices(), grabVertices(), m_triangleData, m_trimeshBody, and m_vrsLoader.

Here is the call graph for this function:

void random_racer::ODETerrainLoader::setDebug ( bool  debug = true  )  [inline]

Enables debug mode for the terrain or disables it.

Definition at line 120 of file ODETerrainLoader.h.

References m_trimeshBody.


Member Data Documentation

VRS::SO<vrsode::CollisionBody> random_racer::ODETerrainLoader::m_trimeshBody [private]

Definition at line 27 of file ODETerrainLoader.h.

Referenced by replaceTerrain(), and setDebug().

VRS::SO<vrsode::TriangleData> random_racer::ODETerrainLoader::m_triangleData [private]

Definition at line 28 of file ODETerrainLoader.h.

Referenced by replaceTerrain().

VRS::SO<VRSTerrainLoader> random_racer::ODETerrainLoader::m_vrsLoader [private]

A SO to the VRSTerrainLoader so we can directly access its vertex array for the mesh access.

Definition at line 34 of file ODETerrainLoader.h.

Referenced by grabVertices(), and replaceTerrain().


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