User Tools

Site Tools


etm:overview

Editable Terrain Manager - Overview

Here I'll shortly describe the various components that make up the ETM library. For details, refer to the API reference and the sample.

TerrainInfo

The TerrainInfo class basically encapsulates heightmap data. You can construct it from an array or vector of floats, but there are also convenience functions to load heightmap data from images or raw data streams. In addition, you define the actual extents of the terrain in Ogre coordinates.

But there's more to TerrainInfo: This class provides the means to query the terrain for various information, such as the terrain height at a certain position as well as testing for ray intersection or terrain normals. So you will probably turn to this class often :) Note that, when you load a terrain, the TerrainManager creates a copy of the supplied TerrainInfo which you can in turn get a const reference to via TerrainManager::getTerrainInfo(). You should work with this const reference, because it will reflect deformation changes while your initial TerrainInfo object will not.

Whenever you are finished deforming your terrain, there are convenience functions to store the heightmap back to files.

TerrainManager

The TerrainManager is the core class which actually creates and renders the terrain in OGRE. You can choose what error margins you'd want to tolerate for terrain rendering, and you can also specify whether or not to create the necessary data structures to do LOD morphing. Then you can load terrain by passing in a TerrainInfo object as well as your desired tile size: Tiles are the rendering primitives into which your terrain is divided internally. It must conform to 2^n+1.

Note that to actually see your terrain, you will have to pass the material you would like to use for the terrain to the TerrainManager. Unlike the TSM, the TerrainManager has no standard material, it's entirely up to you.

SplattingManager

All the SplattingManager actually does is to create some textures dynamically in memory and allows you to edit them. You pass in a basename for those textures as well as the number of channels to use (from 1 to 4). To actually make use of those, you need to create a terrain material which uses these dynamic textures as splatting coverage maps. Unless you want to waste endless amounts of passes on your terrain, you will likely want to use a pixel shader to splat several textures in one pass. The ETM includes an example for doing this.

Brush

This class defines an editing brush you can use both to deform or set terrain heights as well as to edit the textures managed by the SplattingManager. You can create Brushes from arrays or vectors of floats, and there is also a convenience function to load one from a grayscale image (see the demo). Note that the Brush affects terrain vertices (or texture pixels), not actual positions, so when deforming or painting, you need to convert your Ogre positions into meaningful vertex or pixel indexes. One way to do that is via the TerrainInfo::posToVertex functions (again, see the demo).

etm/overview.txt · Last modified: 2015/08/23 13:06 (external edit)