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 class
RectangularTessellator.CacheKey
protected static class
RectangularTessellator.RectTile
protected static class
RectangularTessellator.RenderInfo
protected static class
RectangularTessellator.TopLevelTiles
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
CACHE_ID
protected static java.lang.String
CACHE_NAME
protected Sector
currentCoverage
protected Frustum
currentFrustum
protected int
currentLevel
protected SectorGeometryList
currentTiles
protected static int
DEFAULT_DENSITY
protected static double
DEFAULT_LOG10_RESOLUTION_TARGET
protected static int
DEFAULT_MAX_LEVEL
protected static int
DEFAULT_NUM_LAT_SUBDIVISIONS
protected static int
DEFAULT_NUM_LON_SUBDIVISIONS
protected int
density
protected static java.util.HashMap<java.lang.Integer,java.nio.ByteBuffer>
evenRowColorList
protected Globe
globe
protected static java.util.HashMap<java.lang.Integer,java.nio.IntBuffer>
indexLists
protected static java.util.HashMap<java.lang.Integer,java.lang.Object>
indexListsVboCacheKeys
protected boolean
makeTileSkirts
protected int
maxLevel
protected int
numLevel0LatSubdivisions
protected int
numLevel0LonSubdivisions
protected static java.util.HashMap<java.lang.Integer,java.nio.ByteBuffer>
oddRowColorList
protected PickSupport
pickSupport
protected static java.util.HashMap<java.lang.Integer,java.nio.FloatBuffer>
textureCoords
protected static java.util.HashMap<java.lang.Integer,java.lang.Object>
textureCoordVboCacheKeys
protected SessionCache
topLevelTilesCache
protected long
updateFrequency
-
Constructor Summary
Constructors Constructor Description RectangularTessellator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static Vec4
applyOffset(Globe globe, Vec4 point, double metersOffset)
Offsetspoint
bymetersOffset
meters.protected boolean
atBestResolution(DrawContext dc, RectangularTessellator.RectTile tile)
protected static double[]
baryCentricCoordsRequireInside(Vec4 pnt, Vec4[] V)
void
beginRendering(DrawContext dc)
protected boolean
bindVbos(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
boolean
buildVerts(DrawContext dc, RectangularTessellator.RectTile tile, boolean makeSkirts)
protected java.util.ArrayList<LatLon>
computeLocations(RectangularTessellator.RectTile tile)
protected double
computeTileResolutionTarget(DrawContext dc, RectangularTessellator.RectTile tile)
protected RectangularTessellator.CacheKey
createCacheKey(DrawContext dc, RectangularTessellator.RectTile tile)
protected static void
createIndices(int density)
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].protected static void
createTextureCoordinates(int density)
protected RectangularTessellator.RectTile
createTile(DrawContext dc, Sector tileSector, int level)
protected java.util.ArrayList<RectangularTessellator.RectTile>
createTopLevelTiles(DrawContext dc)
protected static double
distanceFromLine(Vec4 pnt, Vec4 P, Vec4 u)
void
endRendering(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 Vec4
getSurfacePoint(RectangularTessellator.RectTile tile, Angle latitude, Angle longitude)
protected Vec4
getSurfacePoint(RectangularTessellator.RectTile tile, Angle latitude, Angle longitude, double metersOffset)
long
getUpdateFrequency()
Indicates the maximum amount of time that may elapse between re-tessellation.protected static Vec4
interpolate(int row, int column, double xDec, double yDec, RectangularTessellator.RenderInfo ri)
Calculates aPoint
that sits atxDec
offset fromcolumn
tocolumn + 1
and atyDec
offset fromrow
torow + 1
.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}.protected Intersection[]
intersect(RectangularTessellator.RectTile tile, double elevation)
protected Intersection[]
intersect(RectangularTessellator.RectTile tile, Line line)
Determines if and where a ray intersects aRectTile
geometry.boolean
isMakeTileSkirts()
Indicates whether the tessellator creates "skirts" around the tiles in order to hide gaps between adjacent tiles with differing tessellations.protected java.nio.DoubleBuffer
makeGeographicTexCoords(SectorGeometry sg, SectorGeometry.GeographicTextureCoordinateComputer computer)
protected void
makeVerts(DrawContext dc, RectangularTessellator.RectTile tile)
protected boolean
needToSplit(DrawContext dc, RectangularTessellator.RectTile tile)
protected void
pick(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 void
render(DrawContext dc, RectangularTessellator.RectTile tile)
protected long
render(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
protected void
renderBoundingVolume(DrawContext dc, RectangularTessellator.RectTile tile)
protected void
renderMultiTexture(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
protected void
renderPatchBoundary(DrawContext dc, RectangularTessellator.RectTile tile)
protected void
renderTileID(DrawContext dc, RectangularTessellator.RectTile tile)
protected void
renderTrianglesWithUniqueColors(DrawContext dc, RectangularTessellator.RectTile tile)
Render each triangle of a tile in a unique color.protected void
renderVA(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
protected boolean
renderVBO(DrawContext dc, RectangularTessellator.RectTile tile, int numTextureUnits)
protected void
renderWireframe(DrawContext dc, RectangularTessellator.RectTile tile, boolean showTriangles, boolean showTileBoundary)
protected PickedObject
resolvePick(DrawContext dc, RectangularTessellator.RectTile tile, java.awt.Point pickPoint)
protected void
selectVisibleTiles(DrawContext dc, RectangularTessellator.RectTile tile)
void
setMakeTileSkirts(boolean makeTileSkirts)
Specifies whether the tessellator creates "skirts" around the tiles in order to hide gaps between adjacent tiles with differing tessellations.void
setUpdateFrequency(long updateFrequency)
Indicates the maximum amount of time that may elapse between re-tessellation.protected boolean
skipTile(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)
SectorGeometryList
tessellate(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:Tessellator
Tessellate a globe for the currently visible region.- Specified by:
tessellate
in 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:
true
if 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:Tessellator
Indicates whether the tessellator creates "skirts" around the tiles in order to hide gaps between adjacent tiles with differing tessellations.- Specified by:
isMakeTileSkirts
in interfaceTessellator
- Returns:
- true if skirts are created, otherwise false.
-
setMakeTileSkirts
public void setMakeTileSkirts(boolean makeTileSkirts)
Description copied from interface:Tessellator
Specifies whether the tessellator creates "skirts" around the tiles in order to hide gaps between adjacent tiles with differing tessellations.- Specified by:
setMakeTileSkirts
in interfaceTessellator
- Parameters:
makeTileSkirts
- true if skirts are created, otherwise false.
-
getUpdateFrequency
public long getUpdateFrequency()
Description copied from interface:Tessellator
Indicates 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:
getUpdateFrequency
in interfaceTessellator
- Returns:
- the update frequency, in milliseconds.
-
setUpdateFrequency
public void setUpdateFrequency(long updateFrequency)
Description copied from interface:Tessellator
Indicates 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:
setUpdateFrequency
in 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 aRectTile
geometry.- Parameters:
tile
- theRectTile
which geometry is to be tested for intersection.line
- the ray for which an intersection is to be found.- Returns:
- an array of
Intersection
sorted 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)
Offsetspoint
bymetersOffset
meters.- Parameters:
globe
- theGlobe
from which to offsetpoint
- theVec4
to offsetmetersOffset
- the magnitude of the offset- Returns:
point
offset 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 aPoint
that sits atxDec
offset fromcolumn
tocolumn + 1
and atyDec
offset fromrow
torow + 1
. Accounts for the diagonals.- Parameters:
row
- represents the row which corresponds to ayDec
value of 0column
- represents the column which corresponds to anxDec
value of 0xDec
- constrained to [0,1]yDec
- constrained to [0,1]ri
- the render info holding the vertices, etc.- Returns:
- a
Point
geometrically 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)
-
-