Package gov.nasa.worldwind.terrain
Class RectangularTessellator
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.terrain.RectangularTessellator
-
- All Implemented Interfaces:
AVList,MessageListener,Tessellator,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
public class RectangularTessellator extends WWObjectImpl implements Tessellator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classRectangularTessellator.CacheKeyprotected static classRectangularTessellator.RectTileprotected static classRectangularTessellator.RenderInfoprotected static classRectangularTessellator.TopLevelTiles
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCACHE_IDprotected static java.lang.StringCACHE_NAMEprotected SectorcurrentCoverageprotected FrustumcurrentFrustumprotected intcurrentLevelprotected SectorGeometryListcurrentTilesprotected static intDEFAULT_DENSITYprotected static doubleDEFAULT_LOG10_RESOLUTION_TARGETprotected static intDEFAULT_MAX_LEVELprotected static intDEFAULT_NUM_LAT_SUBDIVISIONSprotected static intDEFAULT_NUM_LON_SUBDIVISIONSprotected intdensityprotected static java.util.HashMap<java.lang.Integer,java.nio.ByteBuffer>evenRowColorListprotected Globeglobeprotected static java.util.HashMap<java.lang.Integer,java.nio.IntBuffer>indexListsprotected static java.util.HashMap<java.lang.Integer,java.lang.Object>indexListsVboCacheKeysprotected booleanmakeTileSkirtsprotected intmaxLevelprotected intnumLevel0LatSubdivisionsprotected intnumLevel0LonSubdivisionsprotected static java.util.HashMap<java.lang.Integer,java.nio.ByteBuffer>oddRowColorListprotected PickSupportpickSupportprotected static java.util.HashMap<java.lang.Integer,java.nio.FloatBuffer>textureCoordsprotected static java.util.HashMap<java.lang.Integer,java.lang.Object>textureCoordVboCacheKeysprotected SessionCachetopLevelTilesCacheprotected longupdateFrequency
-
Constructor Summary
Constructors Constructor Description RectangularTessellator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static Vec4applyOffset(Globe globe, Vec4 point, double metersOffset)OffsetspointbymetersOffsetmeters.protected booleanatBestResolution(DrawContext dc, RectangularTessellator.RectTile tile)protected static double[]baryCentricCoordsRequireInside(Vec4 pnt, Vec4[] V)voidbeginRendering(DrawContext dc)protected booleanbindVbos(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)booleanbuildVerts(DrawContext dc, RectangularTessellator.RectTile tile, boolean makeSkirts)protected java.util.ArrayList<LatLon>computeLocations(RectangularTessellator.RectTile tile)protected doublecomputeTileResolutionTarget(DrawContext dc, RectangularTessellator.RectTile tile)protected RectangularTessellator.CacheKeycreateCacheKey(DrawContext dc, RectangularTessellator.RectTile tile)protected static voidcreateIndices(int density)protected static doublecreatePosition(int start, double decimal, int density)Computes from a column (or row) number, and a given offset ranged [0,1] corresponding to the distance along the edge of this sector, where between this column and the next column the corresponding position will fall, in the range [0,1].protected static voidcreateTextureCoordinates(int density)protected RectangularTessellator.RectTilecreateTile(DrawContext dc, Sector tileSector, int level)protected java.util.ArrayList<RectangularTessellator.RectTile>createTopLevelTiles(DrawContext dc)protected static doubledistanceFromLine(Vec4 pnt, Vec4 P, Vec4 u)voidendRendering(DrawContext dc)protected int[]fillIndexListVbo(DrawContext dc, int density, java.nio.IntBuffer indices)protected int[]fillTextureCoordsVbo(DrawContext dc, int density, java.nio.FloatBuffer texCoords)protected Vec4getSurfacePoint(RectangularTessellator.RectTile tile, Angle latitude, Angle longitude)protected Vec4getSurfacePoint(RectangularTessellator.RectTile tile, Angle latitude, Angle longitude, double metersOffset)longgetUpdateFrequency()Indicates the maximum amount of time that may elapse between re-tessellation.protected static Vec4interpolate(int row, int column, double xDec, double yDec, RectangularTessellator.RenderInfo ri)Calculates aPointthat sits atxDecoffset fromcolumntocolumn + 1and atyDecoffset fromrowtorow + 1.protected static Vec4interpolate(Vec4 bL, Vec4 bR, Vec4 tR, Vec4 tL, double xDec, double yDec)Calculates the point at (xDec, yDec) in the two triangles defined by {bL, bR, tL} and {bR, tR, tL}.protected Intersection[]intersect(RectangularTessellator.RectTile tile, double elevation)protected Intersection[]intersect(RectangularTessellator.RectTile tile, Line line)Determines if and where a ray intersects aRectTilegeometry.booleanisMakeTileSkirts()Indicates whether the tessellator creates "skirts" around the tiles in order to hide gaps between adjacent tiles with differing tessellations.protected java.nio.DoubleBuffermakeGeographicTexCoords(SectorGeometry sg, SectorGeometry.GeographicTextureCoordinateComputer computer)protected voidmakeVerts(DrawContext dc, RectangularTessellator.RectTile tile)protected booleanneedToSplit(DrawContext dc, RectangularTessellator.RectTile tile)protected voidpick(DrawContext dc, RectangularTessellator.RectTile tile, java.awt.Point pickPoint)protected PickedObject[]pick(DrawContext dc, RectangularTessellator.RectTile tile, java.util.List<? extends java.awt.Point> pickPoints)protected voidrender(DrawContext dc, RectangularTessellator.RectTile tile)protected longrender(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)protected voidrenderBoundingVolume(DrawContext dc, RectangularTessellator.RectTile tile)protected voidrenderMultiTexture(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)protected voidrenderPatchBoundary(DrawContext dc, RectangularTessellator.RectTile tile)protected voidrenderTileID(DrawContext dc, RectangularTessellator.RectTile tile)protected voidrenderTrianglesWithUniqueColors(DrawContext dc, RectangularTessellator.RectTile tile)Render each triangle of a tile in a unique color.protected voidrenderVA(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)protected booleanrenderVBO(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)protected voidrenderWireframe(DrawContext dc, RectangularTessellator.RectTile tile, boolean showTriangles, boolean showTileBoundary)protected PickedObjectresolvePick(DrawContext dc, RectangularTessellator.RectTile tile, java.awt.Point pickPoint)protected voidselectVisibleTiles(DrawContext dc, RectangularTessellator.RectTile tile)voidsetMakeTileSkirts(boolean makeTileSkirts)Specifies whether the tessellator creates "skirts" around the tiles in order to hide gaps between adjacent tiles with differing tessellations.voidsetUpdateFrequency(long updateFrequency)Indicates the maximum amount of time that may elapse between re-tessellation.protected booleanskipTile(DrawContext dc, Sector sector)Determines whether a tile is within a 2D globe's projection limits.protected RectangularTessellator.RectTile[]split(DrawContext dc, RectangularTessellator.RectTile tile)SectorGeometryListtessellate(DrawContext dc)Tessellate a globe for the currently visible region.-
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
-
DEFAULT_MAX_LEVEL
protected static final int DEFAULT_MAX_LEVEL
- See Also:
- Constant Field Values
-
DEFAULT_LOG10_RESOLUTION_TARGET
protected static final double DEFAULT_LOG10_RESOLUTION_TARGET
- See Also:
- Constant Field Values
-
DEFAULT_NUM_LAT_SUBDIVISIONS
protected static final int DEFAULT_NUM_LAT_SUBDIVISIONS
- See Also:
- Constant Field Values
-
DEFAULT_NUM_LON_SUBDIVISIONS
protected static final int DEFAULT_NUM_LON_SUBDIVISIONS
- See Also:
- Constant Field Values
-
DEFAULT_DENSITY
protected static final int DEFAULT_DENSITY
- See Also:
- Constant Field Values
-
CACHE_NAME
protected static final java.lang.String CACHE_NAME
- See Also:
- Constant Field Values
-
CACHE_ID
protected static final java.lang.String CACHE_ID
-
textureCoords
protected static final java.util.HashMap<java.lang.Integer,java.nio.FloatBuffer> textureCoords
-
indexLists
protected static final java.util.HashMap<java.lang.Integer,java.nio.IntBuffer> indexLists
-
oddRowColorList
protected static final java.util.HashMap<java.lang.Integer,java.nio.ByteBuffer> oddRowColorList
-
evenRowColorList
protected static final java.util.HashMap<java.lang.Integer,java.nio.ByteBuffer> evenRowColorList
-
textureCoordVboCacheKeys
protected static final java.util.HashMap<java.lang.Integer,java.lang.Object> textureCoordVboCacheKeys
-
indexListsVboCacheKeys
protected static final java.util.HashMap<java.lang.Integer,java.lang.Object> indexListsVboCacheKeys
-
numLevel0LatSubdivisions
protected int numLevel0LatSubdivisions
-
numLevel0LonSubdivisions
protected int numLevel0LonSubdivisions
-
topLevelTilesCache
protected SessionCache topLevelTilesCache
-
pickSupport
protected PickSupport pickSupport
-
currentTiles
protected SectorGeometryList currentTiles
-
currentFrustum
protected Frustum currentFrustum
-
currentCoverage
protected Sector currentCoverage
-
makeTileSkirts
protected boolean makeTileSkirts
-
currentLevel
protected int currentLevel
-
maxLevel
protected int maxLevel
-
globe
protected Globe globe
-
density
protected int density
-
updateFrequency
protected long updateFrequency
-
-
Method Detail
-
tessellate
public SectorGeometryList tessellate(DrawContext dc)
Description copied from interface:TessellatorTessellate a globe for the currently visible region.- Specified by:
tessellatein interfaceTessellator- Parameters:
dc- the current draw context.- Returns:
- the tessellation, or null if the tessellation failed or the draw context identifies no visible region.
-
createTopLevelTiles
protected java.util.ArrayList<RectangularTessellator.RectTile> createTopLevelTiles(DrawContext dc)
-
skipTile
protected boolean skipTile(DrawContext dc, Sector sector)
Determines whether a tile is within a 2D globe's projection limits.- Parameters:
dc- the current draw context. The globe contained in the context must be aGlobe2D.sector- the tile's sector.- Returns:
trueif the tile should be skipped -- it's outside the globe's projection limits -- otherwisefalse.
-
createTile
protected RectangularTessellator.RectTile createTile(DrawContext dc, Sector tileSector, int level)
-
isMakeTileSkirts
public boolean isMakeTileSkirts()
Description copied from interface:TessellatorIndicates whether the tessellator creates "skirts" around the tiles in order to hide gaps between adjacent tiles with differing tessellations.- Specified by:
isMakeTileSkirtsin interfaceTessellator- Returns:
- true if skirts are created, otherwise false.
-
setMakeTileSkirts
public void setMakeTileSkirts(boolean makeTileSkirts)
Description copied from interface:TessellatorSpecifies whether the tessellator creates "skirts" around the tiles in order to hide gaps between adjacent tiles with differing tessellations.- Specified by:
setMakeTileSkirtsin interfaceTessellator- Parameters:
makeTileSkirts- true if skirts are created, otherwise false.
-
getUpdateFrequency
public long getUpdateFrequency()
Description copied from interface:TessellatorIndicates the maximum amount of time that may elapse between re-tessellation. Re-tessellation is performed to synchronize the terrain's resolution into with the current viewing state and availability of elevations.- Specified by:
getUpdateFrequencyin interfaceTessellator- Returns:
- the update frequency, in milliseconds.
-
setUpdateFrequency
public void setUpdateFrequency(long updateFrequency)
Description copied from interface:TessellatorIndicates the maximum amount of time that may elapse between re-tessellation. Re-tessellation is performed to synchronize the terrain's resolution into with the current viewing state and availability of elevations.- Specified by:
setUpdateFrequencyin interfaceTessellator- Parameters:
updateFrequency- the update frequency, in milliseconds.
-
selectVisibleTiles
protected void selectVisibleTiles(DrawContext dc, RectangularTessellator.RectTile tile)
-
atBestResolution
protected boolean atBestResolution(DrawContext dc, RectangularTessellator.RectTile tile)
-
needToSplit
protected boolean needToSplit(DrawContext dc, RectangularTessellator.RectTile tile)
-
computeTileResolutionTarget
protected double computeTileResolutionTarget(DrawContext dc, RectangularTessellator.RectTile tile)
-
split
protected RectangularTessellator.RectTile[] split(DrawContext dc, RectangularTessellator.RectTile tile)
-
createCacheKey
protected RectangularTessellator.CacheKey createCacheKey(DrawContext dc, RectangularTessellator.RectTile tile)
-
makeVerts
protected void makeVerts(DrawContext dc, RectangularTessellator.RectTile tile)
-
buildVerts
public boolean buildVerts(DrawContext dc, RectangularTessellator.RectTile tile, boolean makeSkirts)
-
computeLocations
protected java.util.ArrayList<LatLon> computeLocations(RectangularTessellator.RectTile tile)
-
renderMultiTexture
protected void renderMultiTexture(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
-
render
protected void render(DrawContext dc, RectangularTessellator.RectTile tile)
-
beginRendering
public void beginRendering(DrawContext dc)
-
endRendering
public void endRendering(DrawContext dc)
-
render
protected long render(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
-
renderVA
protected void renderVA(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
-
renderVBO
protected boolean renderVBO(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
-
bindVbos
protected boolean bindVbos(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
-
fillIndexListVbo
protected int[] fillIndexListVbo(DrawContext dc, int density, java.nio.IntBuffer indices)
-
fillTextureCoordsVbo
protected int[] fillTextureCoordsVbo(DrawContext dc, int density, java.nio.FloatBuffer texCoords)
-
renderWireframe
protected void renderWireframe(DrawContext dc, RectangularTessellator.RectTile tile, boolean showTriangles, boolean showTileBoundary)
-
renderPatchBoundary
protected void renderPatchBoundary(DrawContext dc, RectangularTessellator.RectTile tile)
-
renderBoundingVolume
protected void renderBoundingVolume(DrawContext dc, RectangularTessellator.RectTile tile)
-
renderTileID
protected void renderTileID(DrawContext dc, RectangularTessellator.RectTile tile)
-
pick
protected PickedObject[] pick(DrawContext dc, RectangularTessellator.RectTile tile, java.util.List<? extends java.awt.Point> pickPoints)
-
pick
protected void pick(DrawContext dc, RectangularTessellator.RectTile tile, java.awt.Point pickPoint)
-
renderTrianglesWithUniqueColors
protected void renderTrianglesWithUniqueColors(DrawContext dc, RectangularTessellator.RectTile tile)
Render each triangle of a tile in a unique color. Used during picking to identify triangles at the pick points.Note: This method modifies the GL_VERTEX_ARRAY and GL_COLOR_ARRAY state and does not restore it. Callers should ensure that GL_CLIENT_VERTEX_ARRAY_BIT has been pushed, and eventually pop it when done using this method.
- Parameters:
dc- the current draw context.tile- the tile to render.
-
resolvePick
protected PickedObject resolvePick(DrawContext dc, RectangularTessellator.RectTile tile, java.awt.Point pickPoint)
-
intersect
protected Intersection[] intersect(RectangularTessellator.RectTile tile, Line line)
Determines if and where a ray intersects aRectTilegeometry.- Parameters:
tile- theRectTilewhich geometry is to be tested for intersection.line- the ray for which an intersection is to be found.- Returns:
- an array of
Intersectionsorted by increasing distance from the line origin, or null if no intersection was found.
-
intersect
protected Intersection[] intersect(RectangularTessellator.RectTile tile, double elevation)
-
getSurfacePoint
protected Vec4 getSurfacePoint(RectangularTessellator.RectTile tile, Angle latitude, Angle longitude, double metersOffset)
-
applyOffset
protected static Vec4 applyOffset(Globe globe, Vec4 point, double metersOffset)
OffsetspointbymetersOffsetmeters.- Parameters:
globe- theGlobefrom which to offsetpoint- theVec4to offsetmetersOffset- the magnitude of the offset- Returns:
pointoffset along its surface normal as if it were onglobe
-
getSurfacePoint
protected Vec4 getSurfacePoint(RectangularTessellator.RectTile tile, Angle latitude, Angle longitude)
-
createPosition
protected static double createPosition(int start, double decimal, int density)Computes from a column (or row) number, and a given offset ranged [0,1] corresponding to the distance along the edge of this sector, where between this column and the next column the corresponding position will fall, in the range [0,1].- Parameters:
start- the number of the column or row to the left, below or on this positiondecimal- the distance from the left or bottom of the current sector that this position fallsdensity- the number of intervals along the sector's side- Returns:
- a decimal ranged [0,1] representing the position between two columns or rows, rather than between two edges of the sector
-
interpolate
protected static Vec4 interpolate(int row, int column, double xDec, double yDec, RectangularTessellator.RenderInfo ri)
Calculates aPointthat sits atxDecoffset fromcolumntocolumn + 1and atyDecoffset fromrowtorow + 1. Accounts for the diagonals.- Parameters:
row- represents the row which corresponds to ayDecvalue of 0column- represents the column which corresponds to anxDecvalue of 0xDec- constrained to [0,1]yDec- constrained to [0,1]ri- the render info holding the vertices, etc.- Returns:
- a
Pointgeometrically within or on the boundary of the quadrilateral whose bottom left corner is indexed by (row,column)
-
interpolate
protected static Vec4 interpolate(Vec4 bL, Vec4 bR, Vec4 tR, Vec4 tL, double xDec, double yDec)
Calculates the point at (xDec, yDec) in the two triangles defined by {bL, bR, tL} and {bR, tR, tL}. If thought of as a quadrilateral, the diagonal runs from tL to bR. Of course, this isn't a quad, it's two triangles.- Parameters:
bL- the bottom left cornerbR- the bottom right cornertR- the top right cornertL- the top left cornerxDec- how far along, [0,1] 0 = left edge, 1 = right edgeyDec- how far along, [0,1] 0 = bottom edge, 1 = top edge- Returns:
- the point xDec, yDec in the co-ordinate system defined by bL, bR, tR, tL
-
baryCentricCoordsRequireInside
protected static double[] baryCentricCoordsRequireInside(Vec4 pnt, Vec4[] V)
-
makeGeographicTexCoords
protected java.nio.DoubleBuffer makeGeographicTexCoords(SectorGeometry sg, SectorGeometry.GeographicTextureCoordinateComputer computer)
-
createTextureCoordinates
protected static void createTextureCoordinates(int density)
-
createIndices
protected static void createIndices(int density)
-
-