jme.locale.external
Class Terrain

java.lang.Object
  extended byjme.locale.external.Terrain
All Implemented Interfaces:
Locale
Direct Known Subclasses:
BruteForce, Geomipmap

public abstract class Terrain
extends java.lang.Object
implements Locale

Terrain defines an abstract class for rendering height map data. The subclass is responsible for setting the height data as well as updating and rendering.

Version:
0.1.0
Author:
Mark Powell

Field Summary
protected  int detailId
          detailId is the texture id for the detail map.
protected  GL gl
          gl the OpenGL context.
protected  AbstractHeightMap heightData
          heightData the height map used to represent the terrain.
protected  boolean isDetailed
          isDetailed denotes if multitextured detail mapping is to be used.
protected  boolean isLit
          isLit denotes if a light map is to be used.
protected  boolean isTextured
          isTextured denotes if a texture map is to be applied to the terrain.
protected  AbstractLightMap lightMap
          lightMap the map used to contain shade values.
protected  int repeatDetailMap
          repeatDetailMap the number of times to repeat the detail texture across the terrain.
protected  int terrainSize
          terrainSize contains the size of the terrain where the area is terrainSize x terrainSize.
protected  int terrainTexture
          terrainTexture is the texture id for the terrain map.
protected  boolean useDistanceFog
          useDistanceFog denotes if distance fog is being used or not.
protected  boolean useVolumeFog
          useVolumeFog denotes if volumetric fog is being used or not.
protected  float xScale
          xScale is the scale of the terrain in the x-axis.
protected  float zScale
          zScale is the scale of the terrain in the z-axis.
 
Constructor Summary
Terrain()
           
 
Method Summary
abstract  void render()
          Abstract method to be implemented by the subclass.
 void setDetailTexture(java.lang.String detailTexture, int repeat)
          setDetailTexture sets texture to use for detail texturing.
 void setDistanceFog(boolean value)
          useDistanceFog determines if distance-based fog will be used.
 void setFogAttributes(int mode, float[] color, float density, float start, float end)
          setFogAttributes sets the attributes for how fog will be used.
 void setHeightData(AbstractHeightMap heightData)
          setHeightData takes a AbstractHeightMap to allow the change of data to render.
 void setLightMap(AbstractLightMap lightMap)
          setLightMap
 void setTexture(javax.swing.ImageIcon texture)
          setTexture sets the texture used to render the terrain.
 void setTexture(java.lang.String texture)
          setTexture sets the texture used to render the terrain.
 void setVolumetricFog(boolean value)
          setVolumetricFog determines if vertex-based fog will be used.
protected  void setVolumetricFogCoord(float height)
          setVolumetricFogCoord sets the level of the fog coordinate.
 void setVolumetricFogDepth(float depth)
          setVolumetricFogDepth sets the depth of the volumetric fog.
 void setXScale(float scale)
          setXScale sets the scale of the terrain along the x-axis.
 void setZScale(float scale)
          setZScale sets the scale of the terrain along the z-axis.
abstract  void update(float time)
          Abstract method to be implemented by the subclass.
 boolean useDistanceFog()
          useDistanceFog returns true if distance fog is turned on, false otherwise.
 boolean useVolumetricFog()
          useVolumetricFog returns true if volumetric fog is turned on, false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

terrainTexture

protected int terrainTexture
terrainTexture is the texture id for the terrain map.


detailId

protected int detailId
detailId is the texture id for the detail map.


terrainSize

protected int terrainSize
terrainSize contains the size of the terrain where the area is terrainSize x terrainSize.


isTextured

protected boolean isTextured
isTextured denotes if a texture map is to be applied to the terrain.


isLit

protected boolean isLit
isLit denotes if a light map is to be used.


isDetailed

protected boolean isDetailed
isDetailed denotes if multitextured detail mapping is to be used.


repeatDetailMap

protected int repeatDetailMap
repeatDetailMap the number of times to repeat the detail texture across the terrain.


lightMap

protected AbstractLightMap lightMap
lightMap the map used to contain shade values.


heightData

protected AbstractHeightMap heightData
heightData the height map used to represent the terrain.


gl

protected GL gl
gl the OpenGL context.


xScale

protected float xScale
xScale is the scale of the terrain in the x-axis. Default is 1.0f.


zScale

protected float zScale
zScale is the scale of the terrain in the z-axis. Default is 1.0f.


useVolumeFog

protected boolean useVolumeFog
useVolumeFog denotes if volumetric fog is being used or not.


useDistanceFog

protected boolean useDistanceFog
useDistanceFog denotes if distance fog is being used or not.

Constructor Detail

Terrain

public Terrain()
Method Detail

setXScale

public void setXScale(float scale)
setXScale sets the scale of the terrain along the x-axis.

Parameters:
scale - the new x scale.

setZScale

public void setZScale(float scale)
setZScale sets the scale of the terrain along the z-axis.

Parameters:
scale - the new z scale.

setFogAttributes

public void setFogAttributes(int mode,
                             float[] color,
                             float density,
                             float start,
                             float end)
setFogAttributes sets the attributes for how fog will be used.

Parameters:
mode - what GL mode to render the fog as (GL.EXP, GL.EXP2, GL.LINEAR).
color - the color of the fog.
density - how thick the fog will be.
start - what distance to start the fog.
end - what distance the fog will be at full capacity.

useDistanceFog

public boolean useDistanceFog()
useDistanceFog returns true if distance fog is turned on, false otherwise.

Specified by:
useDistanceFog in interface Locale
Returns:
true if distance fog is on, false if it is off.

useVolumetricFog

public boolean useVolumetricFog()
useVolumetricFog returns true if volumetric fog is turned on, false otherwise.

Specified by:
useVolumetricFog in interface Locale
Returns:
true if distance fog is on, false if it is off.

setDistanceFog

public void setDistanceFog(boolean value)
useDistanceFog determines if distance-based fog will be used. If true is passed it is enabled otherwise, it is disabled.

Parameters:
value - true if distance fog is to be used, false otherwise.

setVolumetricFogDepth

public void setVolumetricFogDepth(float depth)
setVolumetricFogDepth sets the depth of the volumetric fog.

Parameters:
depth - the depth of the volumetric fog.

setVolumetricFog

public void setVolumetricFog(boolean value)
setVolumetricFog determines if vertex-based fog will be used. If true is passed it is enabled, otherwise it is disabled.

Parameters:
value - true if volumetric fog is to be used, false otherwise.

setVolumetricFogCoord

protected void setVolumetricFogCoord(float height)
setVolumetricFogCoord sets the level of the fog coordinate. This is dependant on the fogDepth and the height of the terrain.

Parameters:
height - the height of the terrain.

setDetailTexture

public void setDetailTexture(java.lang.String detailTexture,
                             int repeat)
setDetailTexture sets texture to use for detail texturing. setDetailTexture takes care of determining if the graphics card can support multitexturing and will turn if off it it doesn't.

Parameters:
detailTexture - the image file to use for detail texturing.
repeat - the number of times to repeat the detail texture.

setTexture

public void setTexture(java.lang.String texture)
setTexture sets the texture used to render the terrain. The texture can be null with will turn off texturing.

Parameters:
texture - the texture to use for the terrain.

setTexture

public void setTexture(javax.swing.ImageIcon texture)
setTexture sets the texture used to render the terrain. The texture can be null with will turn off texturing.

Parameters:
texture - the texture to use for the terrain.

setLightMap

public void setLightMap(AbstractLightMap lightMap)
setLightMap

Parameters:
lightMap -

setHeightData

public void setHeightData(AbstractHeightMap heightData)
setHeightData takes a AbstractHeightMap to allow the change of data to render.

Parameters:
heightData - the new terrain data.
Throws:
MonkeyRuntimeException - if heightData is null.

update

public abstract void update(float time)
Abstract method to be implemented by the subclass.

Specified by:
update in interface Locale
See Also:
Locale.update(float)

render

public abstract void render()
Abstract method to be implemented by the subclass.

Specified by:
render in interface Locale
See Also:
Locale.render()