Package com.jme3.terrain.geomipmap
Class TerrainLodControl
java.lang.Object
com.jme3.scene.control.AbstractControl
com.jme3.terrain.geomipmap.TerrainLodControl
- All Implemented Interfaces:
com.jme3.export.Savable,com.jme3.scene.control.Control,com.jme3.util.clone.JmeCloneable,Cloneable
- Direct Known Subclasses:
MultiTerrainLodControl,TerrainGridLodControl
public class TerrainLodControl
extends com.jme3.scene.control.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!
When the control or the terrain are removed from the scene, you should call
TerrainLodControl.detachAndCleanUpControl() to remove any threads it created
to handle the LOD processing. If you supply your own executor service, then
you have to handle its thread termination yourself.
- Author:
- Brent Owens
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classCalculates the LOD of all child terrain patches. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.jme3.renderer.CameraThe camera from render view port.protected com.jme3.util.SafeArrayList<com.jme3.math.Vector3f> protected com.jme3.util.SafeArrayList<com.jme3.renderer.Camera> The list of cameras for when terrain supports multiple cameras (ie split screen)protected booleanprotected booleanprotected Future<HashMap<String, UpdatedTerrainPatch>> protected com.jme3.util.SafeArrayList<com.jme3.math.Vector3f> protected AtomicBooleanprotected LodCalculatorprotected com.jme3.math.Vector3fThe previous location ofcamera.protected Terrainprotected booleanThe flag of using a camera from render viewport instead cameras fromcameras.Fields inherited from class com.jme3.scene.control.AbstractControl
enabled, spatial -
Constructor Summary
ConstructorsConstructorDescriptionTerrainLodControl(com.jme3.renderer.Camera camera) TerrainLodControl(Terrain terrain) TerrainLodControl(Terrain terrain, com.jme3.renderer.Camera camera) TerrainLodControl(Terrain terrain, List<com.jme3.renderer.Camera> cameras) Only uses the first camera right now. -
Method Summary
Modifier and TypeMethodDescriptionvoidcloneFields(com.jme3.util.clone.Cloner cloner, Object original) protected voidcontrolRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) protected voidcontrolUpdate(float tpf) protected TerrainLodControl.UpdateLODcreateLodUpdateTask(List<com.jme3.math.Vector3f> locations, LodCalculator lodCalculator) voidCall this when you remove the terrain or this control from the scene.voidForce the LOD to update instantly, does not wait for the camera to move.booleanjmeClone()protected DistanceLodCalculatorprotected voidvoidread(com.jme3.export.JmeImporter im) voidsetCamera(com.jme3.renderer.Camera camera) voidsetCameras(List<com.jme3.renderer.Camera> cameras) voidsetEnabled(boolean enabled) voidsetLodCalculator(LodCalculator lodCalculator) voidsetSpatial(com.jme3.scene.Spatial spatial) voidsetTerrain(Terrain terrain) voidsetUseRenderCamera(boolean useRenderCamera) protected voidupdateLOD(LodCalculator lodCalculator) protected voidupdateLOD(com.jme3.util.SafeArrayList<com.jme3.math.Vector3f> locations, LodCalculator lodCalculator) protected booleanupdateLodOffCount(LodCalculator lodCalculator) voidwrite(com.jme3.export.JmeExporter ex) Methods inherited from class com.jme3.scene.control.AbstractControl
cloneForSpatial, getSpatial, isEnabled, render, update
-
Field Details
-
cameras
protected com.jme3.util.SafeArrayList<com.jme3.renderer.Camera> camerasThe list of cameras for when terrain supports multiple cameras (ie split screen) -
cameraLocations
protected com.jme3.util.SafeArrayList<com.jme3.math.Vector3f> cameraLocations -
lastCameraLocations
protected com.jme3.util.SafeArrayList<com.jme3.math.Vector3f> lastCameraLocations -
lodCalcRunning
-
previousCameraLocation
protected com.jme3.math.Vector3f previousCameraLocationThe previous location ofcamera. -
camera
protected com.jme3.renderer.Camera cameraThe camera from render view port. -
terrain
-
lodCalculator
-
indexer
-
useRenderCamera
protected boolean useRenderCameraThe flag of using a camera from render viewport instead cameras fromcameras. -
forceUpdate
protected boolean forceUpdate -
hasResetLod
protected boolean hasResetLod
-
-
Constructor Details
-
TerrainLodControl
public TerrainLodControl() -
TerrainLodControl
-
TerrainLodControl
public TerrainLodControl(com.jme3.renderer.Camera camera) -
TerrainLodControl
-
TerrainLodControl
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 Details
-
makeLodCalculator
-
setUseRenderCamera
public void setUseRenderCamera(boolean useRenderCamera) - Parameters:
useRenderCamera- true to use camera from the render viewport
-
isUseRenderCamera
public boolean isUseRenderCamera()- Returns:
- true to use camera from the render viewport
-
controlRender
protected void controlRender(com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp) - Specified by:
controlRenderin classcom.jme3.scene.control.AbstractControl
-
controlUpdate
protected void controlUpdate(float tpf) - Specified by:
controlUpdatein classcom.jme3.scene.control.AbstractControl
-
detachAndCleanUpControl
public void detachAndCleanUpControl()Call this when you remove the terrain or this control from the scene. It will clear up any threads it had. -
updateLOD
-
updateLOD
protected void updateLOD(com.jme3.util.SafeArrayList<com.jme3.math.Vector3f> locations, LodCalculator lodCalculator) -
updateLodOffCount
-
forceUpdate
public void forceUpdate()Force the LOD to update instantly, does not wait for the camera to move. It will reset once it has updated. -
prepareTerrain
protected void prepareTerrain() -
createLodUpdateTask
protected TerrainLodControl.UpdateLOD createLodUpdateTask(List<com.jme3.math.Vector3f> locations, LodCalculator lodCalculator) -
jmeClone
- Specified by:
jmeClonein interfacecom.jme3.util.clone.JmeCloneable- Overrides:
jmeClonein classcom.jme3.scene.control.AbstractControl
-
cloneFields
- Specified by:
cloneFieldsin interfacecom.jme3.util.clone.JmeCloneable- Overrides:
cloneFieldsin classcom.jme3.scene.control.AbstractControl
-
setCamera
public void setCamera(com.jme3.renderer.Camera camera) -
setCameras
-
setSpatial
public void setSpatial(com.jme3.scene.Spatial spatial) - Specified by:
setSpatialin interfacecom.jme3.scene.control.Control- Overrides:
setSpatialin classcom.jme3.scene.control.AbstractControl
-
setTerrain
-
getLodCalculator
-
setLodCalculator
-
setEnabled
public void setEnabled(boolean enabled) - Overrides:
setEnabledin classcom.jme3.scene.control.AbstractControl
-
write
- Specified by:
writein interfacecom.jme3.export.Savable- Overrides:
writein classcom.jme3.scene.control.AbstractControl- Throws:
IOException
-
read
- Specified by:
readin interfacecom.jme3.export.Savable- Overrides:
readin classcom.jme3.scene.control.AbstractControl- Throws:
IOException
-