vForums Support > Programming & Coding :: Programming Discussion :: > Random Terrain Generation

Random Terrain Generation - Posted By Marc (cr0w) on 7th Feb 09 at 6:18pm
Image
Download as .rar
Download as .zip


This is the project I undertook for my Computer Science class first semester. It randomly generates a landscape using an algorithm known as MPD (MidPoint Displacement).

The way it works is that the 4 corner points are randomly set. Next the point in the middle of those 4 are set by taking the average of the 4 corner points, and adding/subtracting a random value.

Next you set the point in the middle of two corners and the middle point, again using the average plus or minus a (smaller) random displacement.

This continues until every point has been set.

I took this project on with very limited knowledge of C++, and learned a lot as time went on. For my first major challenge using a new language, I think I did very well.

There are still quite a few things that are buggy, such as the shading, but I am working on getting all bugs fixed.

The only things you need to worry about in this program are the "Max Displacement" and the "Artifact Indifference". The "Max Displacement" is the highest random value that can be used to set a point's height. The "Artifact Indifference" looks for any point that for whatever reason is at least a certain height higher than all those around it, and redefines its height, making the landscape flow more smoothly.

Thoughts? Comments? {Grin}

Re: Random Terrain Generation - Posted By dog199200 (dog199200) on 8th Feb 09 at 1:10am
its good for a start by looking at the images, but you might wnat to add in a texturing system and a map shaping tool or two and maybe an 3D extraction tool later on {Tongue Out}

Re: Random Terrain Generation - Posted By Marc (cr0w) on 8th Feb 09 at 5:31am
The main point of this assignment was to get a feel for OpenGL and GLUT; I may add a texturization system, but I can't see myself ever using the other two.