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

The Terrain class renders the terrain using patches and a displacement texture. Patches that are too far from the current camera position are culled. More...

#include <terrain.h>

Inheritance diagram for terminus::Terrain:
terminus::AbstractGraphicsObject

Public Member Functions

 Terrain (World &world, const Level &level)
 
virtual void localRender (QOpenGLFunctions &gl) const override
 this method contains the default render code using m_geometry, m_program and m_material More...
 
virtual void localRenderSetup (QOpenGLFunctions &gl, Program &program) const override
 override this method to customize the rendering process More...
 
virtual void localRenderCleanup (QOpenGLFunctions &gl, Program &program) const override
 override this method to customize the rendering process More...
 
void configureWith (const Level &level)
 sets the displacement texture and track courses according to level More...
 
TrackrightTrack () const
 
TrackleftTrack () const
 
- Public Member Functions inherited from terminus::AbstractGraphicsObject
 AbstractGraphicsObject (World &world)
 
virtual ~AbstractGraphicsObject ()
 
virtual void update () final
 update object hierarchy beginning at this object More...
 
virtual void render (QOpenGLFunctions &gl) final
 render object hierarchy beginning at this object More...
 
virtual void bindCamera (Camera *camera)
 binds a camera to track this object More...
 
virtual void unbindCamera (Camera *camera)
 release a camera so that it wont track this object any longer More...
 
virtual void onBindCamera ()
 override this method to perform specific actions once a camera has been bound More...
 
virtual void onUnbindCamera ()
 override this method to perform specific actions once a camera has been released More...
 
virtual void adjustCamera ()
 override this method to adjust the parameters of a bound camera according to this objects own state More...
 
virtual void moveEvent (QVector3D movement)
 override this method to react to move events received by a bound camera More...
 
virtual void rotateEvent (QVector2D rotation)
 override this method to react to rotate events received by a bound camera More...
 
const QVector3D & minBB () const
 
const QVector3D & maxBB () const
 
QVector3D worldUp ()
 
QVector3D worldFront ()
 
QVector3D worldSide ()
 
QVector3D position () const
 
QQuaternion rotation () const
 
QVector3D scale () const
 
QMatrix4x4 modelMatrix () const
 
QMatrix4x4 modelMatrixInverted () const
 

Protected Member Functions

virtual void doForAllChildren (std::function< void(AbstractGraphicsObject &)> callback) override
 override this method to make child objects known More...
 
void renderPatch (QOpenGLFunctions &gl, int iX, int iZ) const
 
void allocateTerrainMap (QOpenGLFunctions &gl) const
 
void deallocateTerrainMap (QOpenGLFunctions &gl) const
 
- Protected Member Functions inherited from terminus::AbstractGraphicsObject
virtual void localUpdate ()
 override this method to update this objects state More...
 
virtual bool localRenderEnabled () const
 override this method to disable or enable rendering conditionally More...
 
void setPosition (const QVector3D &position)
 sets the position and invalidates the model matrices More...
 
void setRotation (const QQuaternion &rotation)
 sets the rotation and invalidates the model matrices More...
 
void setScale (const QVector3D &scale)
 sets the scale and invalidates the model matrices More...
 
void setScale (float scale)
 sets the scale uniformly on all three axes and invalidates the model matrices More...
 
QVector3D worldToModel (const QVector3D &vWorld)
 
QVector3D modelToWorld (const QVector3D &vModel)
 
void dispose ()
 remove this object from the world and delete it as soon as it is safe to do so More...
 

Protected Attributes

LevelConfiguration m_levelConfig
 
std::unique_ptr< Trackm_rightTrack
 
std::unique_ptr< Trackm_leftTrack
 
std::unique_ptr< std::vector< GLfloat > > m_terrainMapData
 
bool m_terrainMapOnGPU
 
bool m_terrainMapValid
 
GLuint m_terrainMap
 
int m_currentPatchX
 
int m_currentPatchZ
 
- Protected Attributes inherited from terminus::AbstractGraphicsObject
Worldm_world
 
bool m_validState
 
Cameram_camera
 
std::shared_ptr< std::unique_ptr< Program > > m_program
 
std::shared_ptr< std::unique_ptr< Geometry > > m_geometry
 
std::shared_ptr< std::unique_ptr< Material > > m_material
 
QVector3D m_position
 
QQuaternion m_rotation
 
QVector3D m_scale
 
bool m_modelMatrixChanged
 
QMatrix4x4 m_modelMatrix
 
bool m_modelMatrixInvertedChanged
 
QMatrix4x4 m_modelMatrixInverted
 

Detailed Description

The Terrain class renders the terrain using patches and a displacement texture. Patches that are too far from the current camera position are culled.

This class also contains the two tracks as children.

See also
Track

Constructor & Destructor Documentation

terminus::Terrain::Terrain ( World world,
const Level level 
)

Member Function Documentation

void terminus::Terrain::allocateTerrainMap ( QOpenGLFunctions &  gl) const
protected
void terminus::Terrain::configureWith ( const Level level)

sets the displacement texture and track courses according to level

Parameters
level
void terminus::Terrain::deallocateTerrainMap ( QOpenGLFunctions &  gl) const
protected
void terminus::Terrain::doForAllChildren ( std::function< void(AbstractGraphicsObject &)>  callback)
overrideprotectedvirtual

override this method to make child objects known

Parameters
callbackcallback must be called once for every child object

Reimplemented from terminus::AbstractGraphicsObject.

Track & terminus::Terrain::leftTrack ( ) const
void terminus::Terrain::localRender ( QOpenGLFunctions &  gl) const
overridevirtual

this method contains the default render code using m_geometry, m_program and m_material

Parameters
gllocalRenderSetup() and localRenderCleanup are called from here and are the preferred way to customize the rendering process over overriding this method entirely

Reimplemented from terminus::AbstractGraphicsObject.

void terminus::Terrain::localRenderCleanup ( QOpenGLFunctions &  gl,
Program program 
) const
overridevirtual

override this method to customize the rendering process

Parameters
gl
program- still bound

Here is the right place to clean up rendering states set in localRenderSetup().

Reimplemented from terminus::AbstractGraphicsObject.

void terminus::Terrain::localRenderSetup ( QOpenGLFunctions &  gl,
Program program 
) const
overridevirtual

override this method to customize the rendering process

Parameters
gl
program- already bound

Here is the right place to set additional uniforms and to bind textures &c.

Reimplemented from terminus::AbstractGraphicsObject.

void terminus::Terrain::renderPatch ( QOpenGLFunctions &  gl,
int  iX,
int  iZ 
) const
protected
Track & terminus::Terrain::rightTrack ( ) const

Member Data Documentation

int terminus::Terrain::m_currentPatchX
mutableprotected
int terminus::Terrain::m_currentPatchZ
mutableprotected
std::unique_ptr<Track> terminus::Terrain::m_leftTrack
protected
LevelConfiguration terminus::Terrain::m_levelConfig
protected
std::unique_ptr<Track> terminus::Terrain::m_rightTrack
protected
GLuint terminus::Terrain::m_terrainMap
mutableprotected
std::unique_ptr<std::vector<GLfloat> > terminus::Terrain::m_terrainMapData
protected
bool terminus::Terrain::m_terrainMapOnGPU
mutableprotected
bool terminus::Terrain::m_terrainMapValid
mutableprotected

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