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 Summary
Nested ClassesModifier and TypeClassDescriptionprotected classCalculates the LOD of all child terrain patches. -
Field Summary
FieldsModifier 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.AbstractControl
enabled, spatial -
Constructor Summary
ConstructorsConstructorDescriptionTerrainLodControl(Camera camera) TerrainLodControl(Terrain terrain) TerrainLodControl(Terrain terrain, Camera camera) TerrainLodControl(Terrain terrain, List<Camera> cameras) Only uses the first camera right now. -
Method Summary
Modifier 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.AbstractControl
cloneForSpatial, getSpatial, isEnabled, render, update
-
Field Details
-
cameras
The list of cameras for when terrain supports multiple cameras (ie split screen) -
cameraLocations
-
lastCameraLocations
-
lodCalcRunning
-
previousCameraLocation
The previous location ofcamera. -
camera
The 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
-
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
Description copied from class:AbstractControlTo be implemented in subclass.- Specified by:
controlRenderin classAbstractControl- Parameters:
rm- the RenderManager rendering the controlled Spatial (not null)vp- the ViewPort being rendered (not null)
-
controlUpdate
protected void controlUpdate(float tpf) Description copied from class:AbstractControlTo be implemented in subclass.- Specified by:
controlUpdatein classAbstractControl- Parameters:
tpf- time per frame (in seconds)
-
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
-
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<Vector3f> locations, LodCalculator lodCalculator) -
jmeClone
Description 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 interfaceJmeCloneable- Overrides:
jmeClonein classAbstractControl- Returns:
- a new instance
-
cloneFields
Description 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 interfaceJmeCloneable- Overrides:
cloneFieldsin classAbstractControl- 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 interfaceControl- Overrides:
setSpatialin classAbstractControl- Parameters:
spatial- the spatial to be controlled. This should not be called from user code.
-
setTerrain
-
getLodCalculator
-
setLodCalculator
-
setEnabled
public void setEnabled(boolean enabled) - Overrides:
setEnabledin classAbstractControl
-
write
- Specified by:
writein interfaceSavable- Overrides:
writein classAbstractControl- Throws:
IOException
-
read
- Specified by:
readin interfaceSavable- Overrides:
readin classAbstractControl- Throws:
IOException
-