|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.j3d.terrain.AbstractTerrainData org.j3d.terrain.AbstractTiledTerrainData org.j3d.loaders.SimpleTiledTerrainData
public class SimpleTiledTerrainData
Simplified implementation of the TiledTerrainData
for any file format or loader that supports a static grid based data
structure.
This implementation is pretty dumb in that it does no paging of the internal data and just keeps it available in memory. That should make it useful for grids of up to 2049x2049 heights.
If a color interpolator is not provided, then color is not supported in this terrain (unless set by some implementing class).
Field Summary |
---|
Fields inherited from class org.j3d.terrain.AbstractTiledTerrainData |
---|
gridPointsPerTile, tileGenerator |
Fields inherited from class org.j3d.terrain.AbstractTerrainData |
---|
colorAvailable, gridStepX, gridStepY, textureAvailable |
Fields inherited from interface org.j3d.terrain.TerrainData |
---|
FREEFORM_DATA, STATIC_DATA, TILED_DATA |
Constructor Summary | |
---|---|
SimpleTiledTerrainData(float[][] data,
boolean mustCopy,
javax.vecmath.Point2d stepDetails)
Create a new instance that uses the passed height map data to this loader. |
|
SimpleTiledTerrainData(HeightMapSource source)
Create a new instance that sources the data from the given parser. |
Method Summary | |
---|---|
void |
getCoordinate(float[] coord,
float[] tex,
float[] color,
int gridX,
int gridY)
Get the coordinate with all the information - texture and colors. |
void |
getCoordinate(float[] coord,
int gridX,
int gridY)
Get the coordinate of the point in the grid. |
void |
getCoordinateWithColor(float[] coord,
float[] color,
int gridX,
int gridY)
Get the coordinate of the point and the corresponding color value in the grid. |
void |
getCoordinateWithTexture(float[] coord,
float[] textureCoord,
int gridX,
int gridY,
int patchX,
int patchY)
Get the coordinate of the point and correspond texture coordinate in the grid. |
float |
getHeight(float x,
float z)
Get the height at the given X,Z coordinate in the local coordinate system. |
float |
getHeightFromGrid(int gridX,
int gridY)
Get the height at the specified grid position. |
void |
getTilesAvailableBounds(java.awt.Rectangle bounds)
Fetch the area, in tile coordinates of the area that is currently available in memory. |
void |
setActiveBounds(java.awt.Rectangle bounds)
Set the bounding information, in number of tiles, of the area that the terrain rendering code will be limiting its access to. |
void |
setColorInterpolator(ColorInterpolator interp)
Set up a height color ramp to provide colour information. |
Methods inherited from class org.j3d.terrain.AbstractTiledTerrainData |
---|
convertGridToTileCoord, convertTileToGridCoord, getTexture, getTileSize, setTextureTileGenerator |
Methods inherited from class org.j3d.terrain.AbstractTerrainData |
---|
getGridXStep, getGridYStep, getSourceDataType, hasColor, hasTexture |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.j3d.terrain.TerrainData |
---|
getGridXStep, getGridYStep, getSourceDataType, hasColor, hasTexture |
Constructor Detail |
---|
public SimpleTiledTerrainData(HeightMapSource source)
source
- The place to source the data frompublic SimpleTiledTerrainData(float[][] data, boolean mustCopy, javax.vecmath.Point2d stepDetails)
mustCopy
parameter. If it is not
copied, then the calling code should make sure that it does not change
values in the array after calling this method. If copying, the code
assumes a rectangular grid of points where the second dimension size is
based on data[0].length
.
data
- The source data to use in [length][width] ordermustCopy
- true to request an internal copy be made of the data
false for it to just reference the datastepDetails
- The distance between each height value in the X and
Z coordinates (Y in terrain parlance)Method Detail |
---|
public void getTilesAvailableBounds(java.awt.Rectangle bounds)
The implementation should fill in the passed rectangle with the bounds information. The bounds are inclusive, so if the implementation of this interface provides the value of {0, 0, 2, 2} this will indicate a 3x3 area is available.
bounds
- The bounds of the available data, to be filled in by the
implementation of this classpublic void setActiveBounds(java.awt.Rectangle bounds)
bounds
- The bounds of the area, in tile coordinates, that will be
accessedpublic float getHeight(float x, float z)
x
- The x coordinate for the height samplingz
- The z coordinate for the height sampling
public void getCoordinate(float[] coord, int gridX, int gridY)
coord
- the x, y, and z coordinates will be placed in the
first three elements of the array.gridX
- The X coordinate of the position in the gridgridY
- The Y coordinate of the position in the gridpublic void getCoordinate(float[] coord, float[] tex, float[] color, int gridX, int gridY)
coord
- he x, y, and z coordinates will be placed in the first
three elements of the array.tex
- 2D coordinates are placed in the first two elementscolor
- 3 component colors are placed in the first 3 elementsgridX
- The X coordinate of the position in the gridgridY
- The Y coordinate of the position in the gridpublic void getCoordinateWithTexture(float[] coord, float[] textureCoord, int gridX, int gridY, int patchX, int patchY)
coord
- he x, y, and z coordinates will be placed in the first
three elements of the array.textureCoord
- 2D coordinates are placed in the first two elementsgridX
- The X coordinate of the position in the gridgridY
- The Y coordinate of the position in the gridpublic void getCoordinateWithColor(float[] coord, float[] color, int gridX, int gridY)
coord
- he x, y, and z coordinates will be placed in the first
three elements of the array.color
- 3 component colors are placed in the first 3 elementsgridX
- The X coordinate of the position in the gridgridY
- The Y coordinate of the position in the gridpublic float getHeightFromGrid(int gridX, int gridY)
gridX
- The X coordinate of the position in the gridgridY
- The Y coordinate of the position in the grid
public void setColorInterpolator(ColorInterpolator interp)
interp
- The interpolator instance to use
|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |