Horde3D Terrain Extension | |
Introduction | Some words about the Terrain Extension. |
Constants | |
Predefined constants | |
Enumerations | |
H3DEXTTerrain | The available Terrain node parameters. |
Functions | |
h3dextAddTerrainNode | Adds a Terrain node to the scene. |
h3dextCreateTerrainGeoRes | Creates a Geometry resource from a specified Terrain node. |
Some words about the Terrain Extension.
The Terrain Extension extends Horde3D with the capability to render large landscapes. A special level of detail algorithm adapts the resolution of the terrain mesh so that near regions get more details than remote ones. The algorithm also considers the geometric complexity of the terrain to increase the resoultion solely where this is really required. This makes the rendering fast and provides a high quality with a minimum of popping artifacts.
A height map is used to define the altitude of the terrain. The height map is a usual texture map that encodes 16 bit height information in two channels. The red channel of the texture contains the coarse height, while the green channel encodes finer graduations. The encoding of the information is usually done with an appropriate tool. If you just want to use 8 bit height information, you can simply copy the greyscale image to the red channel of the height map and leave the green channel black.
To install the extension, copy the Extensions directory to the path where the Horde3D SDK resides, so that the two directories are on the same level in the hierarchy. In Visual Studio, add the extension and sample projects to the Horde3D solution. Then add the extension project to the project dependencies of the Horde3D Engine and the Horde3D Engine to the dependencies of the Terrain Sample. After that, include ‘Terrain/extension.h’ in ‘egExtensions.cpp’ of the engine and add ‘#pragma comment( lib, “Extension_Terrain.lib” )’ to link against the terrain extension (under Windows). Finally, add the following line to ExtensionManager::installExtensions to register the extension:
The extension is then part of the Horde3D DLL and can be used with the Horde3DTerrain.h header file.
The extension defines the uniform terBlockParams and the attribute terHeight that can be used in a shader to render the terrain. To see how this is working in detail, have a look at the included sample shader.
The available Terrain node parameters.
DLL H3DNode h3dextAddTerrainNode( H3DNode parent, const char * name, H3DRes heightMapRes, H3DRes materialRes )
Adds a Terrain node to the scene.
This function creates a new Terrain node and attaches it to the specified parent node.
parent | handle to parent node to which the new node will be attached |
name | name of the node |
heightMapRes | handle to a 2D Texture resource that contains the terrain height information (must be square and POT) |
materialRes | handle to the Material resource used for rendering the terrain |
handle to the created node or 0 in case of failure
DLL H3DRes h3dextCreateTerrainGeoRes( H3DNode node, const char * resName, float meshQuality )
Creates a Geometry resource from a specified Terrain node.
This function creates a new Geometry resource that contains the vertex data of the specified Terrain node. To reduce the amount of data, it is possible to specify a quality value which controls the overall resolution of the terrain mesh. The algorithm will automatically create a higher resoultion in regions where the geometrical complexity is higher and optimize the vertex count for flat regions.
node | handle to terrain node that will be accessed |
resName | name of the Geometry resource that shall be created |
meshQuality | constant controlling the overall mesh resolution |
handle to the created Geometry resource or 0 in case of failure
Adds a Terrain node to the scene.
DLL H3DNode h3dextAddTerrainNode( H3DNode parent, const char * name, H3DRes heightMapRes, H3DRes materialRes )
Creates a Geometry resource from a specified Terrain node.
DLL H3DRes h3dextCreateTerrainGeoRes( H3DNode node, const char * resName, float meshQuality )