We have seen how to generate a terrain from a heightmap using ImageBasedHeightMap
or the SDK. This type of terrain is the one that you have most control over, and you will probably use it most often. jMonkeyEngine can also generate a random heightmap if you need a quick and dirty solution.
Perform the following steps to generate a simple random heightmap for a hilly terrain:
Return to your copy of
TerrainSimple.java
.Comment out the line that generates the
ImageBasedHeightMap
.Add a line that generates a
HillHeightMap
.AbstractHeightMap heightmap = null; try { // heightmap = new ImageBasedHeightMap(// heightMapImage.getImage(), .5f ); heightmap = new HillHeightMap(1025,500,50,100,(byte)3); heightmap.load(); } catch (Exception e) { e.printStackTrace(); }
Keep the rest of the code.
Run the code. You see a random terrain with lots of round hills. Don't be surprised if the texture-splatting material that you re-used from the heightmap-based terrain...