Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Terragen terrain loader

Author
Message
apmoh
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location:
Posted: 3rd Jan 2004 04:41
The problem:

My daughter wanted to create a simulated spud-gun in DB. This created a real problem in scale, we needed enough resolution to be able to see a 4in. potato and enough room to shoot it 500 or more meters.

My first attempt at a solution was to create a 50 x 50 matrix. I scaled it so that each side was 150000 units long. If I assumed that 1 world unit equals 1 cm, that made the matrix side 1.5 km long and each tile 30m to a side. I then stuck great big walls on the four sides of the matrix. This worked pretty good, but there were two problems:

1. when you get into really large scales randomize matrix stops working and you have to manually set the heights - Ok, I can make prettier terrains anyway.

2. my camera kept getting to places where it could see over the walls and it was ugly.

I wanted a "see forever" kind of terrain.

So after a lot of cussing and hair pulling I have created a program that loads a terragen .ter file into a memblock and uses it to dynamically update a 50x50 matrix. A 257x257 terrain gives you a 7.5 x 7.5 km playground and with a 750m buffer area on each side that you can't enter you Still have 6x6 km to roam around in.

So, is there any interest in my posting the code? It is not perfect but I could use some constructive criticism and comments. Or has it already been done to death?

Let me know...

Anthony
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 3rd Jan 2004 07:29
post it...i would like to see it

apmoh
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location:
Posted: 4th Jan 2004 09:03
Ok, but there are some caveats. First, all this prog does is load a .ter file and let you fly around. Well it does some other things but it is primarally a testbed for fooling around with the terrain. Second, it is not perfect, you can occaisionally see updates at the edges of the screen especially when you are travelling diagonally (prog has to update two edges of matrix and things get visible). Third, there are some limitations, some arbitrary, some because I'm lazy, none I think are insurmountable, but heh!

As far as the Terragen terrain is concerned:

1. it must be square (i.e. I only look at the SIZE chunk and ignore the XPTS and YPTS chunks)

2. I ignore the SCAL chunk and assume a scaling of 30m per sample (the Terragen default, and coincidentally a convenient scaling for a 50x50 matrix)

3. I have hard-coded a ceiling of 300m for flying around to keep from flying through the skydome. Your terrain should probably have a max altitude of somewhere around 300m. In the terrain I included there are some peaks to the SE that barely exceed 300m. If you cruise over them you'll get temporarily popped above 300m.

4. At this time I have only tested with the one terrain. Should work (or at least be workable) with other terrains (esp. other sizes) but I don't know yet.

5. The download is big - you are getting a snapshot of what I have been working with and currently all my bitmaps are .bmp and not .jpg. The zip weighs in a cool megabyte.

6. The system I am using to texture the matrix could best be described as goofy. It is actually quite simple in practice and I suspect a holy terror to descibe to some one else. Any ideas on how to improve this would be greatly appreciated.

7. The texturing system relies on a bitmap called texture_map.bmp. If you load it into a paint program it will look totally black. It is actually a 16-color image with pallet entries like rgb(1,1,1), rgb(2,2,2), rgb(3,3,3)... rgb(16,16,16). It was created by taking the texture_256.bmp (which was created by rendering the terrain in Terragen) and converting it to a 16-color image. Then the pallet was edited and the first pallet entry was changed to rgb(1,1,1), etc. Then by loading this image (actually I load the image and keep only the red channel to save memory) I can use this information to index my terrain texture (texture.bmp). Get it?

8. Because of the texture_map.bmp load, the program HAS to run in a 32-bit display mode. DB doesn't load a bmp as stored, but converts it to the current display mode. If the display mode is 16 bits then the color information get screwed. I can think of at least one way around this, but this whole system has gotten goofy enough.

Ok, now to the fun stuff...

Controls are kinda goofy as well, come from bolting on stuff as I thought of it.

The cursor keys are move forward, back, sidestep right and left.

Right-clicking the mouse turns on and off mouselook. Mouselook is the only way to turn. Probably no reason not to leave mouselook on all the time except occaisionally I like to turn it off so don't have to worry about joggling the mouse.

The scrollwheel will run up forward or backward velocity. Clicking the scrollwheel stops you dead in the water.

Left-click will level the camera

A and Z (or a and z) will lift and lower the camera.

Holding the shiftkey while using the arrow keys will double your speed.

I started out using relatively arbitrary values for speed, but I wanted some values that were at least somewhat realistic. 25m/s works out to about 55mph and that is the base 'walking' speed (yeah, I know, realistic eh?). Pressing the shift key doubles that to 50m/s. Pressing the 's' key brings up a very crude throttle. Everything stops and waits for you to press a number key (1-0 where 0=10). This number divided by 10 is a modifier to the whole speed thing, which is defaulted around 5, so if you press 0 (10) then every thing doubles and your max speed is 100m/s. This is what I envision as maximum safe speed. However, this is supposed to be fun, so hitting the spacebar toggles a 'turbo' boost.

When you start the program, you'll be looking at an axis jack which marks the center of the terrain and has x and z coords of zero (y is 2m above terrain). Pressing 'L' for 'look' will point the camera at the axis jack so you don't get lost. The default is to just point the camera. This is fast and accurate, but it can be disorienting if you are not sure what direction you are facing to begin with. Pressing 'm' will toggle a different method that uses curveangle to spin the camera around. It is not always totally accurate and shouldn't be used when you are zooming around close to the jack, but it gives you a better feel for where you were headed.

'P' will page through some text overlays of info. I find that text is a real hog to put on the page, so try to do without it. The controls get pretty jerky when text is being displayed.

A note about the velocity shown on the first info page. It is only accurate for the scroll wheel. When you are at rest, what is displayed is the potential velocity if you pressed the up arrow. It doesn't recognize the shift key.

'W' displays the frame rate in the lower right corner.

'K' controls the dome - the states are dome & fog, no dome & fog, no dome & no fog.

'F' toggles a freeze of the matrix. You can then move off the matrix, and press 'f' again and watch a whole bunch of updates happen.

That's about it...

You can download it at: http://space-available.com/terra/terra2.zip

Have fun,

Anthony
apmoh
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location:
Posted: 4th Jan 2004 17:06
I forgot two of the most important restrictions.
The program is hard coded to use matrix 1, and the matrix must be square.

Anthony
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 4th Jan 2004 23:58
alright, i'll take a looksie when i have time....prolly tomarrow

Login to post a reply

Server time is: 2025-06-07 11:20:17
Your offset time is: 2025-06-07 11:20:17