[MUD-Dev] Re: Terrain/Landmass & GIF/BMP

Niklas Elmqvist d97elm at dtek.chalmers.se
Thu Oct 8 07:36:43 New Zealand Daylight Time 1998

On Wed, 7 Oct 1998, quzah [sotfhome] wrote:


> The first is this: I am developing a world generator of
> sorts, that with a few parameters will generate the entire
> mud world. It will take into account the following info:
>    sizeX (width of world west to east)
>    sizeY (length of world north to south)
>    clustering (continents/small islands/large islands/etc)
>    "hillyness" (flat/small hills/mountains/etc)
>    mineral richness (frequency of mineral deposits)
>    temperature (over all cold/mild/warm/hot/etc)
>    on land water supplies (rivers/lakes/etc [amount of])
>    wetness (over all very dry/dry/moderate/damp/very wet/etc)

Neat. I am doing the same for a 3D terrain renderer.

> Does anyone know a link or quick formula I could look at to do
> something along these lines? I can just toss out random +/- to
> a given coordinate, and check its neighbors to make sure there
> is not too big a jump, but I think that would be inefficient
> and or ineffective in the long run. Any suggestions?

Well, other posters have already suggested the use of fractal terrain
generation, and I tend to agree.

The basics of fractal terrain generation are quite simple and can be
contrived by just about anyone. Think "subdivision" and "recursion" and
you're home free. What you do is that you start out with an empty
matrix and initialize its corners to a random height. Then call the
recursive subdivide procedure on the matrix, which will compute the
average heights, plot them into the matrix and then call itself
recursively on the four subsquares (there are many variations on this).

A good place to start out is with the following article, which explains
the technique in pretty good detail:
<URL: http://www.gameprogrammer.com/fractal/fractal.html>

I once had a reference to a scientific paper describing how to add
"nature" your terrain fields in the sense of erosion, snow, and
vegetation. I could kill to get a hand on it now. :)

> (For rivers I plan on using heuristics for getting from point
> A (river source) to point B (river mouth) but I haven't looked
> at it too in depth. Finally I believe I have managed to locate
> the actual formula for "A*" so I may see what I can do with it
> at a later date.)

I'd certainly be interested in seeing this if you have the possibility to
post it. 

> After finally generating a world mass, I need a way to "see"
> what it looks like. Even on a very small world (500x1000) in
> ASCII form, it will be very very hard to get an over all look
> at the world. I was thinking that if there is a simple way to
> output to a GIF or BMP, then I'd be able to just open up the
> picture in a paint program and "see" what the world looks
> like. Does anyone know of any good links that explain how to
> output either "x number of bits" or "x number of bytes" to a
> GIF or BMP? (PCX would even work). Currently, each piece of
> info on the land mass takes up 20 bits, so I can either drop
> it down to 16 bits, or bump it up to 32 bits for the use of
> GIF/BMP (Yeah, I know GIF is 8bits, I THINK I can lower it
> enough to be able to use a GIF format).

Hmmm.... Seems to me that if you want to encode *all* the information in
the map in a single picture, you'll get a very messy one. That is, it will
be very hard (just as hard as with your ASCII output) to get a feel for
what the map looks like. You can simply *not* encode all the data fields
in those 20 bits (some of which are heights, others which are resources,
and so on, I take it?) and make it useful for a human reader ("so, okay,
um, a lot of green mixed in with a little red should mean high altitude
and some, um, lessee, iron ore..."). 

Instead, I'd suggest you make overlay pictures... That is, one picture
shows the height levels in nice shades of gray. Another shows the resource
distribution while another might show bodies of water (ok, some of these
could be combined into one). 

As for graphics formats... The format that strikes me as the simplest is
plain BMP (the Windows incarnation, that is). However, other posters have
responded to this, so I will refrain from doing it as well. 


> -Q-

-- Niklas Elmqvist (d97elm at dtek.chalmers.se) ----------------------
  "Nanny Ogg looked under her bed in case there was a man there. 
   Well, you never knew your luck."
		-- Terry Pratchett, Lords and Ladies

More information about the MUD-Dev mailing list