Class RawHeightMap

java.lang.Object
com.jme3.terrain.heightmap.AbstractHeightMap
com.jme3.terrain.heightmap.RawHeightMap
All Implemented Interfaces:
HeightMap

public class RawHeightMap extends AbstractHeightMap
RawHeightMap creates a height map from a RAW image file. The greyscale image denotes height based on the value of the pixel for each point. Where pure black the lowest point and pure white denotes the highest.
  • Field Details

    • FORMAT_8BIT

      public static final int FORMAT_8BIT
      Format specification for 8 bit precision heightmaps
      See Also:
    • FORMAT_16BITLE

      public static final int FORMAT_16BITLE
      Format specification for 16 bit little endian heightmaps
      See Also:
    • FORMAT_16BITBE

      public static final int FORMAT_16BITBE
      Format specification for 16 bit big endian heightmaps
      See Also:
  • Constructor Details

    • RawHeightMap

      public RawHeightMap(String filename, int size) throws Exception
      Constructor creates a new RawHeightMap object and loads a RAW image file to use as a height field. The greyscale image denotes the height of the terrain, where dark is low point and bright is high point. The values of the RAW correspond directly with the RAW values or 0 - 255.
      Parameters:
      filename - the RAW file to use as the heightmap.
      size - the size of the RAW (must be square).
      Throws:
      Exception - if the filename is null or not RAW, and if the size is 0 or less.
    • RawHeightMap

      public RawHeightMap(float[] heightData)
    • RawHeightMap

      public RawHeightMap(String filename, int size, int format, boolean swapXy) throws Exception
      Throws:
      Exception
    • RawHeightMap

      public RawHeightMap(InputStream stream, int size, int format, boolean swapxy) throws Exception
      Throws:
      Exception
    • RawHeightMap

      public RawHeightMap(URL resource, int size, int format, boolean swapxy) throws Exception
      Throws:
      Exception
  • Method Details

    • load

      public boolean load()
      load fills the height data array with the appropriate data from the set RAW image.
      Returns:
      true if the load is successful, false otherwise.
      Throws:
      RuntimeException - if the RAW image has not been set
    • setFilename

      public void setFilename(String filename) throws Exception
      setFilename sets the file to use for the RAW data. A call to load is required to put the changes into effect.
      Parameters:
      filename - the new file to use for the height data.
      Throws:
      Exception - if the file is null or not RAW.
    • setHeightStream

      public void setHeightStream(InputStream stream) throws Exception
      setHeightStream sets the stream to use for the RAW data. A call to load is required to put the changes into effect.
      Parameters:
      stream - the new stream to use for the height data.
      Throws:
      Exception - if the stream is null or not RAW.