Placing an object on a random point

Hi all!



I have an object that i want to place on a random point over a terrain page. What am i doing?





public void placeFlag() {
        float x = 45 + FastMath.nextRandomFloat() * 130;
        float z = 45 + FastMath.nextRandomFloat() * 130;
        float y = tb.getHeight(x, z);
       
        localTranslation.x = x;
        localTranslation.y = y;
        localTranslation.z = z;
       
    }


But the Y axis value is not what i want. I want correct point height. Because i am using a HillHeightMap, the tb.getHeight(x,z) give me the greatest height.

Any idea?

try getHeightAtPoint(x,y)

But with TerrainPage, i have just getHeight(…) and getHeightFromWorld(…).



my terrain is like follows:



HillHeightMap mapaDeAlturas = new HillHeightMap(129, 250, 2.0f, 20.0f,
(byte) 2);
mapaDeAlturas.setHeightScale(0.001f);
Vector3f terrainScale = new Vector3f(10, 1, 10);
TerrainPage terreno = new TerrainPage("Terreno", 33, mapaDeAlturas
.getSize(), terrainScale, mapaDeAlturas.getHeightMap(), false);
terreno.setDetailTexture(1, 64);


Where terreno is a TerrainPage instance.