j3d.org Code

org.j3d.terrain
Interface TerrainData

All Superinterfaces:
HeightDataSource
All Known Subinterfaces:
FreeFormTerrainData, StaticTerrainData, TiledTerrainData
All Known Implementing Classes:
AbstractFreeFormTerrainData, AbstractStaticTerrainData, AbstractTerrainData, AbstractTiledTerrainData, HeightMapTerrainData, SimpleTiledTerrainData

public interface TerrainData
extends HeightDataSource

This class provides a generic interface to the terrain dataset.

The dataset is represented as a regular grid of heights which use the carto-based notion of the ground being the X-Y plane, rather than the 3D graphics convention of X-Z. In all cases, the access to this data is assumed to be in a grid pattern. If the source data comes from non-uniform sources, such as spot heights, then it will need to be accessible/interpolated to fit the grid nature of the access routines.

Note: You should never directly implement this interface. It is expected by the rendering algorithms that one of the derived types will always be used.

Version:
$Revision: 1.9 $
Author:
Justin Couch based on original ideas of Paul Byrne

Field Summary
static int FREEFORM_DATA
          The source data comes in free-form data that may be accessed any way that the terrain rendering algorithm likes.
static int STATIC_DATA
          The source data type is a simple, static terrain
static int TILED_DATA
          The source data comes in the form of tiles that may be dynamically loaded.
 
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[] tex, int gridX, int gridY, int patchX, int patchY)
          Get the coordinate of the point and corresponding texture coordinate in the grid.
 double getGridXStep()
          Get the real world distance between consecutive X values in the grid.
 double getGridYStep()
          Get the real world distance between consecutive Y values in the grid.
 float getHeightFromGrid(int gridX, int gridY)
          Get the height at the specified grid position.
 int getSourceDataType()
          Get the type of terrain data that we are dealing with.
 boolean hasColor()
          Check to see if this terrain data has per-vertex colours.
 boolean hasTexture()
          Check to see if this terrain data has any texturing at all - either tiled or simple.
 
Methods inherited from interface org.j3d.ui.navigation.HeightDataSource
getHeight
 

Field Detail

STATIC_DATA

static final int STATIC_DATA
The source data type is a simple, static terrain

See Also:
Constant Field Values

TILED_DATA

static final int TILED_DATA
The source data comes in the form of tiles that may be dynamically loaded. The most efficient way to use this data is to align the accesses according to the tile boundaries.

See Also:
Constant Field Values

FREEFORM_DATA

static final int FREEFORM_DATA
The source data comes in free-form data that may be accessed any way that the terrain rendering algorithm likes.

See Also:
Constant Field Values
Method Detail

getSourceDataType

int getSourceDataType()
Get the type of terrain data that we are dealing with. One of the constant types are returned. More efficient way of dealing with multiple types than using instanceof

Returns:
The type of data that this instance represents

getCoordinate

void getCoordinate(float[] coord,
                   int gridX,
                   int gridY)
Get the coordinate of the point in the grid. This should translate between the grid position (x,y) and the 3D axis system (x,y,z), which don't use the same coordinate system.

Parameters:
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 grid
gridY - The Y coordinate of the position in the grid

getCoordinate

void getCoordinate(float[] coord,
                   float[] tex,
                   float[] color,
                   int gridX,
                   int gridY)
Get the coordinate with all the information - texture and colors.

Parameters:
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 elements
color - 3 component colors are placed in the first 3 elements
gridX - The X coordinate of the position in the grid
gridY - The Y coordinate of the position in the grid

getCoordinateWithTexture

void getCoordinateWithTexture(float[] coord,
                              float[] tex,
                              int gridX,
                              int gridY,
                              int patchX,
                              int patchY)
Get the coordinate of the point and corresponding texture coordinate in the grid. Assumes that the grid covers a single large texture rather than multiple smaller textures. This should translate between the grid position (x,y) and the 3D axis system (x,y,z), which don't use the same coordinate system.

Parameters:
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 elements
gridX - The X coordinate of the position in the grid
gridY - The Y coordinate of the position in the grid

getCoordinateWithColor

void getCoordinateWithColor(float[] coord,
                            float[] color,
                            int gridX,
                            int gridY)
Get the coordinate of the point and the corresponding color value in the grid. Color values are used when there is no texture supplied, so this should always provide something useful.

Parameters:
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 elements
gridX - The X coordinate of the position in the grid
gridY - The Y coordinate of the position in the grid

hasColor

boolean hasColor()
Check to see if this terrain data has per-vertex colours. Colour may be used with or separately from the texture data. This allows you to use colours to modulate the texture information if desired. Note that if you provide per-vertex colour information here, you need to be careful with the appearance information that gets set if you provide a custom appearance implementation.

Returns:
true If per-vertex color is available

hasTexture

boolean hasTexture()
Check to see if this terrain data has any texturing at all - either tiled or simple.

Returns:
true If a texture(s) is available

getHeightFromGrid

float getHeightFromGrid(int gridX,
                        int gridY)
Get the height at the specified grid position.

Parameters:
gridX - The X coordinate of the position in the grid
gridY - The Y coordinate of the position in the grid
Returns:
The height at the given grid position

getGridXStep

double getGridXStep()
Get the real world distance between consecutive X values in the grid.

Returns:
The distance between each step of the grid

getGridYStep

double getGridYStep()
Get the real world distance between consecutive Y values in the grid.

Returns:
The distance between each step of the grid

j3d.org Code

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