j3d.org Code

org.j3d.geom.terrain
Class HeightDataCreator

java.lang.Object
  extended by org.j3d.geom.terrain.HeightDataCreator

public class HeightDataCreator
extends java.lang.Object

A converter utility for changing an image into a height field set of data points.

To translate an image to a height field, the width of the image (X values) translates to the width of the geometry. The height of the image (Y values) is translated to the depth of the terrain. A terrain is always generated in the X-Z plain and height values along the Y axis.

Version:
$Revision: 1.2 $
Author:
Justin Couch

Constructor Summary
HeightDataCreator()
          Create a default data creator with the min and max heights set to 0 and 1.
HeightDataCreator(float min, float max)
          Create a data creator that has the minimum and maximum heights set but uses the default spacing of the cells.
 
Method Summary
 float[][] createHeightField(java.awt.image.BufferedImage img)
          Convert an image into a set of terrain points.
 void setHeightRange(float min, float max)
          Set the height range values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HeightDataCreator

public HeightDataCreator()
Create a default data creator with the min and max heights set to 0 and 1.


HeightDataCreator

public HeightDataCreator(float min,
                         float max)
Create a data creator that has the minimum and maximum heights set but uses the default spacing of the cells.

Parameters:
min - The minimum height of the image
max - The maximum height of the image
Throws:
java.lang.IllegalArgumentException - The minimum was greater than max
Method Detail

setHeightRange

public void setHeightRange(float min,
                           float max)
Set the height range values.

Parameters:
min - The minimum height of the image
max - The maximum height of the image
Throws:
java.lang.IllegalArgumentException - The minimum was greater than max

createHeightField

public float[][] createHeightField(java.awt.image.BufferedImage img)
Convert an image into a set of terrain points. Ideally, the image should be a greyscale image, but color images are fine. Internally, we convert the color into a greyscale and then use that as the basis for creating the elevation grid.

Range values are taken according to the preset values supplied elsewhere.

Parameters:
img - The image to convert
Returns:
A height field matching the image

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org