How do I do Height Mapping???

Started by
8 comments, last by CodePlayEatSleep 23 years, 11 months ago
Okay, my upcomming project will feature top-down terrain with simulated elevation. I play on doing something like this: Draw a terrain map. Then divide the map into little tiles (inside my editor) and place a number (or any other kind of information) inside that tile array, for example like 1,2,3. 1 being the lowest and 3 the highest. So when the player is at array[2][3] the game check the height information in that array and render the player accordingly. Any better ideas? Thanks Also, it''s going to be 2D, my next next project will be in 3D, hopefully. ThnXXXXXXX Yours Truly... Code sleep get drunk..whoaa???
Advertisement
If it''s top down, what is the visual difference between being at height 1 and height 2?
Maybe the player will be drawn bigger .

-Icarus

Edited by - Icarus on 5/3/00 7:13:06 PM
-Andreas
Hi CodePlayEatSleep, (nice name, by the way)

I would suggest using bitmaps for any type of terrain mapping, as they are so easy to edit.

For example, you can use a greyscale bitmap to represent your heightmap (white = highest, black = lowest). You could use a coloured bitmap to represent what texture each tile should have (blue = water texture, dark green = grass texture, light green = thin grass texture, etc). The applications are virtually endless...

I use bitmaps for these purposes in my 3D terrain engine, and they work a treat. The cool thing is that for more natural looking terrain, you can say, start with a mid-level grey bitmap (smack in the middle of the height range), just spray some darker pixels where you want a valley/canyon, throw on some lighter pixels for a few hills/mountains/plateaus, and then run some smoothing filters over it to make nice curvy goodness. Also, you can use noise filters to generate random heightmaps that you can just use straight away, or use as a starting point to modify.

Yes, grasshopper, bitmaps will bring you peace.



-------------
squirrels are a remarkable source of protein...
How would you go about rendering those heightmaps?
I''ve always understood the idea of heightmaps, but I could never actually implement them because I didn''t know how to render the polygons right
Thank you for the responses.

Okay, what means is how do I , ummm, how do I tell my program to reconize the bit-map? I already know how to *make* a terrain bit-map, now I want my program to know about my bit-map...ahhhrrhh do you see what I''m saying here?

So I thought up this crazy idea of keeping the height information in a interger array. So the bit-map is divided into little tiles, and the interger array where I keep my height information is the same size as the bit-map. So when I move my guy(any in game object) he checks the array tile he''s in for the height information. Do I make sense?
There is probably a better way to do this...

Anyway my next project will be a turned based squad simulator featuring U.S special forces (Delta Force, Navy Seal, Army Ranger). You control a squadron of speical forces on various operations around the world. Some feature that I want to include are stuff like hiding in a grass, real projetile physics...etc.. I want to make this game as real as possible (to an extend).

0.0000000000000002


Okay, I''m not sure we''re on the same wavelength here. Where is the flaw in your idea?

OK, this is what I was getting at:
- read your bitmap data into a bit fat byte buffer
- each pixel in the bitmap is equivalent to a tile in your world.
- the colour/shade of the pixel defines what height it is (if you use a greyscale bitmap, each of the RGB values are equal, so pick whichever part (R, G, or B) to use as your height value. As it is a byte, the value will be between 0 and 255 - that''s 256 different heights available to you. If you don''t want this many, use a scaling/rounding factor or something)

As you said, just have a 2D array the same size as the bitmap which contains your tiles. To get the height at any particular tile, simply plug in the co-ords of it into the array: playerY = mapArray[playerX][playerZ] (this assumes Y is the vertical axis)

Are we talking about the same thing here?
Sorry if that didn''t make more sense


to DarkAgito:
the quick way to do it is to do as I said above, but instead of each pixel representing a "tile", have it represent a vertex (I assume you mean you want to render the heightfield in 3D), then simply draw a big bunch of quads/triangles using these vertices as the... well, vertices You can toy with ways to draw heightmaps more efficiently with quad/tri strips, merging redundant quads/tris, etc... in fact, the field (sorry about the pun) is enormous, and constantly being researched.


-------------
squirrels are a remarkable source of protein...
Yes, something like that, but of course I have to think it over abit more...thank you very-much :D...

"CyberPimping ain''t easy, I guess a bit cheesy."
I love using different shades of grey to represent diff. heights. I would def. use em. Check the link out, it is a heightmap 3d program I did for fun to learn about heightmaps. It 100% for sure does not work in 24bit mode even though there is a selection, so just use 32bit if your card supports it, cant say that works for sure either. oh well.
heightmap
ao
Play free Java games at: www.infinitepixels.com
Oopsyy, I''m one of those dudes who have a Vodoo3 card in their system, so I can''t run it in 24 or 32 bit mode , could I have the source? If you don''t mind, I will give you full credit if I use your height map code in anyway . Thanks.

This topic is closed to new replies.

Advertisement