|
Code
|
|
Written in C++ with OpenGL using MSVC 5.0. Runs over
windows using Nehe's window code. Originally written
in GLUT.
|
|
Quad Tree
|
|
The landscape is a quad tree of a variable depth. The
default depth for the game is 6. This allows me to create
4096 squares, each of which is divided into 2 triangles.
|
|
Lighting
|
|
A single pass through the tree grabs all the heights and
generates the lighting normals. This is done once at the
beginning of the terrain and after each deformation.
When the drawing code parses the tree it grabs the correct
lighting normal for each vertex. The per-vertex lighting
allows for a smoother landscape.
|
|
Collision Detection
|
|
The quad-tree nature of the landscape also allows for collision
detection in log(n) time.
|
|
Display Lists
|
|
Unfortunately the deformable property of the terrain doesnt allow
it to be stored in a display list. Nor can I use tesselation to
increase the detail of the terrain.
All other objects have been added to the display list.
|
|
Height Maps
|
|
The landscape can be generated either from a fractal algorithm, or
from a heightmap bmp file.
|
|
Other Ideas (yet to be implemented)
|
|
Tri structure for storing branches. Leafs will display leaves.
Tree depths dependent on distance from camera. Branches and leaves
will be Display Listed.
On the fly tessalation of triangles closes to the camera for added
detail.
|
|