random_racer::ControlPointContainer Class Reference

This Class is a structure to hold the whole ControlPoints for our terrain. More...

#include <ControlPointContainer.h>

Inheritance diagram for random_racer::ControlPointContainer:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 ControlPointContainer (unsigned int numControlPoints, unsigned int blocksize, VRS::SO< VRS::Callback1< std::vector< VRS::Vector > * > > genPointCallback, int minY, int maxY)
 For the Callback Parameters looks at the ControlPointGenerator.h.
virtual ~ControlPointContainer ()
template<class T>
void getPoints (double valueX, double valueZ, T *target)
 This function writes all ControlPoints of the four bordering Blocks to the target.
template<class T>
void getPoints (double beginX, double beginZ, double endX, double endZ, T *target)
 This function writes the ControlPoints stored in the Hashmap to the target or generate them if they are not existing.
int minHeight ()
int maxHeight ()

Private Types

typedef __gnu_cxx::hash_map<
int, std::vector< unsigned
char > * > 
InnerHashMap
 This our 2-Dim.
typedef __gnu_cxx::hash_map<
int, InnerHashMap * > 
HashMap

Private Member Functions

int mapToKey (double value)
 Maps a given value to a key, depending on the blocksize.
int getOffset (int key)
 Returns the Offset for the absolute coordinates, depending on the given Block Key, the Blocksize and Number of ControlPoints.
unsigned char mapToHashMapHeight (double height)
 Maps the Height-Value to 0 - 254 (the height from the generator is between 0 -1).
double mapHeightBack (unsigned char height)
 Maps form 0 - 254 to original Height.
unsigned int calculateAbsHeight (int minHeight, int maxHeight)
 Calculate the right absolute Height depending on the domain.
void getFourBlocks (double valueX, double valueZ, int *blockList)
 Calculates the right four blocks, which lays around the point and stores the X and Z Key for four Blocks.
void generateBlock (int valueX, int valueZ)
 Generates the block in the hashmap.
unsigned int mapsIndex (double valueX, double valueZ)
unsigned int mapsIndexBackToX (unsigned int index)
unsigned int mapsIndexBackToZ (unsigned int p_index, unsigned int p_valueX)

Private Attributes

HashMap m_hashMap
unsigned int m_numControlPoints
 m_Blocksize is the (absolute) Dimension of the Block.
unsigned int m_blocksize
int m_minY
 Stores the Domain of the Height.
int m_maxY
unsigned int m_absHeight
 Stores the absolute Domain of the Height.
bool m_calcMinus
 indicates if we have to substract (true) in the mapHeightBack function or to add
int m_blockList [8]
 Stores the X and Z Key for four Blocks.
VRS::SO< VRS::Callback1< std::vector<
VRS::Vector > * > > 
m_callback
 Callback to generate random control points The parameter specifies the target where we store the generated values.
std::vector< VRS::Vector > m_genPointCache
 Cache for the generated Control Points (returns from the callback).

Friends

class ControlPointContainerTests

Detailed Description

This Class is a structure to hold the whole ControlPoints for our terrain.

The structure is a 2-Dim. HashMap with an std::vector to store the height of the ControlPoint. The position of the Height value in the std::vector is the X- and Z-Value of the ControlPoint. To access the HashMap the ControlPointContainer gets absolute (world) Coordinates, which we maps to a key, calculated depending on the blocksize. If the Block is not existing the ControlPointContainer uses a callback from the ControlPointGenerator to fill the new generated block with ControlPoints. To get the ControlPoints to an absolute (world) position see the getPoints function.

Definition at line 28 of file ControlPointContainer.h.


Member Typedef Documentation

typedef __gnu_cxx::hash_map<int, std::vector<unsigned char> *> random_racer::ControlPointContainer::InnerHashMap [private]

This our 2-Dim.

HashMap with an std:vector of unsigned chars, which represents the Height of the ControlPoints

Definition at line 37 of file ControlPointContainer.h.

typedef __gnu_cxx::hash_map<int, InnerHashMap * > random_racer::ControlPointContainer::HashMap [private]

Definition at line 38 of file ControlPointContainer.h.


Constructor & Destructor Documentation

random_racer::ControlPointContainer::ControlPointContainer ( unsigned int  numControlPoints,
unsigned int  blocksize,
VRS::SO< VRS::Callback1< std::vector< VRS::Vector > * > >  genPointCallback,
int  minY,
int  maxY 
)

For the Callback Parameters looks at the ControlPointGenerator.h.

Parameters:
numControlPoints Number of ControlPoints
blocksize Size of the Block
minY Specifies the minimum Height of the ControlPoints
maxY Specifies the maximum Height of the ControlPoints

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

Definition at line 27 of file ControlPointContainer.cpp.


Member Function Documentation

int random_racer::ControlPointContainer::mapToKey ( double  value  )  [private]

Maps a given value to a key, depending on the blocksize.

Definition at line 32 of file ControlPointContainer.cpp.

References m_blocksize.

Referenced by random_racer::ControlPointContainerTests::testMapsValueToKey().

Here is the caller graph for this function:

int random_racer::ControlPointContainer::getOffset ( int  key  )  [private]

Returns the Offset for the absolute coordinates, depending on the given Block Key, the Blocksize and Number of ControlPoints.

Definition at line 38 of file ControlPointContainer.cpp.

References m_blocksize.

Referenced by random_racer::ControlPointContainerTests::testGetOffsetToKey().

Here is the caller graph for this function:

unsigned char random_racer::ControlPointContainer::mapToHashMapHeight ( double  height  )  [private]

Maps the Height-Value to 0 - 254 (the height from the generator is between 0 -1).

Definition at line 44 of file ControlPointContainer.cpp.

Referenced by generateBlock().

Here is the caller graph for this function:

double random_racer::ControlPointContainer::mapHeightBack ( unsigned char  height  )  [private]

Maps form 0 - 254 to original Height.

Definition at line 50 of file ControlPointContainer.cpp.

References m_absHeight, m_calcMinus, and m_minY.

unsigned int random_racer::ControlPointContainer::calculateAbsHeight ( int  minHeight,
int  maxHeight 
) [private]

Calculate the right absolute Height depending on the domain.

Definition at line 65 of file ControlPointContainer.cpp.

References m_calcMinus.

void random_racer::ControlPointContainer::getFourBlocks ( double  valueX,
double  valueZ,
int *  blockList 
) [private]

Calculates the right four blocks, which lays around the point and stores the X and Z Key for four Blocks.

Definition at line 87 of file ControlPointContainer.cpp.

References m_blocksize.

Referenced by random_racer::ControlPointContainerTests::testGetTheFourBlocks().

Here is the caller graph for this function:

void random_racer::ControlPointContainer::generateBlock ( int  valueX,
int  valueZ 
) [private]

Generates the block in the hashmap.

Definition at line 104 of file ControlPointContainer.cpp.

References m_callback, m_genPointCache, m_hashMap, m_numControlPoints, mapsIndex(), and mapToHashMapHeight().

Here is the call graph for this function:

unsigned int random_racer::ControlPointContainer::mapsIndex ( double  valueX,
double  valueZ 
) [inline, private]

Definition at line 113 of file ControlPointContainer.h.

References m_numControlPoints.

Referenced by generateBlock().

Here is the caller graph for this function:

unsigned int random_racer::ControlPointContainer::mapsIndexBackToX ( unsigned int  index  )  [private]

Definition at line 130 of file ControlPointContainer.cpp.

References m_numControlPoints.

unsigned int random_racer::ControlPointContainer::mapsIndexBackToZ ( unsigned int  p_index,
unsigned int  p_valueX 
) [private]

Definition at line 136 of file ControlPointContainer.cpp.

References m_numControlPoints.

template<class T>
void random_racer::ControlPointContainer::getPoints ( double  valueX,
double  valueZ,
T *  target 
)

This function writes all ControlPoints of the four bordering Blocks to the target.

The Target has to be a structure that has a push_back function. The four Blocks are calculated based on the given Point specified by valueX and valueZ.

Referenced by random_racer::ControlPointContainerTests::testHashMapValues().

Here is the caller graph for this function:

template<class T>
void random_racer::ControlPointContainer::getPoints ( double  beginX,
double  beginZ,
double  endX,
double  endZ,
T *  target 
)

This function writes the ControlPoints stored in the Hashmap to the target or generate them if they are not existing.

If the area specified by the first four parameters lie in one block, the ControlPoints of the one block is returned. If in two only the ControlPoints of the two Blocks. The last possibility is to lie in four Blocks the ControlPoints of the four Blocks are returned.

int random_racer::ControlPointContainer::minHeight (  )  [inline]

Definition at line 173 of file ControlPointContainer.h.

References m_minY.

int random_racer::ControlPointContainer::maxHeight (  )  [inline]

Definition at line 179 of file ControlPointContainer.h.

References m_maxY.


Friends And Related Function Documentation

friend class ControlPointContainerTests [friend]

Definition at line 49 of file ControlPointContainer.h.


Member Data Documentation

HashMap random_racer::ControlPointContainer::m_hashMap [private]

Definition at line 40 of file ControlPointContainer.h.

Referenced by generateBlock().

unsigned int random_racer::ControlPointContainer::m_numControlPoints [private]

m_Blocksize is the (absolute) Dimension of the Block.

m_numControlPoints is the Number of ControlPoints in the Block.

Definition at line 46 of file ControlPointContainer.h.

Referenced by generateBlock(), mapsIndex(), mapsIndexBackToX(), and mapsIndexBackToZ().

unsigned int random_racer::ControlPointContainer::m_blocksize [private]

Definition at line 46 of file ControlPointContainer.h.

Referenced by getFourBlocks(), getOffset(), and mapToKey().

int random_racer::ControlPointContainer::m_minY [private]

Stores the Domain of the Height.

Definition at line 65 of file ControlPointContainer.h.

Referenced by mapHeightBack(), and minHeight().

int random_racer::ControlPointContainer::m_maxY [private]

Definition at line 65 of file ControlPointContainer.h.

Referenced by maxHeight().

unsigned int random_racer::ControlPointContainer::m_absHeight [private]

Stores the absolute Domain of the Height.

Definition at line 70 of file ControlPointContainer.h.

Referenced by mapHeightBack().

bool random_racer::ControlPointContainer::m_calcMinus [private]

indicates if we have to substract (true) in the mapHeightBack function or to add

Definition at line 87 of file ControlPointContainer.h.

Referenced by calculateAbsHeight(), and mapHeightBack().

int random_racer::ControlPointContainer::m_blockList[8] [private]

Stores the X and Z Key for four Blocks.

The X-Key is to access the first Dim of the Hashmap, the Z-Key to access the second.

Definition at line 99 of file ControlPointContainer.h.

VRS::SO<VRS::Callback1<std::vector<VRS::Vector>* > > random_racer::ControlPointContainer::m_callback [private]

Callback to generate random control points The parameter specifies the target where we store the generated values.

Definition at line 130 of file ControlPointContainer.h.

Referenced by generateBlock().

std::vector<VRS::Vector> random_racer::ControlPointContainer::m_genPointCache [private]

Cache for the generated Control Points (returns from the callback).

Definition at line 135 of file ControlPointContainer.h.

Referenced by generateBlock().


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