Get the height of an terrain

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
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Get the height of an terrain

Post by Peter Müller »

Hi!
Is it possible to get the height of an terrain, which is loaded with ISceneManager::addTerrainMesh(...)?

I tried already to use an ITerrainSceneNode, but the getHeight method always returns flase :?

I hope, somebody can help me.
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

it should work with:

...
buffer = terrainmesh->getMesh(0)->getMeshBuffer(0);
video::S3DVertex* v = (video::S3DVertex*)buffer->getVertices();
height=v[0].Pos.Y
...
and so on
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

And how do I know, which index I have to set into

Code: Select all

height=v[0].Pos.Y
?
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
knightoflight
Posts: 199
Joined: Sun Aug 24, 2003 5:47 pm
Location: Germany

Post by knightoflight »

if you would test for example with a 4x4 heightmap, you would see that in case of this irrlicht-command
v[0]-v[3] are the first row, v[4]-v[7] the next and so on, easy to use with two for-loops
for( int x = 0; x < 4; x++ )
{
for( int z = 0; z < 4; z++ )
{
height=v[x+z*4];
}
}

ok ?
Peter Müller
Posts: 292
Joined: Sun Mar 14, 2004 5:28 pm
Location: Germany
Contact:

Post by Peter Müller »

Ah, thanks, I understood!
http://www.games-forge.de - Die Community für Nachwuchsprogrammierer
Post Reply