molecular
Public Member Functions | List of all members
molecular::gfx::DrawTerrain Class Reference

Draw heightmap terrain. More...

#include <DrawTerrain.h>

Inheritance diagram for molecular::gfx::DrawTerrain:
molecular::gfx::DrawingFunction molecular::gfx::RenderFunction

Public Member Functions

template<class TRenderManager >
 DrawTerrain (TRenderManager &manager)
 
 ~DrawTerrain ()
 
void Execute () override
 
util::AxisAlignedBox GetBounds () const override
 
void SetHeightScale (float scale)
 Set scaling factor for heightmap values. More...
 
void SetSize (float xSize, float ySize)
 Set drawing size of terrain. More...
 
void SetHeightmapData (unsigned int width, unsigned int height, const float *data)
 Set heightmap data from array of floats. More...
 
void SetTestData (unsigned int width, unsigned int height)
 Set heightmap to a 2D sine pattern for testing purposes. More...
 
void SetLodFactor (float factor)
 Set factor which decides on the LOD level from distance to viewer. More...
 
void SetPickingId (unsigned int id)
 
- Public Member Functions inherited from molecular::gfx::DrawingFunction
template<class TRenderManager >
 DrawingFunction (TRenderManager &manager)
 
bool BoundsChangedSince (int framecounter) const override
 
- Public Member Functions inherited from molecular::gfx::RenderFunction
template<class TRenderManager >
 RenderFunction (TRenderManager &manager)
 
 RenderFunction (Scoping &scoping, RenderCmdSink &renderer)
 
virtual ~RenderFunction ()
 
virtual void Set (Hash, bool)
 Set bool property with given name. More...
 

Additional Inherited Members

- Protected Member Functions inherited from molecular::gfx::DrawingFunction
RenderCmdSink::ProgramPrepareProgram ()
 
- Protected Member Functions inherited from molecular::gfx::RenderFunction
template<class T >
const T * GetVariable (Hash key)
 Convenience shortcut to a variable pointer from the dynamic scope. More...
 
- Protected Attributes inherited from molecular::gfx::DrawingFunction
ProgramProvidermProgramProvider
 
- Protected Attributes inherited from molecular::gfx::RenderFunction
ScopingmScoping
 
RenderCmdSinkmRenderer
 

Detailed Description

Draw heightmap terrain.

Divides the terrain into patches of size kPatchSize. Stores heightmap data in a texture that is evaluated in the vertex shader. Does level of detail calculations. Origin of the terrain mesh is the corner with heightmap index 0,0.

Todo:

Frustum culling for individual patches.

Skirting to hide seams between patches with different LOD.

Mipmapping. Right now, simple subsampling is used for lower LOD.

Constructor & Destructor Documentation

template<class TRenderManager >
molecular::gfx::DrawTerrain::DrawTerrain ( TRenderManager &  manager)
molecular::gfx::DrawTerrain::~DrawTerrain ( )

Member Function Documentation

void molecular::gfx::DrawTerrain::Execute ( )
overridevirtual
util::AxisAlignedBox molecular::gfx::DrawTerrain::GetBounds ( ) const
overridevirtual
void molecular::gfx::DrawTerrain::SetHeightmapData ( unsigned int  width,
unsigned int  height,
const float *  data 
)

Set heightmap data from array of floats.

void molecular::gfx::DrawTerrain::SetHeightScale ( float  scale)
inline

Set scaling factor for heightmap values.

Defaults to 1.

Todo:
Pass as parameter to SetHeightmapData().
void molecular::gfx::DrawTerrain::SetLodFactor ( float  factor)
inline

Set factor which decides on the LOD level from distance to viewer.

void molecular::gfx::DrawTerrain::SetPickingId ( unsigned int  id)
inline
void molecular::gfx::DrawTerrain::SetSize ( float  xSize,
float  ySize 
)

Set drawing size of terrain.

Terrain is always drawn with these dimensions, regardless of heightmap sample count.

void molecular::gfx::DrawTerrain::SetTestData ( unsigned int  width,
unsigned int  height 
)

Set heightmap to a 2D sine pattern for testing purposes.


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