j3d.org Code

org.j3d.terrain
Class AbstractTiledTerrainData

java.lang.Object
  extended by org.j3d.terrain.AbstractTerrainData
      extended by org.j3d.terrain.AbstractTiledTerrainData
All Implemented Interfaces:
TerrainData, TiledTerrainData, HeightDataSource
Direct Known Subclasses:
SimpleTiledTerrainData

public abstract class AbstractTiledTerrainData
extends AbstractTerrainData
implements TiledTerrainData

An abstract representation of the base functionality for a TerrainData implementation.

This class provides a lot of the common functionality that all implementations will require. Good to save you typing.

Version:
$Revision: 1.4 $
Author:
Justin Couch

Field Summary
protected  int gridPointsPerTile
          The number of grid points per tile.
protected  TextureTileGenerator tileGenerator
          Reference to the currently set texture tile generator
 
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
protected AbstractTiledTerrainData()
          Create a new instance.of this data class with all flags set to false.
 
Method Summary
protected  int convertGridToTileCoord(int grid)
          Convenience method to convert the grid coordinate to the tile that it belongs in.
protected  int convertTileToGridCoord(int tile)
          Convenience method to convert the tile coordinate to a grid coordinate
 java.awt.image.BufferedImage getTexture(int tileX, int tileY)
          Fetch the texture or part of a texture that can be applied to the sub-region of the overall object.
 int getTileSize()
          Get the number of grid points along one side of a single tile.
 void setTextureTileGenerator(TextureTileGenerator gen)
          Set the texture tile geneattor instance to the new value.
 
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.TiledTerrainData
getTilesAvailableBounds, setActiveBounds
 
Methods inherited from interface org.j3d.terrain.TerrainData
getCoordinate, getCoordinate, getCoordinateWithColor, getCoordinateWithTexture, getGridXStep, getGridYStep, getHeightFromGrid, getSourceDataType, hasColor, hasTexture
 
Methods inherited from interface org.j3d.ui.navigation.HeightDataSource
getHeight
 

Field Detail

tileGenerator

protected TextureTileGenerator tileGenerator
Reference to the currently set texture tile generator


gridPointsPerTile

protected int gridPointsPerTile
The number of grid points per tile.

Constructor Detail

AbstractTiledTerrainData

protected AbstractTiledTerrainData()
Create a new instance.of this data class with all flags set to false.

Method Detail

getTileSize

public int getTileSize()
Get the number of grid points along one side of a single tile.

Specified by:
getTileSize in interface TiledTerrainData
Returns:
The number of points in the size if the grid

getTexture

public java.awt.image.BufferedImage getTexture(int tileX,
                                               int tileY)
Fetch the texture or part of a texture that can be applied to the sub-region of the overall object. This is to allow for texture tiling of very large texture images or terrain items. If there is no texture or no texture for that region, then this should return null.

Specified by:
getTexture in interface TiledTerrainData
Parameters:
tileX - the x coordinate of the tile number for the texture
tileY - the y coordinate of the tile number for the texture
Returns:
The texture object suitable for that bounds or null

setTextureTileGenerator

public void setTextureTileGenerator(TextureTileGenerator gen)
Set the texture tile geneattor instance to the new value. Setting a value of null will clear the current instance. Calling this method with a non-null generator instance does not automatically set the has texture flag.

Parameters:
gen - The new generator instance to use

convertTileToGridCoord

protected int convertTileToGridCoord(int tile)
Convenience method to convert the tile coordinate to a grid coordinate

Parameters:
tile - The tile coordinate
Returns:
The equivalent grid coordinate

convertGridToTileCoord

protected int convertGridToTileCoord(int grid)
Convenience method to convert the grid coordinate to the tile that it belongs in. If the point is exactly on the edge of a grid, the value returned is for the larger tile coordinate.

Parameters:
grid - The grid coordinate
Returns:
The equivalent grid coordinate

j3d.org Code

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