|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgov.nasa.worldwind.render.SurfaceObjectTileBuilder
public class SurfaceObjectTileBuilder
Builds a list of SurfaceTile instances who's content is defined by a specified set
of SurfaceObject references. It's typically not necessary to use
SurfaceObjectTileBuilder directly. World Wind's default SceneController automatically
batches instances of SurfaceObject in a single SurfaceObjectTileBuilder.
Applications that need to draw basic surface shapes should use or extend SurfaceShape instead of using SurfaceObjectTileBuilder directly.
buildTiles(DrawContext, Iterable) (DrawContext, Iterable)} with an
Iterable of SurfaceObjects. This assembles a set of surface tiles that meet the resolution requirements for the
specified draw context, then draws the SurfaceObjects into those offscreen surface tiles by calling SurfaceObject.render(DrawContext). This process may temporarily use the framebuffer to
perform offscreen rendering, and therefore should be called during the preRender method of a World Wind Layer. See PreRenderable for details. Once built, the
surface tiles can be rendered by a SurfaceTileRenderer.
By default, SurfaceObjectTileBuilder creates texture tiles with a width and height of 512 pixels, and with internal
format GL_RGBA. These parameters are configurable by calling setTileDimension(java.awt.Dimension) or setTileTextureFormat(int).
The most common usage pattern for SurfaceObjectTileBuilder is to build the surface tiles from a set of SurfaceObjects
during the preRender phase, then draw those surface tiles during the render phase. For example, a Renderable can use SurfaceObjectTileBuilder to draw a set of SurfaceObjects as follows:
class MyRenderable implements Renderable, PreRenderable
{
protected SurfaceObjectTileBuilder tileBuilder = new SurfaceObjectTileBuilder();
protected ArrayList tiles = new ArrayList();
public void preRender(DrawContext dc)
{
List> surfaceObjects = Arrays.asList(
new SurfaceCircle(LatLon.fromDegrees(0, 100), 10000),
new SurfaceSquare(LatLon.fromDegrees(0, 101), 10000));
this.tiles.addAll(this.tileBuilder.buildSurfaceTiles(dc, surfaceObjects));
}
public void render(DrawContext dc)
{
dc.getGeographicSurfaceTileRenderer().renderTiles(dc, this.tiles);
}
}
| Nested Class Summary | |
|---|---|
protected static class |
SurfaceObjectTileBuilder.SurfaceObjectTile
Represents a TextureTile who's contents is constructed by a set of surface
objects. |
protected static class |
SurfaceObjectTileBuilder.SurfaceObjectTileStateKey
Represents a surface object tile's current state. |
| Field Summary | |
|---|---|
protected List<SurfaceObject> |
currentSurfaceObjects
List of currently assembled surface objects. |
protected Dimension |
currentTileDimension
Indicates the currently used tile texture width and height, in pixels. |
protected List<SurfaceObjectTileBuilder.SurfaceObjectTile> |
currentTiles
List of currently assembled surface tiles. |
protected static LatLon |
DEFAULT_LEVEL_ZERO_TILE_DELTA
The default level zero tile delta used to construct a LevelSet. |
protected static int |
DEFAULT_NUM_LEVELS
The default number of levels used to construct a LevelSet. |
protected static double |
DEFAULT_SPLIT_SCALE
The default split scale. |
protected static int |
DEFAULT_TEXTURE_DIMENSION
The default surface tile texture dimension, in pixels. |
protected static int |
DEFAULT_TEXTURE_INTERNAL_FORMAT
The default OpenGL internal format used to create surface tile textures. |
protected static int |
DEFAULT_TEXTURE_PIXEL_FORMAT
The default OpenGL pixel format used to create surface tile textures. |
protected static Map<Dimension,LevelSet> |
levelSetMap
Map associating a tile texture dimension to its corresponding LevelSet. |
protected static long |
nextUniqueId
The next unique ID. |
protected OGLRenderToTextureSupport |
rttSupport
Support class used to render to an offscreen surface tile. |
protected double |
splitScale
Controls the tile resolution as distance changes between the globe's surface and the eye point. |
protected Map<Dimension,String> |
tileCacheNameMap
Map associating a tile texture dimension to a tile cache name. |
protected Dimension |
tileDimension
Indicates the desired tile texture width and height, in pixels. |
protected int |
tileTextureFormat
The surface tile OpenGL texture format. |
protected boolean |
useLinearFilter
Controls if surface tiles are rendered using a linear filter or a nearest-neighbor filter. |
protected boolean |
useMipmaps
Controls if mip-maps are generated for surface tile textures. |
| Constructor Summary | |
|---|---|
SurfaceObjectTileBuilder()
Constructs a new SurfaceObjectTileBuilder with a tile width and height of 512, with the default tile
texture format, with linear filtering enabled, and with mip-mapping disabled. |
|
SurfaceObjectTileBuilder(Dimension tileTextureDimension,
int tileTextureFormat,
boolean useLinearFilter,
boolean useMipmaps)
Constructs a new SurfaceObjectTileBuilder width the specified tile dimension, tile texture format, and flags specifying if linear filtering and mip-mapping are enabled. |
|
| Method Summary | |
|---|---|
protected void |
addIntersectingObjects(DrawContext dc,
SurfaceObjectTileBuilder.SurfaceObjectTile parent,
SurfaceObjectTileBuilder.SurfaceObjectTile tile)
Adds SurfaceObjects from the parent's object list to the specified tile's object list. |
protected void |
addTile(SurfaceObjectTileBuilder.SurfaceObjectTile tile)
Adds the specified tile to the tile builder's currentTiles list. |
protected void |
addTileOrDescendants(DrawContext dc,
LevelSet levelSet,
SurfaceObjectTileBuilder.SurfaceObjectTile parent,
SurfaceObjectTileBuilder.SurfaceObjectTile tile)
Potentially adds the specified tile or its descendants to the tile builder's currentTiles list. |
protected void |
assembleSurfaceObjects(Iterable<?> iterable)
Adds any SurfaceObjects in the specified Iterable to the tile builder's currentSurfaceObjects list. |
protected void |
assembleTiles(DrawContext dc)
Assembles a set of surface tiles that are visible in the specified DrawContext and meet the tile builder's resolution criteria. |
List<SurfaceTile> |
buildTiles(DrawContext dc,
Iterable<?> iterable)
Assembles the surface tiles and draws any SurfaceObjects in the iterable into those offscreen tiles. |
protected boolean |
canAssembleTiles(DrawContext dc)
Returns true if the draw context's viewport width and height are greater than zero. |
protected Dimension |
computeTextureTileDimension(DrawContext dc)
Returns the tile dimension used to create the tile textures for the specified DrawContext. |
protected static LevelSet |
createLevelSet(int tileWidth,
int tileHeight)
Returns a new LevelSet with the specified tile width and height. |
protected Object |
createSurfaceTileDrawContext(SurfaceObjectTileBuilder.SurfaceObjectTile tile)
Returns a new Object representing the drawing context for the specified tile. |
protected SurfaceObjectTileBuilder.SurfaceObjectTile |
createTile(Sector sector,
Level level,
int row,
int column,
String cacheName)
Returns a new SurfaceObjectTile corresponding to the specified sector, level, row, column, and cacheName. |
protected Object |
createTileKey(Level level,
int row,
int column,
String cacheName)
Returns a new tile key corresponding to the tile with the specified level, row, column,
and cacheName. |
protected Texture |
createTileTexture(DrawContext dc,
int width,
int height)
Returns a new surface tile texture for use on the specified draw context with the specified width and height. |
protected LevelSet |
getLevelSet(Dimension tileDimension)
Returns a shared LevelSet for the specified tileDimension. |
double |
getSplitScale()
Returns the split scale value controlling the tile's surface texel resolution relative to the distance between the globe's surface at the image position and the eye point. |
protected String |
getTileCacheName(Dimension tileDimension)
Indicates the tile cache name to use for the specified tileDimension. |
Dimension |
getTileDimension()
Returns the surface tile dimension. |
int |
getTileTextureFormat()
Returns the surface tile's OpenGL texture format, or 0 to indicate that the default format is used. |
protected boolean |
intersectsFrustum(DrawContext dc,
TextureTile tile)
Test if the tile intersects the specified draw context's frustum. |
protected boolean |
intersectsVisibleSector(DrawContext dc,
TextureTile tile)
Test if the specified tile intersects the draw context's visible sector. |
boolean |
isUseLinearFilter()
Returns if linear filtering is used when rendering surface tiles. |
boolean |
isUseMipmaps()
Returns if mip-maps are generated for surface tile textures. |
protected boolean |
meetsRenderCriteria(DrawContext dc,
LevelSet levelSet,
Tile tile)
Tests if the specified tile meets the rendering criteria on the specified draw context. |
protected boolean |
needToSplit(DrawContext dc,
Tile tile)
Tests if the specified tile must be split to meets the desired resolution on the specified draw context. |
protected String |
nextCacheName()
Returns a unique name appropriate for use as part of a cache name. |
protected static long |
nextUniqueId()
Returns the next unique integer associated with a SurfaceObjectTileBuilder. |
void |
setSplitScale(double splitScale)
Sets the parameter controlling the tile resolution as distance changes between the globe's surface and the eye point. |
void |
setTileDimension(Dimension dimension)
Specifies the preferred surface tile texture dimension. |
void |
setTileTextureFormat(int textureFormat)
Specifies the surface tile's OpenGL texture format. |
void |
setUseLinearFilter(boolean useLinearFilter)
Specifies if linear filtering should be used when rendering surface tiles. |
void |
setUseMipmaps(boolean useMipmaps)
Specifies if mip-maps should be generated for surface tile textures. |
protected void |
updateTile(DrawContext dc,
SurfaceObjectTileBuilder.SurfaceObjectTile tile)
Draws the current list of SurfaceObjects into the specified surface tile. |
protected void |
updateTiles(DrawContext dc)
Updates each SurfaceObjectTileBuilder.SurfaceObjectTile in the currentTiles list. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected List<SurfaceObject> currentSurfaceObjects
protected Dimension currentTileDimension
tileDimension if this value does not fit in the viewport, or is not a power of two.
Initially null.
protected List<SurfaceObjectTileBuilder.SurfaceObjectTile> currentTiles
protected static final LatLon DEFAULT_LEVEL_ZERO_TILE_DELTA
protected static final int DEFAULT_NUM_LEVELS
protected static final double DEFAULT_SPLIT_SCALE
protected static final int DEFAULT_TEXTURE_DIMENSION
protected static final int DEFAULT_TEXTURE_INTERNAL_FORMAT
protected static final int DEFAULT_TEXTURE_PIXEL_FORMAT
protected static Map<Dimension,LevelSet> levelSetMap
protected static long nextUniqueId
protected OGLRenderToTextureSupport rttSupport
protected double splitScale
protected Map<Dimension,String> tileCacheNameMap
protected Dimension tileDimension
DEFAULT_TEXTURE_DIMENSION.
protected int tileTextureFormat
protected boolean useLinearFilter
protected boolean useMipmaps
| Constructor Detail |
|---|
public SurfaceObjectTileBuilder()
512, with the default tile
texture format, with linear filtering enabled, and with mip-mapping disabled.
public SurfaceObjectTileBuilder(Dimension tileTextureDimension,
int tileTextureFormat,
boolean useLinearFilter,
boolean useMipmaps)
tileTextureDimension - the surface tile texture dimension, in pixels.tileTextureFormat - the surface tile OpenGL texture format, or 0 to use the default format.useLinearFilter - true to use linear filtering while rendering surface tiles; false to use
nearest-neighbor filtering.useMipmaps - true to generate mip-maps for surface tile textures; false otherwise.
IllegalArgumentException - if the tile dimension is null.| Method Detail |
|---|
protected void addIntersectingObjects(DrawContext dc,
SurfaceObjectTileBuilder.SurfaceObjectTile parent,
SurfaceObjectTileBuilder.SurfaceObjectTile tile)
dc - the current DrawContext.parent - the tile's parent.tile - the tile to add intersecting SurfaceObject to.protected void addTile(SurfaceObjectTileBuilder.SurfaceObjectTile tile)
currentTiles list.
tile - the tile to add.
protected void addTileOrDescendants(DrawContext dc,
LevelSet levelSet,
SurfaceObjectTileBuilder.SurfaceObjectTile parent,
SurfaceObjectTileBuilder.SurfaceObjectTile tile)
currentTiles list. The tile
and its descendants are discarded if the tile is not visible or does not intersect any SurfaceObjects in the
parent's surface object list. See SurfaceObjectTileBuilder.SurfaceObjectTile.getObjectList().
If the tile meet the tile builder's resolution criteria it's added to the tile builder's
currentTiles list. Otherwise, it's split into four sub-tiles and each tile is recursively processed.
See meetsRenderCriteria(DrawContext, gov.nasa.worldwind.util.LevelSet, gov.nasa.worldwind.util.Tile).
dc - the current DrawContext.levelSet - the tile's LevelSet.parent - the tile's parent, or null if the tile is a top level tile.tile - the tile to add.protected void assembleSurfaceObjects(Iterable<?> iterable)
currentSurfaceObjects list.
iterable - the Iterable to gather SurfaceObjects from.protected void assembleTiles(DrawContext dc)
currentTiles list.
During assembly each SurfaceObject in currentSurfaceObjects is sorted into the tiles they intersect. The
top level tiles are used as an index to quickly determine which tiles each SurfaceObjects intersects.
SurfaceObjects are sorted into sub-tiles by simple intersection tests. SurfaceObjects are added to each tile's
surface object list at most once. See SurfaceObjectTileBuilder.SurfaceObjectTile.addSurfaceObject(SurfaceObject,
gov.nasa.worldwind.geom.Sector). Tiles that don't intersect any SurfaceObjects are discarded.
dc - the DrawContext to assemble tiles for.
public List<SurfaceTile> buildTiles(DrawContext dc,
Iterable<?> iterable)
View.
This may temporarily use the framebuffer to perform offscreen rendering, and therefore should be called during
the preRender method of a World Wind Layer.
This returns an empty List if the specified iterable is null, is empty or contains no SurfaceObjects.
dc - the draw context to build tiles for.iterable - the iterable to gather SurfaceObjects from.
IllegalArgumentException - if the draw context is null.protected boolean canAssembleTiles(DrawContext dc)
dc - the DrawContext to test.
protected Dimension computeTextureTileDimension(DrawContext dc)
DrawContext. This
attempts to use the caller configured tileDimension, but always returns a dimension that is
is a power of two, is square, and fits in the DrawContext's viewport.
dc - the DrawContext to compute a texture tile dimension for.
DrawContext.
protected static LevelSet createLevelSet(int tileWidth,
int tileHeight)
DEFAULT_LEVEL_ZERO_TILE_DELTA, has number of levels equal to DEFAULT_NUM_LEVELS (with no empty levels). The LevelSets' cache name and dataset name dummy values, and should
not be used.
tileWidth - the LevelSet's tile width, in pixels.tileHeight - the LevelSet's tile height, in pixels.
protected Object createSurfaceTileDrawContext(SurfaceObjectTileBuilder.SurfaceObjectTile tile)
tile - The tile to create a context for.
protected SurfaceObjectTileBuilder.SurfaceObjectTile createTile(Sector sector,
Level level,
int row,
int column,
String cacheName)
sector, level, row, column, and cacheName.
sector - The tile's Sector.level - The tile's Level in a LevelSet.row - The tile's row in the Level, starting from 0 and increasing to the right.column - The tile's column in the Level, starting from 0 and increasing upward.cacheName - Tile tile's cache name.
protected Object createTileKey(Level level,
int row,
int column,
String cacheName)
level, row, column,
and cacheName.
level - The tile's Level in a LevelSet.row - The tile's row in the Level, starting from 0 and increasing to the right.column - The tile's column in the Level, starting from 0 and increasing upward.cacheName - Tile tile's cache name.
protected Texture createTileTexture(DrawContext dc,
int width,
int height)
tilePixelFormat. If
tilePixelFormat is zero, this returns a texture with internal format GL_RGBA8.
The returned texture's parameters are configured as follows: | Parameter Name | Value | ||||||||
|---|---|---|---|---|---|---|---|---|---|
GL.GL_TEXTURE_MIN_FILTER | GL_LINEAR_MIPMAP_LINEAR
if useLinearFilter and useMipmaps are both true, GL_LINEAR if
useLinearFilter is true and useMipmaps is false, and GL_NEAREST if
useLinearFilter is false. | ||||||||
GL.GL_TEXTURE_MAG_FILTER | GL_LINEAR
if useLinearFilter is true, GL_NEAREST if useLinearFilter is
false. | ||||||||
GL.GL_TEXTURE_WRAP_S | GL_CLAMP_TO_EDGE | ||||||||
GL.GL_TEXTURE_WRAP_T | GL_CLAMP_TO_EDGE | ||||||||
|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||