Hello everybody.
I would like to create randomly positioned objects on the scene from file (j3o/.xml). I can do that, but i want place objects on the surfaces (ground, roofs etc.). My scene is a small village. I know i can use getHeight() method with Terrain type but i don’t know how should i get height (y) in specified point (x,z) for Spatial, Geometry,Node or cast to Terrain.
Here is my actual code (fragments). I used fixed y coordinate:
private void makeCubes(int number) {
for (int i = 0; i < (int) number; i++) {
Vector3f loc = new Vector3f(
FastMath.nextRandomInt(-40, 40), 1.5f,FastMath.nextRandomInt(-40, 40));
Geometry geom = myBox("Cube" + i, loc, ColorRGBA.randomColor());
itemsNode.attachChild(geom);
}
}
makeCubes(40);
Thank you for all replies!