James Randall Musings on software development, business and technology.
Empire of Asphalt: Landscape Part 1

Cracked on with the landscape system over the weekend and got a nice SimCity 2000 / Transport Tycoon style isometric system up and running.

It uses the diamond square algorithm with a few constraints added. It was trivial to get a beautiful rolling landscape in place… fiddly to get it looking all chunky and isometric!

I also spent a while wandering why large maps seemed to stop rendering at an arbitary point. Turned out that I’d exceed 64k of indexes for verticies in a index buffer and the type of the values in such buffers is 16-bits.

The solution was to break them into chunks which I wanted to do anyway as when the player is raising, lowering and levelling the terrain I didn’t really want to be regenerating a single very large mesh. With the chunk approach I can just update most of the time a single chunk and at the worst case 4 chunks (when the player changes something on a corner). I guess I could optimise that further to a maxium of 3 chunks by “mis-aligning” the chunks but I suspect the increased complexity isn’t worth the effort.

Next steps are to make sure there are some level parts of the map to start out with and add some water but the hard bit is pretty much done.

You can see the current iteration in the video below and the source is in this commit in GitHub.