com.jme3.terrain.geomipmap
Class TerrainLodControl

java.lang.Object
  extended by com.jme3.scene.control.AbstractControl
      extended by com.jme3.terrain.geomipmap.TerrainLodControl
All Implemented Interfaces:
Savable, Control
Direct Known Subclasses:
MultiTerrainLodControl, TerrainGridLodControl

public class TerrainLodControl
extends AbstractControl

Tells the terrain to update its Level of Detail. It needs the cameras to do this, and there could possibly be several cameras in the scene, so it accepts a list of cameras. NOTE: right now it just uses the first camera passed in, in the future it will use all of them to determine what LOD to set. This control serializes, but it does not save the Camera reference. This camera reference has to be manually added in when you load the terrain to the scene!


Nested Class Summary
protected  class TerrainLodControl.UpdateLOD
          Calculates the LOD of all child terrain patches.
 
Field Summary
protected  java.util.List<Camera> cameras
           
protected  java.util.concurrent.ExecutorService executor
           
protected  java.util.concurrent.Future<java.util.HashMap<java.lang.String,UpdatedTerrainPatch>> indexer
           
protected  java.util.List<Vector3f> lastCameraLocations
           
protected  LodCalculator lodCalculator
           
 
Fields inherited from class com.jme3.scene.control.AbstractControl
enabled, spatial
 
Constructor Summary
TerrainLodControl()
           
TerrainLodControl(Terrain terrain, Camera camera)
           
TerrainLodControl(Terrain terrain, java.util.List<Camera> cameras)
          Only uses the first camera right now.
 
Method Summary
 Control cloneForSpatial(Spatial spatial)
          Creates a clone of the Control, the given Spatial is the cloned version of the spatial to which this control is attached to.
protected  void controlRender(RenderManager rm, ViewPort vp)
          To be implemented in subclass.
protected  void controlUpdate(float tpf)
          To be implemented in subclass.
protected  java.util.concurrent.ExecutorService createExecutorService()
           
 LodCalculator getLodCalculator()
           
protected  TerrainLodControl.UpdateLOD getLodThread(java.util.List<Vector3f> locations, LodCalculator lodCalculator)
           
protected  boolean isLodCalcRunning()
           
protected  void prepareTerrain()
           
 void read(JmeImporter im)
           
 void setCamera(Camera camera)
           
 void setCameras(java.util.List<Camera> cameras)
           
 void setEnabled(boolean enabled)
           
protected  void setLodCalcRunning(boolean running)
           
 void setLodCalculator(LodCalculator lodCalculator)
           
 void setSpatial(Spatial spatial)
           
 void setTerrain(Terrain terrain)
           
protected  void updateLOD(java.util.List<Vector3f> locations, LodCalculator lodCalculator)
           
 void write(JmeExporter ex)
           
 
Methods inherited from class com.jme3.scene.control.AbstractControl
getSpatial, isEnabled, render, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cameras

protected java.util.List<Camera> cameras

lodCalculator

protected LodCalculator lodCalculator

lastCameraLocations

protected java.util.List<Vector3f> lastCameraLocations

executor

protected java.util.concurrent.ExecutorService executor

indexer

protected java.util.concurrent.Future<java.util.HashMap<java.lang.String,UpdatedTerrainPatch>> indexer
Constructor Detail

TerrainLodControl

public TerrainLodControl()

TerrainLodControl

public TerrainLodControl(Terrain terrain,
                         Camera camera)

TerrainLodControl

public TerrainLodControl(Terrain terrain,
                         java.util.List<Camera> cameras)
Only uses the first camera right now.

Parameters:
terrain - to act upon (must be a Spatial)
cameras - one or more cameras to reference for LOD calc
Method Detail

controlRender

protected void controlRender(RenderManager rm,
                             ViewPort vp)
Description copied from class: AbstractControl
To be implemented in subclass.

Specified by:
controlRender in class AbstractControl

createExecutorService

protected java.util.concurrent.ExecutorService createExecutorService()

controlUpdate

protected void controlUpdate(float tpf)
Description copied from class: AbstractControl
To be implemented in subclass.

Specified by:
controlUpdate in class AbstractControl

updateLOD

protected void updateLOD(java.util.List<Vector3f> locations,
                         LodCalculator lodCalculator)

prepareTerrain

protected void prepareTerrain()

getLodThread

protected TerrainLodControl.UpdateLOD getLodThread(java.util.List<Vector3f> locations,
                                                   LodCalculator lodCalculator)

isLodCalcRunning

protected boolean isLodCalcRunning()

setLodCalcRunning

protected void setLodCalcRunning(boolean running)

cloneForSpatial

public Control cloneForSpatial(Spatial spatial)
Description copied from interface: Control
Creates a clone of the Control, the given Spatial is the cloned version of the spatial to which this control is attached to.

Returns:
A clone of this control for the spatial

setCamera

public void setCamera(Camera camera)

setCameras

public void setCameras(java.util.List<Camera> cameras)

setSpatial

public void setSpatial(Spatial spatial)
Specified by:
setSpatial in interface Control
Overrides:
setSpatial in class AbstractControl
Parameters:
spatial - the spatial to be controlled. This should not be called from user code.

setTerrain

public void setTerrain(Terrain terrain)

getLodCalculator

public LodCalculator getLodCalculator()

setLodCalculator

public void setLodCalculator(LodCalculator lodCalculator)

setEnabled

public void setEnabled(boolean enabled)
Overrides:
setEnabled in class AbstractControl

write

public void write(JmeExporter ex)
           throws java.io.IOException
Specified by:
write in interface Savable
Overrides:
write in class AbstractControl
Throws:
java.io.IOException

read

public void read(JmeImporter im)
          throws java.io.IOException
Specified by:
read in interface Savable
Overrides:
read in class AbstractControl
Throws:
java.io.IOException