Empty Height Map Implementation

Would anyone be horribly offended if I committed this? Its a very simple height map implementation that just builds an array of 0’s so that flat terrain can be quickly achieved… Good for debugging, I figure this would be useful for people working on their own tile loaders or just want flat, endless terrain :slight_smile:


import com.jme3.terrain.heightmap.AbstractHeightMap;


  • Creates a flat heightmap of a desired size.
  • @author Skye Book



    public class EmptyHeightMap extends AbstractHeightMap {

    private int size;




    public EmptyHeightMap(int size) {

    this.size = size;


  • @see com.jme3.terrain.heightmap.HeightMap#load()



    public boolean load() {

    heightData = new float[size

    for(int i=0; i<(size*size); i++){



    return true;





You can just pass in a float array of zeros directly to the terrain quad constructor if you want it flat, without having to use a heightmap. The heightmaps just are a converter from various data sources to height values using the heightmap.getHeightMap() method.

Also if you do not supply an array to the constructor, it will create an empty/flat heightmap for you.

Ah, excellent!

Gonna have a look at the source now :slight_smile:

Edit: Well played, @sploreg… well played.