com.jme3.terrain.heightmap
Class ImageBasedHeightMap
java.lang.Object
com.jme3.terrain.heightmap.AbstractHeightMap
com.jme3.terrain.heightmap.ImageBasedHeightMap
- All Implemented Interfaces:
- HeightMap, ImageHeightmap
public class ImageBasedHeightMap
- extends AbstractHeightMap
- implements ImageHeightmap
ImageBasedHeightMap
is a height map created from the grayscale
conversion of an image. The image used currently must have an equal height
and width, although future work could scale an incoming image to a specific
height and width.
Method Summary |
protected float |
calculateHeight(float red,
float green,
float blue)
Get the grayscale value, or override in your own sub-classes |
protected float |
getHeightAtPostion(java.nio.ByteBuffer buf,
Image image,
int position,
ColorRGBA store)
|
boolean |
load()
Loads the image data from top left to bottom right |
boolean |
load(boolean flipX,
boolean flipY)
|
void |
setImage(Image image)
|
Methods inherited from class com.jme3.terrain.heightmap.AbstractHeightMap |
erodeTerrain, findMinMaxHeights, flatten, getHeightMap, getInterpolatedHeight, getScaledHeightAtPoint, getScaledHeightMap, getSize, getTrueHeightAtPoint, normalizeTerrain, save, setHeightAtPoint, setHeightScale, setMagnificationFilter, setSize, smooth, smooth, unloadHeightMap |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
colorImage
protected Image colorImage
ImageBasedHeightMap
public ImageBasedHeightMap(Image colorImage)
- Creates a HeightMap from an Image. The image will be converted to
grayscale, and the grayscale values will be used to generate the height
map. White is highest point while black is lowest point.
Currently, the Image used must be square (width == height), but future
work could rescale the image.
- Parameters:
colorImage
- Image to map to the height map.
ImageBasedHeightMap
public ImageBasedHeightMap(Image colorImage,
float heightScale)
setImage
public void setImage(Image image)
load
public boolean load()
- Loads the image data from top left to bottom right
- Specified by:
load
in interface HeightMap
- Returns:
- true if the load was successful, false otherwise.
calculateHeight
protected float calculateHeight(float red,
float green,
float blue)
- Get the grayscale value, or override in your own sub-classes
load
public boolean load(boolean flipX,
boolean flipY)
getHeightAtPostion
protected float getHeightAtPostion(java.nio.ByteBuffer buf,
Image image,
int position,
ColorRGBA store)