Package com.jme3.terrain.geomipmap
Class TerrainLodControl
java.lang.Object
com.jme3.scene.control.AbstractControl
com.jme3.terrain.geomipmap.TerrainLodControl
- All Implemented Interfaces:
- Savable,- Control,- JmeCloneable,- Cloneable
- Direct Known Subclasses:
- MultiTerrainLodControl,- TerrainGridLodControl
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.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classCalculates the LOD of all child terrain patches.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected CameraThe camera from render view port.protected SafeArrayList<Vector3f>protected SafeArrayList<Camera>The list of cameras for when terrain supports multiple cameras (ie split screen)protected booleanprotected booleanprotected Future<HashMap<String,UpdatedTerrainPatch>> protected SafeArrayList<Vector3f>protected AtomicBooleanprotected LodCalculatorprotected 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.AbstractControlenabled, spatial
- 
Constructor SummaryConstructorsConstructorDescriptionTerrainLodControl(Camera camera) TerrainLodControl(Terrain terrain) TerrainLodControl(Terrain terrain, Camera camera) TerrainLodControl(Terrain terrain, List<Camera> cameras) Only uses the first camera right now.
- 
Method SummaryModifier and TypeMethodDescriptionvoidcloneFields(Cloner cloner, Object original) Implemented to perform deep cloning for this object, resolving local cloned references using the specified cloner.protected voidcontrolRender(RenderManager rm, ViewPort vp) To be implemented in subclass.protected voidcontrolUpdate(float tpf) To be implemented in subclass.protected TerrainLodControl.UpdateLODcreateLodUpdateTask(List<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()Performs a regular shallow clone of the object.protected DistanceLodCalculatorprotected voidvoidread(JmeImporter im) voidvoidsetCameras(List<Camera> cameras) voidsetEnabled(boolean enabled) voidsetLodCalculator(LodCalculator lodCalculator) voidsetSpatial(Spatial spatial) voidsetTerrain(Terrain terrain) voidsetUseRenderCamera(boolean useRenderCamera) protected voidupdateLOD(LodCalculator lodCalculator) protected voidupdateLOD(SafeArrayList<Vector3f> locations, LodCalculator lodCalculator) protected booleanupdateLodOffCount(LodCalculator lodCalculator) voidwrite(JmeExporter ex) Methods inherited from class com.jme3.scene.control.AbstractControlcloneForSpatial, getSpatial, isEnabled, render, update
- 
Field Details- 
camerasThe list of cameras for when terrain supports multiple cameras (ie split screen)
- 
cameraLocations
- 
lastCameraLocations
- 
lodCalcRunning
- 
previousCameraLocationThe previous location ofcamera.
- 
cameraThe camera from render view port.
- 
terrain
- 
lodCalculator
- 
indexer
- 
useRenderCameraprotected boolean useRenderCameraThe flag of using a camera from render viewport instead cameras fromcameras.
- 
forceUpdateprotected boolean forceUpdate
- 
hasResetLodprotected boolean hasResetLod
 
- 
- 
Constructor Details- 
TerrainLodControlpublic TerrainLodControl()
- 
TerrainLodControl
- 
TerrainLodControl
- 
TerrainLodControl
- 
TerrainLodControlOnly 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
- 
setUseRenderCamerapublic void setUseRenderCamera(boolean useRenderCamera) - Parameters:
- useRenderCamera- true to use camera from the render viewport
 
- 
isUseRenderCamerapublic boolean isUseRenderCamera()- Returns:
- true to use camera from the render viewport
 
- 
controlRenderDescription copied from class:AbstractControlTo be implemented in subclass.- Specified by:
- controlRenderin class- AbstractControl
- Parameters:
- rm- the RenderManager rendering the controlled Spatial (not null)
- vp- the ViewPort being rendered (not null)
 
- 
controlUpdateprotected void controlUpdate(float tpf) Description copied from class:AbstractControlTo be implemented in subclass.- Specified by:
- controlUpdatein class- AbstractControl
- Parameters:
- tpf- time per frame (in seconds)
 
- 
detachAndCleanUpControlpublic 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
- 
updateLodOffCount
- 
forceUpdatepublic void forceUpdate()Force the LOD to update instantly, does not wait for the camera to move. It will reset once it has updated.
- 
prepareTerrainprotected void prepareTerrain()
- 
createLodUpdateTaskprotected TerrainLodControl.UpdateLOD createLodUpdateTask(List<Vector3f> locations, LodCalculator lodCalculator) 
- 
jmeCloneDescription copied from interface:JmeCloneablePerforms a regular shallow clone of the object. Some fields may also be cloned but generally only if they will never be shared with other objects. (For example, local Vector3fs and so on.)This method is separate from the regular clone() method so that objects might still maintain their own regular java clone() semantics (perhaps even using Cloner for those methods). However, because Java's clone() has specific features in the sense of Object's clone() implementation, it's usually best to have some path for subclasses to bypass the public clone() method that might be cloning fields and instead get at the superclass protected clone() methods. For example, through super.jmeClone() or another protected clone method that some base class eventually calls super.clone() in. - Specified by:
- jmeClonein interface- JmeCloneable
- Overrides:
- jmeClonein class- AbstractControl
- Returns:
- a new instance
 
- 
cloneFieldsDescription copied from interface:JmeCloneableImplemented to perform deep cloning for this object, resolving local cloned references using the specified cloner. The object can call cloner.clone(fieldValue) to deep clone any of its fields.Note: during normal clone operations the original object will not be needed as the clone has already had all of the fields shallow copied. - Specified by:
- cloneFieldsin interface- JmeCloneable
- Overrides:
- cloneFieldsin class- AbstractControl
- Parameters:
- cloner- The cloner that is performing the cloning operation. The cloneFields method can call back into the cloner to make clones of its subordinate fields.
- original- The original object from which this object was cloned. This is provided for the very rare case that this object needs to refer to its original for some reason. In general, all of the relevant values should have been transferred during the shallow clone, and this object need only clone what it wants.
 
- 
setCamera
- 
setCameras
- 
setSpatial- Specified by:
- setSpatialin interface- Control
- Overrides:
- setSpatialin class- AbstractControl
- Parameters:
- spatial- the spatial to be controlled. This should not be called from user code.
 
- 
setTerrain
- 
getLodCalculator
- 
setLodCalculator
- 
setEnabledpublic void setEnabled(boolean enabled) - Overrides:
- setEnabledin class- AbstractControl
 
- 
write- Specified by:
- writein interface- Savable
- Overrides:
- writein class- AbstractControl
- Throws:
- IOException
 
- 
read- Specified by:
- readin interface- Savable
- Overrides:
- readin class- AbstractControl
- Throws:
- IOException
 
 
-