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

quzah quzah
Thu Oct 22 01:20:54 New Zealand Daylight Time 1998


From: Chris Gray <cg at ami-cg.GraySage.Edmonton.AB.CA> on Thursday, October 08,
1998 at 6:14 PM
Subject: Re: [MUD-Dev] Re: Terrain/Landmass & GIF/BMP


>Haven't looked into fractal terrain generation or display, eh. OK, that
>gives me an opportunity to fill your mailbox! Here is the complete source
>for a fractal terrain generator/displayer for my AmigaMUD system. The
>source will look at bit unusual, but its close enough to things like C
>and Pascal that it should be readable.
>


[example snipped]

Well, this is just a general reply/comment for anyone who replied
to me earlier; and since this was the last message on the topic,
this is what I'm replying to.

Anyway, I settled on targa (.tga) for my graphic file of choice.
I chose it because it had the best docs (read: simple for me simple
brain) of what I looked at. I first looked at png, pcx, bmp, gif,
tiff, and tga. (Thanks for the link to wotsit, btw.) My implementation
is very ugly, and reading the .tga craps out after the 18th byte,
though I am not sure why. (Every byte past the 18th reads 10000000
no matter what your actual data should be. Period. No matter what
.tga file, from the 18th bit onward reads exactally the same.)

I cheated in making my .tga writer. I opened up photoshop, wrote a
1000x1000 pixel .tga @ 16 bpp, all one color, then read the file one
bit at a time (outputting to a screen) and compared it with the .txt
file I had to see if the bits lined up like they should.

.TGA has a very ugly way to store 2-byte pieces of info. First, you
take and reverse the entire thing left-to-right (bit by bit), then
take the first eight bits, and swap them with the second eight bits
and that's how it stores it to file. (Or something like that -- anway
it works now.)

So, my .tga writer just writes the 18 bits in fixed-mode (ie: Yes,
this is going to be 1000x1000 at 16bpp and if you don't like it, rewrite
the header. ;). Then I just write an array 1000x1000 of color (16 bits)
to disk and call it good.

It's ugly, but I'm not making a graphical game, all I need to do is
make it readable in photoshop so I can see what the dirt looks like.

And hey, photoshop likes it, so that's good enough for me.

At any rate, now I'm trying to get the land to look good, and not just
be 32 different colors of green blocks ;)
-Q-

(god I must have been tired last night, I sent this the first
 time only to chris; not mud-dev --sigh)





More information about the MUD-Dev mailing list