Package gov.nasa.worldwind
Class AbstractSceneController
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.AbstractSceneController
-
- All Implemented Interfaces:
AVList
,Disposable
,MessageListener
,SceneController
,WWObject
,java.beans.PropertyChangeListener
,java.util.EventListener
- Direct Known Subclasses:
BasicSceneController
public abstract class AbstractSceneController extends WWObjectImpl implements SceneController
-
-
Field Summary
Fields Modifier and Type Field Description protected ClutterFilter
clutterFilter
protected DrawContext
dc
protected boolean
deepPick
protected boolean
deferOrderedRendering
protected long
frame
protected double
framesPerSecond
protected double
frameTime
protected GLRuntimeCapabilities
glRuntimeCaps
protected GpuResourceCache
gpuResourceCache
protected PickedObjectList
lastObjectsInPickRect
The list of picked objects that intersect the current pick rectangle.protected PickedObjectList
lastPickedObjects
The list of picked objects at the current pick point.protected Model
model
protected java.util.Collection<PerformanceStatistic>
perFrameStatistics
protected java.util.Set<java.lang.String>
perFrameStatisticsKeys
protected java.util.Map<java.lang.Integer,PickedObject>
pickableObjects
Map of integer color codes to picked objects used to quickly resolve the top picked objects indoResolveTopPick(gov.nasa.worldwind.render.DrawContext, java.awt.Rectangle)
.protected java.awt.Point
pickPoint
The pick point in AWT screen coordinates, ornull
if the pick point is disabled.protected java.util.ArrayList<java.awt.Point>
pickPoints
protected java.awt.Rectangle
pickRect
The pick rectangle in AWT screen coordinates, ornull
if the pick rectangle is disabled.protected double
pickTime
protected java.util.Collection<java.lang.Throwable>
renderingExceptions
protected ScreenCreditController
screenCreditController
protected static java.lang.String
SURFACE_OBJECT_TILE_COUNT_NAME
The display name for the surface object tile count performance statistic.protected SurfaceObjectTileBuilder
surfaceObjectTileBuilder
Support class used to build the composite representation of surface objects as a list of SurfaceTiles.protected TextRendererCache
textRendererCache
protected long
timebase
protected double
verticalExaggeration
protected View
view
-
Constructor Summary
Constructors Constructor Description AbstractSceneController()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
applyView(DrawContext dc)
protected void
buildCompositeSurfaceObjects(DrawContext dc)
Builds a composite representation for allSurfaceObject
instances in the draw context's ordered surface renderable queue.protected void
checkGLErrors(DrawContext dc)
Called to check for openGL errors.protected void
clearFrame(DrawContext dc)
protected void
createPickFrustum(DrawContext dc)
protected void
createTerrain(DrawContext dc)
void
dispose()
Releases resources associated with this scene controller.protected void
doDeepPick(DrawContext dc)
protected void
doNonTerrainPick(DrawContext dc)
protected abstract void
doRepaint(DrawContext dc)
protected void
doResolveTopPick(DrawContext dc, java.awt.Point pickPoint)
protected void
doResolveTopPick(DrawContext dc, java.awt.Rectangle pickRect)
protected void
draw(DrawContext dc)
protected void
drawCompositeSurfaceObjects(DrawContext dc)
Causes the scene controller to draw the composite representation of allSurfaceObject
instances in the draw context's ordered surface renderable queue.protected void
drawOrderedSurfaceRenderables(DrawContext dc)
protected void
finalizeFrame(DrawContext dc)
ClutterFilter
getClutterFilter()
Returns the current clutter filter.DrawContext
getDrawContext()
Returns the current draw context.double
getFramesPerSecond()
Returns the current average frames drawn per second.double
getFrameTime()
Returns the per-frame timestamp.GLRuntimeCapabilities
getGLRuntimeCapabilities()
Returns theGLRuntimeCapabilities
associated with this SceneController.GpuResourceCache
getGpuResourceCache()
Returns this scene controller's GPU Resource cache.Model
getModel()
Indicates the scene controller's model.PickedObjectList
getObjectsInPickRectangle()
Returns the list of picked objects that intersect the current pick rectangle.java.util.Collection<PerformanceStatistic>
getPerFrameStatistics()
Returns the current per-frame statistics.PickedObjectList
getPickedObjectList()
Returns the list of picked objects at the current pick point.java.awt.Point
getPickPoint()
Returns the current pick point in AWT screen coordinates.java.awt.Rectangle
getPickRectangle()
Returns the current pick rectangle in AWT screen coordinates.java.util.Collection<java.lang.Throwable>
getRenderingExceptions()
Returns the rendering exceptions accumulated by this SceneController during the last frame as aCollection
ofThrowable
objects.ScreenCreditController
getScreenCreditController()
Returns the current screen credit controller.SectorGeometryList
getTerrain()
Returns the terrain geometry used to draw the most recent frame.TextRendererCache
getTextRendererCache()
double
getVerticalExaggeration()
Indicates the current vertical exaggeration.View
getView()
Returns the current view.protected java.awt.Point
getViewportCenter(DrawContext dc)
protected void
initializeDrawContext(DrawContext dc)
protected void
initializeFrame(DrawContext dc)
boolean
isDeepPickEnabled()
Indicates whether all items under the cursor are identified during picking and withinSelectEvent
s.boolean
isDeferOrderedRendering()
protected PickedObjectList
mergePickedObjectLists(PickedObjectList listA, PickedObjectList listB)
protected void
pick(DrawContext dc)
protected void
pickLayers(DrawContext dc)
protected void
pickOrderedSurfaceRenderables(DrawContext dc)
protected void
pickTerrain(DrawContext dc)
protected void
preRender(DrawContext dc)
protected void
preRenderOrderedSurfaceRenderables(DrawContext dc)
void
reinitialize()
Reinitializes the scene controller.int
repaint()
Cause the window to regenerate the frame, including pick resolution.protected void
resolveTopPick(DrawContext dc)
void
setClutterFilter(ClutterFilter clutterFilter)
Specifies the clutter filter to use.void
setDeepPickEnabled(boolean tf)
Specifies whether all items under the cursor are identified during picking and withinSelectEvent
s.void
setDeferOrderedRendering(boolean deferOrderedRendering)
void
setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities)
Sets theGLRuntimeCapabilities
associated with this SceneController to the specified parameter.void
setGpuResourceCache(GpuResourceCache gpuResourceCache)
Specifies the GPU Resource cache to use.void
setModel(Model model)
Specifies the scene controller's model.void
setPerFrameStatisticsKeys(java.util.Set<java.lang.String> keys)
Specifies the performance values to monitor.protected void
setPickedObjectList(PickedObjectList pol)
void
setPickPoint(java.awt.Point pickPoint)
Specifies the current pick point in AWT screen coordinates, ornull
to indicate that there is no pick point.void
setPickRectangle(java.awt.Rectangle pickRect)
Specifies the current pick rectangle in AWT screen coordinates, ornull
to indicate that there is no pick rectangle.void
setScreenCreditController(ScreenCreditController screenCreditController)
Specifies theScreenCreditController
to use for displaying screen credits for the model of this screen controller.void
setVerticalExaggeration(double verticalExaggeration)
Specifies the exaggeration to apply to elevation values of terrain and other displayed items.void
setView(View view)
Sets the current view.-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
-
-
-
-
Field Detail
-
model
protected Model model
-
view
protected View view
-
verticalExaggeration
protected double verticalExaggeration
-
dc
protected DrawContext dc
-
lastPickedObjects
protected PickedObjectList lastPickedObjects
The list of picked objects at the current pick point. This list is computed during each call to repaint. Initiallynull
.
-
lastObjectsInPickRect
protected PickedObjectList lastObjectsInPickRect
The list of picked objects that intersect the current pick rectangle. This list is computed during each call to repaint. Initiallynull
.
-
pickableObjects
protected java.util.Map<java.lang.Integer,PickedObject> pickableObjects
Map of integer color codes to picked objects used to quickly resolve the top picked objects indoResolveTopPick(gov.nasa.worldwind.render.DrawContext, java.awt.Rectangle)
. This map is used only when a pick rectangle is specified. Initialized to a new HashMap.
-
frame
protected long frame
-
timebase
protected long timebase
-
framesPerSecond
protected double framesPerSecond
-
frameTime
protected double frameTime
-
pickTime
protected double pickTime
-
pickPoint
protected java.awt.Point pickPoint
The pick point in AWT screen coordinates, ornull
if the pick point is disabled. Initiallynull
.
-
pickRect
protected java.awt.Rectangle pickRect
The pick rectangle in AWT screen coordinates, ornull
if the pick rectangle is disabled. Initiallynull
.
-
deepPick
protected boolean deepPick
-
gpuResourceCache
protected GpuResourceCache gpuResourceCache
-
textRendererCache
protected TextRendererCache textRendererCache
-
perFrameStatisticsKeys
protected java.util.Set<java.lang.String> perFrameStatisticsKeys
-
perFrameStatistics
protected java.util.Collection<PerformanceStatistic> perFrameStatistics
-
renderingExceptions
protected java.util.Collection<java.lang.Throwable> renderingExceptions
-
screenCreditController
protected ScreenCreditController screenCreditController
-
glRuntimeCaps
protected GLRuntimeCapabilities glRuntimeCaps
-
pickPoints
protected java.util.ArrayList<java.awt.Point> pickPoints
-
surfaceObjectTileBuilder
protected SurfaceObjectTileBuilder surfaceObjectTileBuilder
Support class used to build the composite representation of surface objects as a list of SurfaceTiles. We keep a reference to the tile builder instance used to build tiles because it acts as a cache key to the tiles and determines when the tiles must be updated. The tile builder does not retain any references the SurfaceObjects, so keeping a reference to it does not leak memory.
-
SURFACE_OBJECT_TILE_COUNT_NAME
protected static final java.lang.String SURFACE_OBJECT_TILE_COUNT_NAME
The display name for the surface object tile count performance statistic.- See Also:
- Constant Field Values
-
clutterFilter
protected ClutterFilter clutterFilter
-
deferOrderedRendering
protected boolean deferOrderedRendering
-
-
Method Detail
-
reinitialize
public void reinitialize()
Description copied from interface:SceneController
Reinitializes the scene controller.- Specified by:
reinitialize
in interfaceSceneController
-
dispose
public void dispose()
Releases resources associated with this scene controller.- Specified by:
dispose
in interfaceDisposable
-
getGpuResourceCache
public GpuResourceCache getGpuResourceCache()
Description copied from interface:SceneController
Returns this scene controller's GPU Resource cache.- Specified by:
getGpuResourceCache
in interfaceSceneController
- Returns:
- this scene controller's GPU Resource cache.
-
setGpuResourceCache
public void setGpuResourceCache(GpuResourceCache gpuResourceCache)
Description copied from interface:SceneController
Specifies the GPU Resource cache to use.- Specified by:
setGpuResourceCache
in interfaceSceneController
- Parameters:
gpuResourceCache
- the texture cache.
-
getTextRendererCache
public TextRendererCache getTextRendererCache()
-
getModel
public Model getModel()
Description copied from interface:SceneController
Indicates the scene controller's model. This returnsnull
if the scene controller has no model.- Specified by:
getModel
in interfaceSceneController
- Returns:
- the scene controller's model, or
null
if the scene controller has no model.
-
getView
public View getView()
Description copied from interface:SceneController
Returns the current view. This method fires anAVKey.VIEW
property change event.- Specified by:
getView
in interfaceSceneController
- Returns:
- the current view.
-
setModel
public void setModel(Model model)
Description copied from interface:SceneController
Specifies the scene controller's model. This method fires anAVKey.MODEL
property change event.- Specified by:
setModel
in interfaceSceneController
- Parameters:
model
- the scene controller's model.
-
setView
public void setView(View view)
Description copied from interface:SceneController
Sets the current view.- Specified by:
setView
in interfaceSceneController
- Parameters:
view
- the view.
-
setVerticalExaggeration
public void setVerticalExaggeration(double verticalExaggeration)
Description copied from interface:SceneController
Specifies the exaggeration to apply to elevation values of terrain and other displayed items.- Specified by:
setVerticalExaggeration
in interfaceSceneController
- Parameters:
verticalExaggeration
- the vertical exaggeration to apply.
-
getVerticalExaggeration
public double getVerticalExaggeration()
Description copied from interface:SceneController
Indicates the current vertical exaggeration.- Specified by:
getVerticalExaggeration
in interfaceSceneController
- Returns:
- the current vertical exaggeration.
-
setPickPoint
public void setPickPoint(java.awt.Point pickPoint)
Specifies the current pick point in AWT screen coordinates, ornull
to indicate that there is no pick point. Each frame, this scene controller determines which objects are drawn at the pick point and places them in a PickedObjectList. This list can be accessed by callingSceneController.getPickedObjectList()
.If the pick point is
null
, this scene controller ignores the pick point and the list of objects returned by getPickedObjectList is empty.- Specified by:
setPickPoint
in interfaceSceneController
- Parameters:
pickPoint
- the current pick point, ornull
.
-
getPickPoint
public java.awt.Point getPickPoint()
Returns the current pick point in AWT screen coordinates.- Specified by:
getPickPoint
in interfaceSceneController
- Returns:
- the current pick point, or
null
if no pick point is current. - See Also:
SceneController.setPickPoint(java.awt.Point)
-
setPickRectangle
public void setPickRectangle(java.awt.Rectangle pickRect)
Specifies the current pick rectangle in AWT screen coordinates, ornull
to indicate that there is no pick rectangle. Each frame, this scene controller determines which objects intersect the pick rectangle and places them in a PickedObjectList. This list can be accessed by callingSceneController.getObjectsInPickRectangle()
.If the pick rectangle is
null
, this scene controller ignores the pick rectangle and the list of objects returned by getObjectsInPickRectangle is empty.- Specified by:
setPickRectangle
in interfaceSceneController
- Parameters:
pickRect
- the current pick rectangle, ornull
.
-
getPickRectangle
public java.awt.Rectangle getPickRectangle()
Returns the current pick rectangle in AWT screen coordinates.- Specified by:
getPickRectangle
in interfaceSceneController
- Returns:
- the current pick rectangle, or
null
if no pick rectangle is current. - See Also:
SceneController.setPickRectangle(java.awt.Rectangle)
-
getPickedObjectList
public PickedObjectList getPickedObjectList()
Returns the list of picked objects at the current pick point. The returned list is computed during the most recent call to repaint.- Specified by:
getPickedObjectList
in interfaceSceneController
- Returns:
- the list of picked objects at the pick point, or null if no objects are currently picked.
-
setPickedObjectList
protected void setPickedObjectList(PickedObjectList pol)
-
getObjectsInPickRectangle
public PickedObjectList getObjectsInPickRectangle()
Returns the list of picked objects that intersect the current pick rectangle. The returned list is computed during the most recent call to repaint.- Specified by:
getObjectsInPickRectangle
in interfaceSceneController
- Returns:
- the list of picked objects intersecting the pick rectangle, or null if no objects are currently intersecting the rectangle.
-
setDeepPickEnabled
public void setDeepPickEnabled(boolean tf)
Description copied from interface:SceneController
Specifies whether all items under the cursor are identified during picking and withinSelectEvent
s.- Specified by:
setDeepPickEnabled
in interfaceSceneController
- Parameters:
tf
- true to identify all items under the cursor during picking, otherwise false.
-
isDeepPickEnabled
public boolean isDeepPickEnabled()
Description copied from interface:SceneController
Indicates whether all items under the cursor are identified during picking and withinSelectEvent
s.- Specified by:
isDeepPickEnabled
in interfaceSceneController
- Returns:
- true if all items under the cursor are identified during picking, otherwise false.
-
getTerrain
public SectorGeometryList getTerrain()
Description copied from interface:SceneController
Returns the terrain geometry used to draw the most recent frame. The geometry spans only the area most recently visible.- Specified by:
getTerrain
in interfaceSceneController
- Returns:
- the terrain geometry used to draw the most recent frame. May be null.
-
getDrawContext
public DrawContext getDrawContext()
Description copied from interface:SceneController
Returns the current draw context.- Specified by:
getDrawContext
in interfaceSceneController
- Returns:
- the current draw context.
-
getFramesPerSecond
public double getFramesPerSecond()
Description copied from interface:SceneController
Returns the current average frames drawn per second. A frame is one repaint of the window and includes a pick pass and a render pass.- Specified by:
getFramesPerSecond
in interfaceSceneController
- Returns:
- the current average number of frames drawn per second.
-
getFrameTime
public double getFrameTime()
Description copied from interface:SceneController
Returns the per-frame timestamp.- Specified by:
getFrameTime
in interfaceSceneController
- Returns:
- the per-frame timestamp, in milliseconds.
-
setPerFrameStatisticsKeys
public void setPerFrameStatisticsKeys(java.util.Set<java.lang.String> keys)
Description copied from interface:SceneController
Specifies the performance values to monitor. SeePerformanceStatistic
for the available keys.- Specified by:
setPerFrameStatisticsKeys
in interfaceSceneController
- Parameters:
keys
- the performance statistic keys to monitor.
-
getPerFrameStatistics
public java.util.Collection<PerformanceStatistic> getPerFrameStatistics()
Description copied from interface:SceneController
Returns the current per-frame statistics.- Specified by:
getPerFrameStatistics
in interfaceSceneController
- Returns:
- the current per-frame statistics.
-
getRenderingExceptions
public java.util.Collection<java.lang.Throwable> getRenderingExceptions()
Description copied from interface:SceneController
Returns the rendering exceptions accumulated by this SceneController during the last frame as aCollection
ofThrowable
objects.- Specified by:
getRenderingExceptions
in interfaceSceneController
- Returns:
- the Collection of accumulated rendering exceptions.
-
getScreenCreditController
public ScreenCreditController getScreenCreditController()
Description copied from interface:SceneController
Returns the current screen credit controller.- Specified by:
getScreenCreditController
in interfaceSceneController
- Returns:
- the current screen credit controller. May be null.
- See Also:
SceneController.setScreenCreditController(gov.nasa.worldwind.render.ScreenCreditController)
-
setScreenCreditController
public void setScreenCreditController(ScreenCreditController screenCreditController)
Description copied from interface:SceneController
Specifies theScreenCreditController
to use for displaying screen credits for the model of this screen controller.- Specified by:
setScreenCreditController
in interfaceSceneController
- Parameters:
screenCreditController
- the screen credit controller. May be null, in which case screen credits are not displayed.
-
getGLRuntimeCapabilities
public GLRuntimeCapabilities getGLRuntimeCapabilities()
Returns theGLRuntimeCapabilities
associated with this SceneController.- Specified by:
getGLRuntimeCapabilities
in interfaceSceneController
- Returns:
- this SceneController's associated GLRuntimeCapabilities.
-
setGLRuntimeCapabilities
public void setGLRuntimeCapabilities(GLRuntimeCapabilities capabilities)
Sets theGLRuntimeCapabilities
associated with this SceneController to the specified parameter.- Specified by:
setGLRuntimeCapabilities
in interfaceSceneController
- Parameters:
capabilities
- the GLRuntimeCapabilities to be associated with this SceneController.
-
getClutterFilter
public ClutterFilter getClutterFilter()
Description copied from interface:SceneController
Returns the current clutter filter.- Specified by:
getClutterFilter
in interfaceSceneController
- Returns:
- the current clutter filter. May be null, in which case decluttering is not performed.
-
setClutterFilter
public void setClutterFilter(ClutterFilter clutterFilter)
Description copied from interface:SceneController
Specifies the clutter filter to use.- Specified by:
setClutterFilter
in interfaceSceneController
- Parameters:
clutterFilter
- the clutter filter to use. May be null to indicate no decluttering.
-
isDeferOrderedRendering
public boolean isDeferOrderedRendering()
-
setDeferOrderedRendering
public void setDeferOrderedRendering(boolean deferOrderedRendering)
-
repaint
public int repaint()
Description copied from interface:SceneController
Cause the window to regenerate the frame, including pick resolution.- Specified by:
repaint
in interfaceSceneController
- Returns:
- if greater than zero, the window should be automatically repainted again at the indicated number of milliseconds from this method's return.
-
doRepaint
protected abstract void doRepaint(DrawContext dc)
-
initializeDrawContext
protected void initializeDrawContext(DrawContext dc)
-
getViewportCenter
protected java.awt.Point getViewportCenter(DrawContext dc)
-
initializeFrame
protected void initializeFrame(DrawContext dc)
-
clearFrame
protected void clearFrame(DrawContext dc)
-
finalizeFrame
protected void finalizeFrame(DrawContext dc)
-
applyView
protected void applyView(DrawContext dc)
-
createPickFrustum
protected void createPickFrustum(DrawContext dc)
-
createTerrain
protected void createTerrain(DrawContext dc)
-
preRender
protected void preRender(DrawContext dc)
-
pickTerrain
protected void pickTerrain(DrawContext dc)
-
pickLayers
protected void pickLayers(DrawContext dc)
-
resolveTopPick
protected void resolveTopPick(DrawContext dc)
-
doResolveTopPick
protected void doResolveTopPick(DrawContext dc, java.awt.Point pickPoint)
-
doResolveTopPick
protected void doResolveTopPick(DrawContext dc, java.awt.Rectangle pickRect)
-
pick
protected void pick(DrawContext dc)
-
doNonTerrainPick
protected void doNonTerrainPick(DrawContext dc)
-
doDeepPick
protected void doDeepPick(DrawContext dc)
-
mergePickedObjectLists
protected PickedObjectList mergePickedObjectLists(PickedObjectList listA, PickedObjectList listB)
-
draw
protected void draw(DrawContext dc)
-
checkGLErrors
protected void checkGLErrors(DrawContext dc)
Called to check for openGL errors. This method includes a "round-trip" between the application and renderer, which is slow. Therefore, this method is excluded from the "normal" render pass. It is here as a matter of convenience to developers, and is not part of the API.- Parameters:
dc
- the relevantDrawContext
-
preRenderOrderedSurfaceRenderables
protected void preRenderOrderedSurfaceRenderables(DrawContext dc)
-
pickOrderedSurfaceRenderables
protected void pickOrderedSurfaceRenderables(DrawContext dc)
-
drawOrderedSurfaceRenderables
protected void drawOrderedSurfaceRenderables(DrawContext dc)
-
buildCompositeSurfaceObjects
protected void buildCompositeSurfaceObjects(DrawContext dc)
Builds a composite representation for allSurfaceObject
instances in the draw context's ordered surface renderable queue. While building the composite representation this invokesRenderable.render(gov.nasa.worldwind.render.DrawContext)
in ordered rendering mode. This does nothing if the ordered surface renderable queue is empty, or if it does not contain any SurfaceObjects.This method is called during the preRender phase, and is therefore free to modify the framebuffer contents to create the composite representation.
- Parameters:
dc
- The drawing context containing the surface objects to build a composite representation for.- See Also:
DrawContext.getOrderedSurfaceRenderables()
-
drawCompositeSurfaceObjects
protected void drawCompositeSurfaceObjects(DrawContext dc)
Causes the scene controller to draw the composite representation of allSurfaceObject
instances in the draw context's ordered surface renderable queue. This representation was built during the preRender phase. This does nothing if the ordered surface renderable queue is empty, or if it does not contain any SurfaceObjects.- Parameters:
dc
- The drawing context containing the surface objects who's composite representation is drawn.
-
-