PDA

View Full Version : Height field



09-16-2004, 12:10 AM
Hi! I have a question about reading height field maps. I'm trying to make a terrain visualisation and put there some buildings, etc.

I found quiet lot code samples how to make triangle strips, but I'm having problems with opening and reading the .bmp file. I'm coding in C++. If you have any good solutions, how to get pixels from file, I would realy appreciate it.

Thanks in advance!

09-16-2004, 03:55 AM
hey piotr, kinda OT, but check this out:
http://www.gamedev.net/reference/articles/article1966.asp

found this with a google for "load a bitmap", page 2 ;)

09-16-2004, 08:49 AM
I'm looking for some method to get the value of pixel color. The .bmp file should be in grey scale, and of course the darker pixel, the higher terrain. I worked out something like this, but it's not working:


void __fastcall TFormMain::SetupTextures()
{
bitmap = new Graphics::TBitmap; //ladowane tylko raz
bitmap->LoadFromFile("teren.bmp");

for(int i = 0; i < 32; i++)
{
for(int j = 0; j < 32; j++)
{
height_field[i][j][0]= float(i)*step;
height_field[i][j][1]= (float)(bitmap->Canvas->Pixels[i][j])[(i*(AREA_SIZE+j)*3];
height_field[i][j][2]= -float(i)*step;

}
}
The line with Canvas is wrong, but I don't know how to make it work... :(

greg2
09-17-2004, 11:32 AM
Nehe has a source code to load .bmp, .gif and .jpg files with IPICTURE (under Windows).

The code change the color of the pixels in order to convert rbg to rgb.

You can use this example to find the color of a pixel.