• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 998
  • Last Modified:

Terrain generating....help

Could someone point me the right direction in the way to make a algorythm to generate a random map (with % of mountain, lakes, forest, etc.), I don't use MFC, but the game is starting to implement Windows programming stuff, so if anyone has links to tutorials, I would appreciate...

I had the idea to use fractal generating for the map, but then I can't specify the % of terrain type wanted....  
0
David MacDonald
Asked:
David MacDonald
1 Solution
 
mlaughtonCommented:
If you are trying to do this on-the-fly during your program, this tip won't help.  But if you'd like to generate 3D terrain before the fact, I'd really suggest checking out Bryce (formerly produced by MetaCreations, now owned by Corel).  9 months ago I wrote a simple program to generate terrain and just 2 weeks ago I found that Bryce does everything I originally wanted and oh so much more.

There are also a lot of rendering features such as textures and effects, but the actual terrain modeling tool is what I use it for.  There are several pre-packaged filters for different effects (water, lava, fractals, mountains, crystals, to name a few).

The real-time editing is done through a 2D bitmap & paintbrush, while the 3D preview version is shown using some kind of volume-rendering.  When you achieve the terrain you're going for, you accept the preview and it is tesselated into 3D polygons for you.

So far I haven't found any controls over the polygons that are created (which is necessary when concerned with 3D game performance) so another 3rd-party application might be needed for optimizations (Blender?, 3D Studio Max?).

Anyway, I hope this helps you out.
0
 
David MacDonaldAuthor Commented:
Thanks, your tip gave me an idea about another concern we had about the game, but the maps have to be generated during the program. Basically what we are doing is kind of an old type rpg sim game. The user will be asked what kind of terrain he wants, so the maps have to be generated on demand....
0
 
pjknibbsCommented:
This site has a few links which might be helpful:

http://members.tripod.com/gamecoder/terrain.htm
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
jack_p50Commented:
why don't you like fractals?
you may generate fractal different elevation (height) map; so low is lakes, high is mountains, and then randomly create some forests
0
 
David MacDonaldAuthor Commented:
It's not really that I don't like fractals (I love em...hehe)... but I can't think of a way to generate a fractal with a % of land, mountain, sea..etc.

pjknibbs:

I've looked at the site....pretty nice... it gave us an idea about another game we hope to make soon.... but the terrain we want for the present game is a 2D map..... more like a gameboard...
but thanks a lot...this link as been bookmarked...:)
0
 
mikefultonCommented:
You can use fractals and still exert some control over what percentage of the map is water, what percentage is mountain, what percentage is plains, etc.

To explain how, let me first briefly outline how a fractal map would be generated in the first place.  You probably already know this, but just in case...

The usual procedure is to assign random (or pseudo-random) numbers to the corners of the map.  This gives you a single large rectangle with values for each corner.  Now you subdivide that rectangle into 4 quadrants.  

To get the values for the new points of the 4 quadrants, you interpolate the corner values of the rectangle you just subdivided, then another random value is added to the result.

The magnitude of the random value that gets added is weighted by how many steps of subdivision you have done so far, so that in the early stages of creating the map, the random numbers may be large, indicating large changes in terrain.  In later stages of map creation, the random numbers are smaller, which would indicate more gradual changes in terrain.

This is one place where you can control your resulting map.  By changing the weighting of the random value according to how many subdivision steps you've done so far, you will get different types of landscape.

The subdivision process is repeated until you get down to the point where you can't subdivide any more because you can't split a pixel in half.

Now we get to how to control the map output.  If you want to specify certain percentages of certain terrain types, then instead of simply assigning random numbers to the map, select values that indicate the desired type of terrain.  

Instead of simply assigning the original 4 corners, you'll start out by subdividing the map into smaller sections right from the beginning.  For example, if you have a 256x256 map, then breaking it down into 16x16 squares will give you 256 points to set.  By selecting 256 values that are weighted towards your desired percentages of each terrain type, this should give you the control you want.

It may also be that doing an initial 8x8 grid with 64 seed values gives you fine enough control.  You'll have to experiment a bit.

By the way, when you assign your initial 256 values (or 64 values, or whatever) you might want to set two adjacent points to the same value.  This would give you a better guarantee that a particular area will show the desired terrain type.  If you set just one point, then the surrounding points could still be drastically different, and you might not get the desired result.  It's something you'd have to play around with a bit.

Another thing to consider is that you might want to specify terrain using two values instead of one.  The most simple fractal landscape generation uses a single value and presumes that everything below a certain threshold is in water, and everything above another threshold is snow-capped mountain.

There's no reason you *have* to do it that way.  You could use two values.  One would indicate the basic terrain type, such as water, grassland, forest, desert.  A second value would indicate elevation relative to the terrain type.  The combination of the two values would allow you to do things that a single value wouldn't allow, such as having a lake in a mountain valley.

Well, I hope this helps.
0
 
David MacDonaldAuthor Commented:
Adjusted points from 40 to 50
0
 
David MacDonaldAuthor Commented:
Answer accepted
0
 
David MacDonaldAuthor Commented:
Altough I do not understand all of it, I think I grasped much of the concept....

I'll try this one.... thanks mike!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now