Empty Height Map Implementation (3 posts)

Topic tags: heightmap, jME3, terrain
  • Profile picture of sbook sbook255p said 4 months, 2 weeks ago:

    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 :)

    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;
    	}
    
    	/* (non-Javadoc)
    	 * @see com.jme3.terrain.heightmap.HeightMap#load()
    	 */
    	@Override
    	public boolean load() {
    		heightData = new float[size*size];
    
    		for(int i=0; i<(size*size); i++){
    			heightData[i]=0f;
    		}
    
    		return true;
    	}
    
    }
    

    https://github.com/skyebook/TMS3D/blob/master/src/net/skyebook/tms3d/EmptyHeightMap.java

  • Profile picture of Sploreg Sploreg200p said 4 months, 2 weeks ago:

    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.

  • Profile picture of sbook sbook255p said 4 months, 2 weeks ago:

    Ah, excellent!

    Gonna have a look at the source now :)

    Edit: Well played, @sploreg… well played.