Terminus
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
terminus::Level Class Reference

The Level class is a generator for level data such as terrain geometry and track courses. More...

#include <level.h>

Public Member Functions

 Level ()
 
 Level (const LevelConfiguration &config)
 
void generateLevel ()
 generate terrain and tracks if not already generated More...
 
void resetLevel ()
 discard terrain and tracks if already generated More...
 
void configure (const LevelConfiguration &config)
 set a new configuration and discard the previously generated terrain and tracks if already generated More...
 
const LevelConfigurationconfig () const
 
std::vector< GLfloat > * copyTerrainMapData () const
 
PolylinecreateRightTrackCourse () const
 
PolylinecreateLeftTrackCourse () const
 

Protected Member Functions

float trackHeight (float x, float z) const
 
void generateTracks ()
 
void generateTerrainMap ()
 
QVector2D terrainDisplacement (float x, float z)
 
void setTrackEnvironment (const CatmullRomSpline &track)
 
float terrainHeight (float x, float z, float fTrack)
 
int tMapIndex (int s, int t) const
 
void tMapSetXYZ (int i, float dx, float dy, float dz)
 
QVector3D tMapGetXYZ (int i) const
 
void tMapSetW (int i, float w)
 
float tMapGetW (int i) const
 

Protected Attributes

LevelConfiguration m_config
 
PerlinNoise m_noise
 
bool m_tracksGenerated
 
std::unique_ptr< CatmullRomSplinem_rightTrack
 
std::unique_ptr< CatmullRomSplinem_leftTrack
 
bool m_texGenerated
 
std::vector< GLfloat > m_terrainMapData
 

Detailed Description

The Level class is a generator for level data such as terrain geometry and track courses.

It uses a LevelConfiguration instance that specifies the dimensions of the generated terrain and a seed value for the pseudo random number generator.

See also
LevelConfiguration

Constructor & Destructor Documentation

terminus::Level::Level ( )
terminus::Level::Level ( const LevelConfiguration config)

Member Function Documentation

const LevelConfiguration & terminus::Level::config ( ) const
Returns
the current LevelConfiguration
void terminus::Level::configure ( const LevelConfiguration config)

set a new configuration and discard the previously generated terrain and tracks if already generated

Parameters
config
std::vector< GLfloat > * terminus::Level::copyTerrainMapData ( ) const
Returns
a copy of the generated terrain displacement map that can be used to fill an OpenGL texture object
Polyline * terminus::Level::createLeftTrackCourse ( ) const
Returns
a newly created Polyline instance that approximates the course of the left track
Polyline * terminus::Level::createRightTrackCourse ( ) const
Returns
a newly created Polyline instance that approximates the course of the right track
void terminus::Level::generateLevel ( )

generate terrain and tracks if not already generated

void terminus::Level::generateTerrainMap ( )
protected
void terminus::Level::generateTracks ( )
protected
void terminus::Level::resetLevel ( )

discard terrain and tracks if already generated

void terminus::Level::setTrackEnvironment ( const CatmullRomSpline track)
protected
QVector2D terminus::Level::terrainDisplacement ( float  x,
float  z 
)
protected
float terminus::Level::terrainHeight ( float  x,
float  z,
float  fTrack 
)
protected
float terminus::Level::tMapGetW ( int  i) const
protected
QVector3D terminus::Level::tMapGetXYZ ( int  i) const
protected
int terminus::Level::tMapIndex ( int  s,
int  t 
) const
protected
void terminus::Level::tMapSetW ( int  i,
float  w 
)
protected
void terminus::Level::tMapSetXYZ ( int  i,
float  dx,
float  dy,
float  dz 
)
protected
float terminus::Level::trackHeight ( float  x,
float  z 
) const
protected

Member Data Documentation

LevelConfiguration terminus::Level::m_config
protected
std::unique_ptr<CatmullRomSpline> terminus::Level::m_leftTrack
protected
PerlinNoise terminus::Level::m_noise
protected
std::unique_ptr<CatmullRomSpline> terminus::Level::m_rightTrack
protected
std::vector<GLfloat> terminus::Level::m_terrainMapData
protected
bool terminus::Level::m_texGenerated
protected
bool terminus::Level::m_tracksGenerated
protected

The documentation for this class was generated from the following files: