ROAM landscapes with XNA

Landscapes in games are always a mission. I have started implementing a ROAM landscape that uses quadtrees, and it is looking pretty good (compared to my previous triangular one).

One of the things that I made to make the whole thing so much easier is a IndexedVertexBuffer. This beast handles my indices and vertices for me, all I need to is say buffer.AddIndex(0), for example. It can then be rendered to screen with a single call.

The whole thing is loosely based on Gamasutra article by Thatcher Ulrich. There are a few more optimizations that I can do on it, but so far I am getting zero problems with holes in the landscape.

The structure I have is persistent, with the cost of memory these days I don't see the point of regenerating it each time. Because of this, the whole process is quite CPU friendly and loading the terrain is almost instant. I did use a rather novel approach to generating the structure which warrants some explanation.

Firstly, I make the maximum resolution structure (in a 2D array, but this array is discarded in any case). I then repeatedly simplify it. A more typical approach would have been to generate the structure using recursion, but this means that you could get a stack overflow, and setting neighbor relationships would be a nightmare. It is actually far simpler my way (about 15 lines of clear code).

In any case I am going to put some screenshots up in the gallery (if I can figure out how to use it). Have a look :). I have marked up all the bits of interest.

Edit: The shots are up here.

posted @ Sunday, September 28, 2008 7:25 PM

Print
«November»
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345