This is something rather simple with jME2, the TerrainBlock class contains a method getSurfaceNormal() which return the normal vector for any arbitrary point on a terrain. Is the something similar in TerraMonkey? I can’t seem to find it.
Thanks
So I came up with using ray picking and return the normal of the intersection point, as follows:
[java]
public Vector3f getNormal(double x, double z) {
// create a vertical ray that intersects with the terrain,
// then pick the triangle and return the normal.
Ray ray = new Ray(new Vector3f((float)x, getHeight(x, z)-10, (float)z), Vector3f.UNIT_Y);
CollisionResults results = new CollisionResults();
picker.getTerrainIntersection(ray, results);
if (results.size() > 0) {
return results.getClosestCollision().getContactNormal();
} else {
return null;
}
}
[/java]
Any potential problems with this solution?