jme.locale.external
Class Geomipmap

java.lang.Object
  extended byjme.locale.external.Terrain
      extended byjme.locale.external.Geomipmap
All Implemented Interfaces:
Locale

public class Geomipmap
extends Terrain

Geomipmap implements a Terrain class for rendering of HeightMaps using the geomipmap CLOD scheme. Geomipmap uses the ideas developed by Willem H. de Boer and presented by Trent Polack. A heightmap is divided into patches, where each patch is a number of vertices. These patches are then organized into LOD levels, where the lowest 0, contains all vertices in the patch and the highest N only contains the four corners. The LOD chosen is dependant on the distance from the patch to the camera. So, the highest LOD N will be the furthest from the camera. This improves the speed of the rendering because patches that are far away do not require as much detail because you wouldn't be able to see it, therefore by lowering it's detail you save passing in those extra, unneeded, vertices. Patches that fall outside the ViewFrustum will also be culled with in turn saves much unnecessary rendering. Special Note: Geomipmapping requires the heightmap to be a 2^N + 1 square size. For example, 1025x1025. Therefore, a MidPointHeightMap would not work for this.

Version:
$Id: Geomipmap.java,v 1.3 2003/09/03 16:20:51 mojomonkey Exp $
Author:
Mark Powell

Field Summary
 
Fields inherited from class jme.locale.external.Terrain
detailId, gl, heightData, isDetailed, isLit, isTextured, lightMap, repeatDetailMap, terrainSize, terrainTexture, useDistanceFog, useVolumeFog, xScale, zScale
 
Constructor Summary
Geomipmap(AbstractHeightMap heightMap, int patchSize, Camera camera)
          Constructor instantiates a new Geomipmap object.
 
Method Summary
 int getNumPatches()
          getNumPatches returns the total number of terrain patches in the terrain.
 int getNumPatchesRendered()
          getNumPatchesRendered returns the number of patches that have been rendered for a given frame.
 void render()
          render renders each patch if it is visible.
 void setMinimumDistance(float minDistance)
          setMinimumDistance sets the distance for the most detail.
 void update(float time)
          update updates the geomipmap patch values to reflect any movement in the camera.
 
Methods inherited from class jme.locale.external.Terrain
setDetailTexture, setDistanceFog, setFogAttributes, setHeightData, setLightMap, setTexture, setTexture, setVolumetricFog, setVolumetricFogCoord, setVolumetricFogDepth, setXScale, setZScale, useDistanceFog, useVolumetricFog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Geomipmap

public Geomipmap(AbstractHeightMap heightMap,
                 int patchSize,
                 Camera camera)
Constructor instantiates a new Geomipmap object. It calculates the level of details based on a patch size and the size of the terrain.

Parameters:
patchSize - the size of a single patch.
camera - the camera used for the viewport.
Throws:
MonkeyRuntimeException - if the patchSize is not greater than zero.
Method Detail

getNumPatches

public int getNumPatches()
getNumPatches returns the total number of terrain patches in the terrain.

Returns:
the total number of patches.

getNumPatchesRendered

public int getNumPatchesRendered()
getNumPatchesRendered returns the number of patches that have been rendered for a given frame.

Returns:
the total number of patches rendered for a given frame.

update

public void update(float time)
update updates the geomipmap patch values to reflect any movement in the camera.

Specified by:
update in interface Locale
Specified by:
update in class Terrain
Parameters:
time - time between frames.
See Also:
Locale.update(float)

render

public void render()
render renders each patch if it is visible. The number of triangle fans rendered for each fan is dependant on the level of detail for the particular patch.

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

setMinimumDistance

public void setMinimumDistance(float minDistance)
setMinimumDistance sets the distance for the most detail. If any patch is within this distance, it will be rendered at full detail. By default, minDistance is set to 50.

Parameters:
minDistance - the distance to render in full detail.