OpenGL Library for Delphi,
maintained by Eric Grange,
based on Mike Lischke's GLScene.

 

Reference Manual - TGLTerrainRenderer

image

The terrain renderer is used to create terrain using an advanced terrain generation algorithm (ROAM). The terrain renderer uses a height data source to generate the terrain heights. Height can be specified as a grey scale bitmap with the TGLBitmapHDS (where white is the highest peak while black is the lowest), HTF file format or using the TGLCustomHDS for custom formats or dynamically generated data. A texture can be applied to the mesh giving a realistic terrain.

image

Important terrain renderer parameters include:
clodprecision: Defines how accurately the terrain is generated. The lower the clodprecision the higher the accuracy and the slower the terrain generation.

qualitystyle: Tiles close to the camera are rendered with higher quality. The two styles are full quality (hrsFullGeometry) and high quality tesselation (hrsTesselated).

qualitydistance: Used to determine how close a tile must be before it is rendered in high quality.

maxclodtriangles: Specifies the size of the internal buffer used by the terrain renderer to hold the triangles of the generated mesh. Tiles rendered with "full quality" does not use this buffer. This should set high enough that it won't exhaust it during rendering, but keep in mind that higher numbers requires more memory, so don't set it higher than needed. You can use the lasttrianglecount property to determine how many triangles was renderer the last frame.

tilesize: A terrain can be split up into tiles. Tiles that are far away from the camera a displayed with lower precision than those closer to the camera, therefore having more than one tile is desirable for speed. However, there is a tradeoff. Each tile can't be rendered with less than two triangles and there is some overhead processing a tile, so having too small tiles (thus splitting the terrain into very many tiles) is not desirable.

tilespertexture: This defines how a texture is displayed on the terrain. If you want to have one texture to cover the entire terrain, you will need to increase the tilespertexture (assuming there are multiple tiles).

heightdatasource: This set the height datasource. The most commonly used one is the TGLBitmapHDS. Others include the TGLCustomHDS, TGLHTFHDS (for HTF files) and TGLPerlinHDS (for Perlin noise generated terrains).

An 'interesting' feature of the terrain renderer is that the texture is displayed the wrong way round therefore you will need to mirror the texture if you want the texture to be the correct way round.

Due to the way the terrain renderer works, regular lighting cannot be used. The usual way to perform lighting is to incorporate it into the texture, or to use a secondary texture.

Note also that Phil Scadden has written an article about the terrain renderer with much more detail at: Terrain Renderer

Demo: CVS/Demos/meshes/terrain

Unit: GLTerrainRenderer

Descends from TGLSceneObject.
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 0.0472 seconds