The Terrain Rendering Exploration toolKit (TREK) was the practical result of a year of research and implementation on terrain visualization methods, funded by the GEOIDE geomatics consortium. The source code implements some of the most important surface approximation algorithms (circa 2002), allowing you to swap between them in real-time. The visualization methods include:
- Brute force rendering.
- Subsampled grid rendering.
- The binary triangle tree method of Evans.
- The non-frame coherent ROAM approach.
- The frame-coherent ROAM approach.
- A modified frame-coherent ROAM approach that uses a new priority queue structure.
The software uses greyscale images as heightfield data for terrains. The problem with heightfield data is that rendering it in a brute-force manner entails exponential costs. As a result, simplification methods have been developed that only render the most important aspects of a terrain.
The software is written in C/C++, OpenGL and the FLTK toolkit. It includes a number of additional features, including:
- Dynamically configurable parameters for each of the algorithms.
- A flight-path system, to record and replay flight paths. (for comparing the speed of the visualizations).
- Tracing and statistical analysis tools, which can be turned off through a compiler directive.
- View-frustrum culling.
- A secondary camera, in addition to the primary camera.
- A skysphere.
- Basic particle systems, with terrain collision enabled.
- An optimized ray-wedge intersection algorithm for ray casting.
- An optimized (x,y)->(z) query to return the height of the approximation at a given planar coordinate.
- A pluggable architecture that allows a developer to insert their own approximation algorithm into the program with a minimal amount of fuss.
As with a lot of my C++, TREK makes very heavy use of assertions to test loop invariants, pre/post conditions and memory allocation. These assertions can be turned off using the standard -NODEBUG compiler directive.