TerrainBlock - getNormal for given x & z?

My game needs objects placed and aligned on the terrain. This would be achievable if the terrain block had a method to return the normal for a given location (using x & z). I'm not sure how I would then use this (still learning the basics of 3D) but it would be useful. Thoughts anyone?

Well you say alligned with the terrain but i don't know if you really want a tree sticking out at a 45 degree angle of the terrain(like on a hump) besides the fact it's highly unlikly most plants grow against gravity, ever wonder why you never have to worry about which way you place a seed in the ground.  But with normals you shader lighting(per-vertex or per-pixel) like diffused,spectual(which is no use if this is infact a outdoors map).  Good luck to you if you have any question on shaders i'm your man.

I'm not thinking of trees, or shaders. But thanks all the same.

When I hit the 6th tutorial, I am going to be orienting the vehicle to the terrain slope. So, I'll make a general solution and migrate it to the terrain system. It's the tutorial after next, so hopefully, it will be done by the end of this week.

Cool - looking forward to it. Thanks.

Added by Renanse:



TerrainPage and TerrainBlock - getSurfaceNormal(…);

Spatial - rotateUpTo(Vector3f);



so you can do something like:


terrain.getSurfaceNormal(player.getLocalTranslation, normalStorage);
if(normalStorage != null) {
    player.rotateUpTo(normalStorage);
}