Get value from bitmap?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Beam

Get value from bitmap?

Post by Beam »

Hi

I use a terrainnode for my map and need to get values from the heightmap, is it possible? like at 421,231 the color is so and so.

Thanks
Beam
kmleonix
Posts: 4
Joined: Thu May 12, 2005 7:22 pm

Post by kmleonix »

It's possible and you have a nice exemple with the class CTerrainSceneNode.

Code: Select all

IImage* heightMap = driver->createImageFromFile("heightmap.bmp");
video::SColor c = heightMap->getPixel(421,231);
Beam

Post by Beam »

Cool! Easy enough.

I'll think it'll be fast enough to use for positioning units right? As long as I only run the first line before I start main loop and then use only the second line often (accessing files is rather slow i've learned)

Thank you
Beam

Post by Beam »

For the interessted, the method is extremely fast. I run it 5000 times per second with a drop from 136 fps to 134 fps. Fast enough for me.

Beam
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

You just need to be weary of the scaling of the terrain. If the terrain scale is 1, 1, 1, then pixel 500,500 is game unit 500,500. However, if you scale your terrain, you'll have to keep multiply scale of the terrain by the position from the heightmap to get the same game unit.
Image
Post Reply