Terrain Howto        
Print

There are two main terrain methods available to be used with Ogre - static meshes and height maps.

See also SceneManagersFAQ and World design for related information.

Static Meshes

Static meshes allow more freedom with terrain as you can have overhangs. You will need to implement collision detection however if you wish to have entities interact correctly with the terrain.
Can be used with octree scene manager.

Ogre Files you need :

  • .scene : shows the location and properties of the landscape nodes
  • .material(s) : for materials used by landscape
  • .mesh : actual landscape mesh

 
Typical content creation process (using octopus exporter as example)

  • Create terrain mesh using modelling program
  • Attach required textures (ie materials).
  • Export the scene as .scene file.
  • Export the mesh in XML format
  • Mesh XML file serialized into .mesh format (by OgreXmlConverter).
  • Materials (textures) exported as .material.

 
TO DO - .scene processing/using these in an application.

HeightMaps

 

 
Heightmaps)) are more limiting in that you cannot have overhangs in the terrain. For further terrain details such as bridges for example - you will need to add these as meshes on top of the height map. If you wish to have a cave you would need to leave a hole in the height map in order place meshes later at the appropriate locations.
Heightmaps are better suited for large maps and can be further optimised by using the paging scene manager.

The Terrain Scene Manager and Paging Scene Manager can be used with heightmaps. TODO - add other scene managers.

These scene managers provide an optimized getHeight function which allows entities to be easily snapped to the terrain. There would still need to be further collision code implemented for any terrain related meshes on the landscape.
Others advantages comes from advanced use of heightmap configuration :

  • Faster Loading and smaller disk size
  • Vertex displacement
  • Horizon culling
  • Dynamic texturing
  • Deformation
  • texture coordinates sharing across pages
  • Vertex program based morphing between LOD levels

 
Typical content creation process of a heightmap :

  • Create height map using a height map editor. 8 bits or 16 bits height maps are supported. Important: The image format must be saved in monochrome mode - height maps in RGB mode (24bit) will throw an exception.
  • Create necessary terrain coloring textures : Terrain Scene Manager needs to 2 textures (Detail is 8 bits gray noise & Color that is usually 24 bits, but you can provide any custom material you want). Paging Scene Manager has multiples combination of texturing up to 4 textures (grass, sand etc.) mixed at the same time, using 4 splatting texture ( 8 bits images )
  • If using Paging Scene Manager - preprocess height map through map splitter to split heightmaps in pages, and generate color and splatting textures.

 
Heightmaps and textures can be generated randomly by several programs. Look to DCC Tools.

Collisions

With terrains of meshes it's easy. Look e.g. the OgreNewt examples in the Ogre SDK.

With heightmap terrains it's difficult:

The (old) terrain scene managers typically don't just use normal meshes. If they did they wouldn't be specialised terrain scene managers, they'd just be normal scene managers displaying a load of meshes. They use all sorts of fancy LOD and morphing algorithms (or something like that) to provide performance optimisations for huge terrains.

It's not just as simple as getting the meshes that the terrain uses, because it probably doesn't use any.

So either:

  • Use the same heightmap image that the terrain uses and build your trimesh? manually from that.
  • Query the heights of the terrain at many many points using a ray query and use that to build your terrain trimesh.
  • Use the ray scene query on the fly with a specialised terrain collider, like what OgreOde does.

 
Written by monster in forum in May 2005. If it is not up to date, please correct.

Note:
In Ogre 1.8 the old Terrain Scene Manager will be removed and replaced by a new Terrain System.

In the forum is a code for implementing terrain collision with OgreNewt by building up a TreeCollision. (look here(external link))


Alias: TerrainHowto


Contributors to this page: alexeyknyshev44 points  , Spacegaier5974 points  , jacmoe177744 points  and Beauty14435 points  .
Page last modified on Monday 11 of March, 2013 17:02:34 UTC by alexeyknyshev44 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.