com.jme3.terrain
Class GeoMap

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

public class GeoMap
extends java.lang.Object
implements Savable

Constructs heightfields to be used in Terrain.


Field Summary
protected  float[] hdata
           
protected  int height
           
protected  int maxval
           
protected  int width
           
 
Constructor Summary
GeoMap()
           
GeoMap(float[] heightData, int width, int height, int maxval)
           
GeoMap(java.nio.FloatBuffer heightData, int width, int height, int maxval)
          Deprecated. 
 
Method Summary
 Mesh createMesh(Vector3f scale, Vector2f tcScale, boolean center)
           
 int getHeight()
          Returns the height of this Geomap
 float[] getHeightArray()
           
 java.nio.FloatBuffer getHeightData()
          Deprecated. 
 int getMaximumValue()
           
 Vector2f getUV(int x, int y, Vector2f store)
           
 Vector2f getUV(int i, 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 getWidth()
          Returns the width of this Geomap
 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
 void read(JmeImporter im)
           
 void write(JmeExporter ex)
           
 java.nio.IntBuffer writeIndexArray(java.nio.IntBuffer store)
           
 java.nio.FloatBuffer writeNormalArray(java.nio.FloatBuffer store, Vector3f scale)
          Creates a normal array from the normal data in this Geomap
 java.nio.FloatBuffer writeTexCoordArray(java.nio.FloatBuffer store, Vector2f offset, Vector2f scale)
           
 java.nio.FloatBuffer writeVertexArray(java.nio.FloatBuffer store, 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 Detail

hdata

protected float[] hdata

width

protected int width

height

protected int height

maxval

protected int maxval
Constructor Detail

GeoMap

public GeoMap()

GeoMap

@Deprecated
public GeoMap(java.nio.FloatBuffer heightData,
                         int width,
                         int height,
                         int maxval)
Deprecated. 


GeoMap

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

getHeightData

@Deprecated
public java.nio.FloatBuffer getHeightData()
Deprecated. 


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, etc).

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
Throws:
java.lang.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
Throws:
java.lang.NullPointerException - If isLoaded() is false

getWidth

public int getWidth()
Returns the width of this Geomap


getHeight

public int getHeight()
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


writeNormalArray

public java.nio.FloatBuffer writeNormalArray(java.nio.FloatBuffer store,
                                             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
Throws:
java.lang.NullPointerException - If isLoaded() or hasNormalmap() is false

writeVertexArray

public java.nio.FloatBuffer writeVertexArray(java.nio.FloatBuffer store,
                                             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
Throws:
java.lang.NullPointerException - If isLoaded() is false

getUV

public Vector2f getUV(int x,
                      int y,
                      Vector2f store)

getUV

public Vector2f getUV(int i,
                      Vector2f store)

writeTexCoordArray

public java.nio.FloatBuffer writeTexCoordArray(java.nio.FloatBuffer store,
                                               Vector2f offset,
                                               Vector2f scale)

writeIndexArray

public java.nio.IntBuffer writeIndexArray(java.nio.IntBuffer store)

createMesh

public Mesh createMesh(Vector3f scale,
                       Vector2f tcScale,
                       boolean center)

write

public void write(JmeExporter ex)
           throws java.io.IOException
Specified by:
write in interface Savable
Throws:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
Specified by:
read in interface Savable
Throws:
java.io.IOException