random_racer::VRSTerrainLoader Class Reference

This is a special TerrainLoader for VRS which creates a Mesh containing the generated Terrain and attaches this to a SceneThing. More...

#include <VRSTerrainLoader.h>

Inheritance diagram for random_racer::VRSTerrainLoader:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 VRSTerrainLoader (VRS::SO< VRS::SceneThing > thing, VRS::SO< ControlPointContainer > container, double boxSize, double viewSize)
 Ctor, for the other params see TerrainLoader::TerrainLoader().
virtual ~VRSTerrainLoader ()
 Dtor, clears m_thing and terminate()s the worker thread.
virtual void replaceTerrain (const VRS::Vector &position, const VRS::Vector &center)
 Fetches the best matching terrain from m_terrainCache, generates, normals, etc, updates the tranlation and updates the meshs vertices with those from the cache.
void beautifyMesh ()
 Recalculates normals, colors and texture coordinates for m_mesh and calls our MeshBeautifier to do its job.
VRS::SO< VRS::Mesh > mesh ()
 returns the contained mesh
VRS::Vector heightAt (double, double)
 returns a vector with the height of the terrain filled into y at a certain x z position.
void terminate ()
 Terminates the worker thread after letting him finish his work.

Private Member Functions

int generate ()
 This is the real method which represents the background- process of this class, returns 1 on success and 0 on error.

Static Private Member Functions

static int workerWrapper (void *self)
 The function which is run by the worker thread.

Private Attributes

SDL_Thread * m_worker
SDL_mutex * m_controlMutex
SDL_mutex * m_generateWakeMutex
SDL_mutex * m_vertexMutex
SDL_cond * m_replaceWakeCond
SDL_cond * m_generateWakeCond
int m_signalWhenDoneWith
bool m_workerIsWaiting
bool m_terminateWorker
VRS::SO< TerrainGeneratorm_generator
 Our TerrainGenerator which is used for generating terrains.
TerrainPart m_terrainCache [4]
VRS::SO< VRS::Translation > m_translation
VRS::SO< VRS::Mesh > m_mesh
VRS::SO< VRS::DataIterator<
VRS::Vector > > 
m_vertexIter
VRS::SO< VRS::DataIterator<
VRS::Vector > > 
m_textureIter
VRS::SO< VRS::DataIterator<
VRS::Color > > 
m_colorIter
VRS::SO< MeshBeautifierm_beautifier

Friends

class ODETerrainLoader

Classes

struct  TerrainPart
 Used for storing the 4 most recent TerrainParts. More...

Detailed Description

This is a special TerrainLoader for VRS which creates a Mesh containing the generated Terrain and attaches this to a SceneThing.

The VRSTerrainLoader also encapsulates a worker thread wich uses a TerrainGenerator to generate terrain with the use of the Nurbs.

Definition at line 37 of file VRSTerrainLoader.h.


Constructor & Destructor Documentation

random_racer::VRSTerrainLoader::VRSTerrainLoader ( VRS::SO< VRS::SceneThing >  thing,
VRS::SO< ControlPointContainer container,
double  boxSize,
double  viewSize 
)

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

Parameters:
thing The SceneThing into which we will load our generated Terrain and the Translation Matrix, so it should be emtpy and not used by somebody else.
container The ControlPointContainer which we will pass to the TerrainGenerator for generating terrain.

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

Dtor, clears m_thing and terminate()s the worker thread.

Definition at line 439 of file VRSTerrainLoader.cpp.

References random_racer::TerrainLoader::m_thing.


Member Function Documentation

int random_racer::VRSTerrainLoader::workerWrapper ( void *  self  )  [static, private]

The function which is run by the worker thread.

After being started, this wraps generate() to give the method a this.

Parameters:
self This gets casted to TerrainLoader* and is interpreted as "this" for the thread worker.

Definition at line 248 of file VRSTerrainLoader.cpp.

int random_racer::VRSTerrainLoader::generate (  )  [private]

This is the real method which represents the background- process of this class, returns 1 on success and 0 on error.

Definition at line 254 of file VRSTerrainLoader.cpp.

References random_racer::TerrainLoader::m_boxSize, m_controlMutex, m_generateWakeCond, m_generateWakeMutex, random_racer::TerrainLoader::m_position, m_replaceWakeCond, m_signalWhenDoneWith, m_terminateWorker, and m_workerIsWaiting.

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

Fetches the best matching terrain from m_terrainCache, generates, normals, etc, updates the tranlation and updates the meshs vertices with those from the cache.

See TerrainLoader::replaceTerrain() for the params.

Implements random_racer::TerrainLoader.

void random_racer::VRSTerrainLoader::beautifyMesh (  ) 

Recalculates normals, colors and texture coordinates for m_mesh and calls our MeshBeautifier to do its job.

Definition at line 446 of file VRSTerrainLoader.cpp.

References m_beautifier, m_translation, and m_vertexIter.

Referenced by random_racer::MeshBeautifier::terLoadTextureCommand().

Here is the caller graph for this function:

VRS::SO< VRS::Mesh > random_racer::VRSTerrainLoader::mesh (  ) 

returns the contained mesh

Definition at line 499 of file VRSTerrainLoader.cpp.

VRS::Vector random_racer::VRSTerrainLoader::heightAt ( double  ,
double   
)

returns a vector with the height of the terrain filled into y at a certain x z position.

Definition at line 505 of file VRSTerrainLoader.cpp.

References m_translation, and m_vertexIter.

void random_racer::VRSTerrainLoader::terminate (  ) 

Terminates the worker thread after letting him finish his work.

Definition at line 462 of file VRSTerrainLoader.cpp.

References m_controlMutex, m_generateWakeCond, m_generateWakeMutex, m_terminateWorker, m_worker, and m_workerIsWaiting.


Friends And Related Function Documentation

friend class ODETerrainLoader [friend]

Definition at line 40 of file VRSTerrainLoader.h.


Member Data Documentation

SDL_Thread* random_racer::VRSTerrainLoader::m_worker [private]

Definition at line 43 of file VRSTerrainLoader.h.

Referenced by terminate().

SDL_mutex* random_racer::VRSTerrainLoader::m_controlMutex [private]

Definition at line 45 of file VRSTerrainLoader.h.

Referenced by generate(), and terminate().

SDL_mutex* random_racer::VRSTerrainLoader::m_generateWakeMutex [private]

Definition at line 46 of file VRSTerrainLoader.h.

Referenced by generate(), and terminate().

SDL_mutex* random_racer::VRSTerrainLoader::m_vertexMutex [private]

Definition at line 47 of file VRSTerrainLoader.h.

SDL_cond* random_racer::VRSTerrainLoader::m_replaceWakeCond [private]

Definition at line 49 of file VRSTerrainLoader.h.

Referenced by generate().

SDL_cond* random_racer::VRSTerrainLoader::m_generateWakeCond [private]

Definition at line 50 of file VRSTerrainLoader.h.

Referenced by generate(), and terminate().

int random_racer::VRSTerrainLoader::m_signalWhenDoneWith [private]

Definition at line 52 of file VRSTerrainLoader.h.

Referenced by generate().

bool random_racer::VRSTerrainLoader::m_workerIsWaiting [private]

Definition at line 53 of file VRSTerrainLoader.h.

Referenced by generate(), and terminate().

bool random_racer::VRSTerrainLoader::m_terminateWorker [private]

Definition at line 55 of file VRSTerrainLoader.h.

Referenced by generate(), and terminate().

VRS::SO<TerrainGenerator> random_racer::VRSTerrainLoader::m_generator [private]

Our TerrainGenerator which is used for generating terrains.

Definition at line 60 of file VRSTerrainLoader.h.

TerrainPart random_racer::VRSTerrainLoader::m_terrainCache[4] [private]

Definition at line 84 of file VRSTerrainLoader.h.

VRS::SO<VRS::Translation> random_racer::VRSTerrainLoader::m_translation [private]

Definition at line 86 of file VRSTerrainLoader.h.

Referenced by beautifyMesh(), and heightAt().

VRS::SO<VRS::Mesh> random_racer::VRSTerrainLoader::m_mesh [private]

Definition at line 87 of file VRSTerrainLoader.h.

VRS::SO<VRS::DataIterator<VRS::Vector> > random_racer::VRSTerrainLoader::m_vertexIter [private]

Definition at line 88 of file VRSTerrainLoader.h.

Referenced by beautifyMesh(), and heightAt().

VRS::SO<VRS::DataIterator<VRS::Vector> > random_racer::VRSTerrainLoader::m_textureIter [private]

Definition at line 88 of file VRSTerrainLoader.h.

VRS::SO<VRS::DataIterator<VRS::Color> > random_racer::VRSTerrainLoader::m_colorIter [private]

Definition at line 89 of file VRSTerrainLoader.h.

VRS::SO<MeshBeautifier> random_racer::VRSTerrainLoader::m_beautifier [private]

Definition at line 91 of file VRSTerrainLoader.h.

Referenced by beautifyMesh().


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