I have juste a question about the last version of irrlicht (0.9)
Is there a function to get the height of the terrain generate with TerrainSceneNode at the point (x,z)?
Thank for your help
Can we get the height of the terrain at (x,z) coordinate??
Not a direct function.
You can get it using a triangle selector and getting a line intersection point.
Or, if you just want the height at a specific vertex, you could get the Y position value by getting the meshBuffer. To figure out the index for a specific vertex, you would multiply X * the width of your heightmap and then adding Y.
You can get it using a triangle selector and getting a line intersection point.
Or, if you just want the height at a specific vertex, you could get the Y position value by getting the meshBuffer. To figure out the index for a specific vertex, you would multiply X * the width of your heightmap and then adding Y.
I just wrote some code for something similar. I was trying to determine the distance of my object in the air from the terrain below.
I used a raycast to determine the distance. This same method could be used to determine the height of the terrain as well.
Just another approach to the problem, thought I'd mention it. Not sure what the best way would be though.
Here's my code if you're interested:
I used a raycast to determine the distance. This same method could be used to determine the height of the terrain as well.
Just another approach to the problem, thought I'd mention it. Not sure what the best way would be though.
Here's my code if you're interested:
Code: Select all
f32 GroundDistance(ISceneNode *node)
{
vector3df start = node->getPosition();
vector3df end = start;
end.Y=end.Y-1000;
triangle3df triangle;
line3d<f32> line(start, end);
smgr->getSceneCollisionManager()->getCollisionPoint(line, terrainSelector, end, triangle);
f32 distance = (start.Y-end.Y);
return distance;
}
About the Spintz idea
Hi Spintz,
It your methods works with a scaled terrain??? I don't know how it's work when we scalled the terrain.
Some code exemple will be very helpfull
Thank for your help
It your methods works with a scaled terrain??? I don't know how it's work when we scalled the terrain.
Some code exemple will be very helpfull
Thank for your help
.: Franck :.
I would love to know the answer to the original question. I dont get that GroundDistance function to work. It gives me 1000 as return which is crazy, and all stuff in it seemes to be correctly set up.
What we need is something like this:
float getTerrainHeight(float x,float y);
Is it possible to do? Thanx
Suliman
What we need is something like this:
float getTerrainHeight(float x,float y);
Is it possible to do? Thanx
Suliman
It is possible to do, however it's not efficient at all. It would require the terrain node to maintain it's own selector of it's data and recalculating that selector every time the terrain is scaled.
The terrain will not always be used with Irrlicht collision, so doing this wouldn't really make sense.
The function posted in this forum will work, as long as your test line intersects with the terrain.
The terrain will not always be used with Irrlicht collision, so doing this wouldn't really make sense.
The function posted in this forum will work, as long as your test line intersects with the terrain.
Here ya go
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=7363
ok, you get the value of the pixel in the heightmap, but that will give you the height of map, plus it's very fast and easy to use. Hell, i got it to work!
Beam
http://irrlicht.sourceforge.net/phpBB2/ ... php?t=7363
ok, you get the value of the pixel in the heightmap, but that will give you the height of map, plus it's very fast and easy to use. Hell, i got it to work!
Beam