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.
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…