I think that the following is failing:
TrianglePatches.TrianglePatchArray.Box.intersectsWithLine(line)
This explains why objects placed using this mechanism aren't always placed on the terrain, but at a Y value of zero.
Version 0.12
Code: Select all
float getHeightAt( scene::ITriangleSelector* selector,
scene::ISceneCollisionManager* scmgr,
float x, float z)
{
// Create a line and get the point it intersects with
the terrain
core::line3d<f32> myline;
core::triangle3df tri;
core::vector3df intersection;
f32 terrainHeightAtPointXZ;
// Make sure the start.Y is higher than the highest
point of your terrain
// Make sure the end.Y is lower than the lowest point
of your terrain
myline.start = core::vector3df ( x, 5000.0f, z );
myline.end = core::vector3df ( x, -5000.0f, z );
if ( scmgr->getCollisionPoint ( myline, selector,
intersection, tri ))
{
terrainHeightAtPointXZ = intersection.Y;
}
return terrainHeightAtPointXZ;
}