Heightmap idea...


I’m thinking about doing a strategy engine, I want to use heightmaps, quadtrees or octrees or something like that… And I tought that I could do some own heightmap system that works like this:

RGBA, Alpha is the height, so high alpha value means higher y coord… Then I could use the colors to split the map into different parts…

Like this:

You read all the pixels, and then you bind a texture and draw all the vertexes with a specific color (e.g. 1.0f, 0.0f, 0.0f) and then you map another texture and draw all the vertexes with that color and so on, this way, I could do water, land, mountain and so on… And then I could do so the boates just could go on that specific color and so on… :stuck_out_tongue:

Will this work? Does this seem like a good idea? I’m not sure, but I want YOUR opinion, so plz, start posting.

Question: If I would do like this, when I draw the vertexes which type should I use glBegin(???) GL_POLYGON or GL_TRIANGLE_STRIP or what???

I dont know about calling glTexCoord3fv(…) with RGBA data… shouldn’t be a problem (just use the values, not the arrays)

as for it being a good idea, it almost seems like any memory gain you get by using the alpha would be offset by the three value colouring system…

If you want to distinguish between different types of landcover, you would be better off checking against a single value, rather than three.

Assuming your y coordinate it up, you can store the heightfield data with only 2 values - height and terrain type. The x and z coordinates are implicit given the already known size of the heightfield.

That said, if you want to do funky coloured lighting across the whole terrain, (which could make for some very cool game mechanics - like colour trails for players, almost a visual form of smell, or projectile flare colouring to distinguish the type of projectile) your technique would be ideal!

I guess the best way to find out is to load a 32 bit tga and start mucking around with it, see what works and what doesnt!

Good luck

CyBBe: I think your idea sounds nice, and the glBegin(GL_POLYGON) should work…

Your idea is cool. However due to the amount of points a terrain usually implies you should be careful with the memory usage if you’re going to store a color for each and every vertex.

A lookup table would be an alternative approach.Instead of using 3 values for each point just use one representing the index of the lookup table.

as for GL_XXX, you should try to use strips because these allow you to send more points to the graphic card with less memory transfer. Better still, use vertex arrays.

Antonio www.fatech.com/tech

What do ya mean? What’s a lookup table? I don’t see why it should be faster to use a array with just vertexes than a array with vertexes AND color values… I don’t get it…

Newbie… =)

[This message has been edited by CyBBe (edited 10-13-2000).]