Class GeoMap

java.lang.Object
com.jme3.terrain.GeoMap
All Implemented Interfaces:
com.jme3.export.Savable
Direct Known Subclasses:
LODGeomap

public class GeoMap extends Object implements com.jme3.export.Savable
Constructs heightfields to be used in Terrain.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected float[]
     
    protected int
     
    protected int
     
    protected int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    GeoMap(float[] heightData, int width, int height, int maxval)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    com.jme3.scene.Mesh
    createMesh(com.jme3.math.Vector3f scale, com.jme3.math.Vector2f tcScale, boolean center)
     
    int
    Returns the height of this Geomap
    float[]
     
    int
     
    com.jme3.math.Vector2f
    getUV(int x, int y, com.jme3.math.Vector2f store)
     
    com.jme3.math.Vector2f
    getUV(int i, com.jme3.math.Vector2f store)
     
    float
    getValue(int i)
    Returns the height value at the given index.
    float
    getValue(int x, int y)
    Returns the height value for a given point.
    int
    Returns the width of this Geomap
    boolean
    Returns true if the Geomap data is loaded in memory If false, then the data is unavailable- must be loaded with load() before the methods getHeight/getNormal can be used
    void
    read(com.jme3.export.JmeImporter im)
     
    void
    write(com.jme3.export.JmeExporter ex)
     
     
    writeNormalArray(FloatBuffer store, com.jme3.math.Vector3f scale)
    Creates a normal array from the normal data in this Geomap
    writeTexCoordArray(FloatBuffer store, com.jme3.math.Vector2f offset, com.jme3.math.Vector2f scale)
     
    writeVertexArray(FloatBuffer store, com.jme3.math.Vector3f scale, boolean center)
    Creates a vertex array from the height data in this Geomap The scale argument specifies the scale to use for the vertex buffer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • hdata

      protected float[] hdata
    • width

      protected int width
    • height

      protected int height
    • maxval

      protected int maxval
  • Constructor Details

    • GeoMap

      public GeoMap()
    • GeoMap

      public GeoMap(float[] heightData, int width, int height, int maxval)
  • Method Details

    • getHeightArray

      public float[] getHeightArray()
    • getMaximumValue

      public int getMaximumValue()
      Returns:
      The maximum possible value that getValue() can return. Mostly depends on the source data format (byte, short, int, etcetera).
    • getValue

      public float getValue(int x, int y)
      Returns the height value for a given point. MUST return the same value as getHeight(y*getWidth()+x)
      Parameters:
      x - the X coordinate
      y - the Y coordinate
      Returns:
      an arbitrary height looked up from the heightmap
      Throws:
      NullPointerException - If isLoaded() is false
    • getValue

      public float getValue(int i)
      Returns the height value at the given index. zero index is top left of map, getWidth()*getHeight() index is lower right
      Parameters:
      i - The index
      Returns:
      an arbitrary height looked up from the heightmap
      Throws:
      NullPointerException - If isLoaded() is false
    • getWidth

      public int getWidth()
      Returns the width of this Geomap
      Returns:
      the width of this Geomap
    • getHeight

      public int getHeight()
      Returns the height of this Geomap
      Returns:
      the height of this Geomap
    • isLoaded

      public boolean isLoaded()
      Returns true if the Geomap data is loaded in memory If false, then the data is unavailable- must be loaded with load() before the methods getHeight/getNormal can be used
      Returns:
      whether the geomap data is loaded in system memory
    • writeNormalArray

      public FloatBuffer writeNormalArray(FloatBuffer store, com.jme3.math.Vector3f scale)
      Creates a normal array from the normal data in this Geomap
      Parameters:
      store - A preallocated FloatBuffer where to store the data (optional), size must be >= getWidth()*getHeight()*3
      Returns:
      store, or a new FloatBuffer if store is null
      Throws:
      NullPointerException - If isLoaded() or hasNormalmap() is false
    • writeVertexArray

      public FloatBuffer writeVertexArray(FloatBuffer store, com.jme3.math.Vector3f scale, boolean center)
      Creates a vertex array from the height data in this Geomap The scale argument specifies the scale to use for the vertex buffer. For example, if scale is 10,1,10, then the greatest X value is getWidth()*10
      Parameters:
      store - A preallocated FloatBuffer where to store the data (optional), size must be >= getWidth()*getHeight()*3
      scale - Created vertexes are scaled by this vector
      Returns:
      store, or a new FloatBuffer if store is null
      Throws:
      NullPointerException - If isLoaded() is false
    • getUV

      public com.jme3.math.Vector2f getUV(int x, int y, com.jme3.math.Vector2f store)
    • getUV

      public com.jme3.math.Vector2f getUV(int i, com.jme3.math.Vector2f store)
    • writeTexCoordArray

      public FloatBuffer writeTexCoordArray(FloatBuffer store, com.jme3.math.Vector2f offset, com.jme3.math.Vector2f scale)
    • writeIndexArray

      public IntBuffer writeIndexArray(IntBuffer store)
    • createMesh

      public com.jme3.scene.Mesh createMesh(com.jme3.math.Vector3f scale, com.jme3.math.Vector2f tcScale, boolean center)
    • write

      public void write(com.jme3.export.JmeExporter ex) throws IOException
      Specified by:
      write in interface com.jme3.export.Savable
      Throws:
      IOException
    • read

      public void read(com.jme3.export.JmeImporter im) throws IOException
      Specified by:
      read in interface com.jme3.export.Savable
      Throws:
      IOException