getHeightFromWorld for TerrainBlock

Everyone that wants to get the height of a point on a TerrainBlock object from World Coordinates will love this patch.



:smiley:



? NewFeature.patch

? build

? loader.sh

? data/doc

? target/META-INF

Index: src/com/jmex/terrain/TerrainBlock.java

===================================================================

RCS file: /cvs/jme/src/com/jmex/terrain/TerrainBlock.java,v

retrieving revision 1.8

diff -r1.8 TerrainBlock.java

231a232,250

>    *

>    * <code>getHeightFromWorld</code> returns the height of an arbitrary point on the

>    * terrain when given world coordinates. If the point is between height point values, the height is

>    * linearly interpolated. This provides smooth height calculations. If the

>    * point provided is not within the bounds of the height map, the NaN float

>    * value is returned (Float.NaN).

>    *

>    * @param position

>                the vector representing the height location to check.

>    * @return the height at the provided location.

>    /

>    public float getHeightFromWorld(Vector3f position) {

>   Vector3f location_pos = position.subtract(getLocalTranslation()).divide(getStepScale());

>   location_pos.multLocal(getStepScale());

>      

>        return getHeight(location_pos.x, location_pos.z);

>    }

>   

>    /

Nice…



Can TerrainPage also be modified too

Added to TerrainBlock and TerrainPage. Thank you!