NASA World Wind

gov.nasa.worldwind.terrain
Class RectangularTessellator

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.terrain.RectangularTessellator
All Implemented Interfaces:
AVList, MessageListener, Tessellator, WWObject, PropertyChangeListener, EventListener

public class RectangularTessellator
extends WWObjectImpl
implements Tessellator


Nested Class Summary
protected static class RectangularTessellator.CacheKey
           
protected static class RectangularTessellator.RectTile
           
protected static class RectangularTessellator.RenderInfo
           
 
Field Summary
protected static String CACHE_ID
           
protected static 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 HashMap<Integer,ByteBuffer> evenRowColorList
           
protected  Globe globe
           
protected static HashMap<Integer,IntBuffer> indexLists
           
protected static HashMap<Integer,Object> indexListsVboCacheKeys
           
protected  boolean makeTileSkirts
           
protected  int maxLevel
           
protected  int numLevel0LatSubdivisions
           
protected  int numLevel0LonSubdivisions
           
protected static HashMap<Integer,ByteBuffer> oddRowColorList
           
protected  PickSupport pickSupport
           
protected static HashMap<Integer,FloatBuffer> textureCoords
           
protected static HashMap<Integer,Object> textureCoordVboCacheKeys
           
protected  ArrayList<RectangularTessellator.RectTile> topLevels
           
protected  long updateFrequency
           
 
Constructor Summary
RectangularTessellator()
           
 
Method Summary
protected static Vec4 applyOffset(Globe globe, Vec4 point, double metersOffset)
          Offsets point by metersOffset 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  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  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, IntBuffer indices)
           
protected  int[] fillTextureCoordsVbo(DrawContext dc, int density, 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 a Point that sits at xDec offset from column to column + 1 and at yDec offset from row to row + 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 a RectTile geometry.
 boolean isMakeTileSkirts()
          Indicates whether the tessellator creates "skirts" around the tiles in order to hide gaps between adjacent tiles with differing tessellations.
protected  DoubleBuffer makeGeographicTexCoords(SectorGeometry sg, SectorGeometry.GeographicTextureCoordinateComputer computer)
           
protected  void makeVerts(DrawContext dc, RectangularTessellator.RectTile tile)
           
protected  boolean needToSplit(DrawContext dc, RectangularTessellator.RectTile tile)
           
protected  PickedObject[] pick(DrawContext dc, RectangularTessellator.RectTile tile, List<? extends Point> pickPoints)
           
protected  void pick(DrawContext dc, RectangularTessellator.RectTile tile, Point pickPoint)
           
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, 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  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, finalize, 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 java.beans.PropertyChangeListener
propertyChange
 
Methods inherited from interface gov.nasa.worldwind.event.MessageListener
onMessage
 

Field Detail

CACHE_ID

protected static final String CACHE_ID

CACHE_NAME

protected static final String CACHE_NAME
See Also:
Constant Field Values

currentCoverage

protected Sector currentCoverage

currentFrustum

protected Frustum currentFrustum

currentLevel

protected int currentLevel

currentTiles

protected SectorGeometryList currentTiles

DEFAULT_DENSITY

protected static final int DEFAULT_DENSITY
See Also:
Constant Field Values

DEFAULT_LOG10_RESOLUTION_TARGET

protected static final double DEFAULT_LOG10_RESOLUTION_TARGET
See Also:
Constant Field Values

DEFAULT_MAX_LEVEL

protected static final int DEFAULT_MAX_LEVEL
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

density

protected int density

evenRowColorList

protected static final HashMap<Integer,ByteBuffer> evenRowColorList

globe

protected Globe globe

indexLists

protected static final HashMap<Integer,IntBuffer> indexLists

indexListsVboCacheKeys

protected static final HashMap<Integer,Object> indexListsVboCacheKeys

makeTileSkirts

protected boolean makeTileSkirts

maxLevel

protected int maxLevel

numLevel0LatSubdivisions

protected int numLevel0LatSubdivisions

numLevel0LonSubdivisions

protected int numLevel0LonSubdivisions

oddRowColorList

protected static final HashMap<Integer,ByteBuffer> oddRowColorList

pickSupport

protected PickSupport pickSupport

textureCoords

protected static final HashMap<Integer,FloatBuffer> textureCoords

textureCoordVboCacheKeys

protected static final HashMap<Integer,Object> textureCoordVboCacheKeys

topLevels

protected ArrayList<RectangularTessellator.RectTile> topLevels

updateFrequency

protected long updateFrequency
Constructor Detail

RectangularTessellator

public RectangularTessellator()
Method Detail

applyOffset

protected static Vec4 applyOffset(Globe globe,
                                  Vec4 point,
                                  double metersOffset)
Offsets point by metersOffset meters.

Parameters:
globe - the Globe from which to offset
point - the Vec4 to offset
metersOffset - the magnitude of the offset
Returns:
point offset along its surface normal as if it were on globe

atBestResolution

protected boolean atBestResolution(DrawContext dc,
                                   RectangularTessellator.RectTile tile)

baryCentricCoordsRequireInside

protected static double[] baryCentricCoordsRequireInside(Vec4 pnt,
                                                         Vec4[] V)

beginRendering

public void beginRendering(DrawContext dc)

bindVbos

protected boolean bindVbos(DrawContext dc,
                           RectangularTessellator.RectTile tile,
                           int numTextureUnits)

buildVerts

public boolean buildVerts(DrawContext dc,
                          RectangularTessellator.RectTile tile,
                          boolean makeSkirts)

computeLocations

protected ArrayList<LatLon> computeLocations(RectangularTessellator.RectTile tile)

computeTileResolutionTarget

protected double computeTileResolutionTarget(DrawContext dc,
                                             RectangularTessellator.RectTile tile)

createCacheKey

protected RectangularTessellator.CacheKey createCacheKey(DrawContext dc,
                                                         RectangularTessellator.RectTile tile)

createIndices

protected static void createIndices(int density)

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 position
decimal - the distance from the left or bottom of the current sector that this position falls
density - 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

createTextureCoordinates

protected static void createTextureCoordinates(int density)

createTile

protected RectangularTessellator.RectTile createTile(DrawContext dc,
                                                     Sector tileSector,
                                                     int level)

createTopLevelTiles

protected ArrayList<RectangularTessellator.RectTile> createTopLevelTiles(DrawContext dc)

distanceFromLine

protected static double distanceFromLine(Vec4 pnt,
                                         Vec4 P,
                                         Vec4 u)

endRendering

public void endRendering(DrawContext dc)

fillIndexListVbo

protected int[] fillIndexListVbo(DrawContext dc,
                                 int density,
                                 IntBuffer indices)

fillTextureCoordsVbo

protected int[] fillTextureCoordsVbo(DrawContext dc,
                                     int density,
                                     FloatBuffer texCoords)

getSurfacePoint

protected Vec4 getSurfacePoint(RectangularTessellator.RectTile tile,
                               Angle latitude,
                               Angle longitude)

getSurfacePoint

protected Vec4 getSurfacePoint(RectangularTessellator.RectTile tile,
                               Angle latitude,
                               Angle longitude,
                               double metersOffset)

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 interface Tessellator
Returns:
the update frequency, in milliseconds.

interpolate

protected static Vec4 interpolate(int row,
                                  int column,
                                  double xDec,
                                  double yDec,
                                  RectangularTessellator.RenderInfo ri)
Calculates a Point that sits at xDec offset from column to column + 1 and at yDec offset from row to row + 1. Accounts for the diagonals.

Parameters:
row - represents the row which corresponds to a yDec value of 0
column - represents the column which corresponds to an xDec value of 0
xDec - 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 corner
bR - the bottom right corner
tR - the top right corner
tL - the top left corner
xDec - how far along, [0,1] 0 = left edge, 1 = right edge
yDec - 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

intersect

protected Intersection[] intersect(RectangularTessellator.RectTile tile,
                                   double elevation)

intersect

protected Intersection[] intersect(RectangularTessellator.RectTile tile,
                                   Line line)
Determines if and where a ray intersects a RectTile geometry.

Parameters:
tile - the RectTile 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.

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 interface Tessellator
Returns:
true if skirts are created, otherwise false.

makeGeographicTexCoords

protected DoubleBuffer makeGeographicTexCoords(SectorGeometry sg,
                                               SectorGeometry.GeographicTextureCoordinateComputer computer)

makeVerts

protected void makeVerts(DrawContext dc,
                         RectangularTessellator.RectTile tile)

needToSplit

protected boolean needToSplit(DrawContext dc,
                              RectangularTessellator.RectTile tile)

pick

protected PickedObject[] pick(DrawContext dc,
                              RectangularTessellator.RectTile tile,
                              List<? extends Point> pickPoints)

pick

protected void pick(DrawContext dc,
                    RectangularTessellator.RectTile tile,
                    Point pickPoint)

render

protected void render(DrawContext dc,
                      RectangularTessellator.RectTile tile)

render

protected long render(DrawContext dc,
                      RectangularTessellator.RectTile tile,
                      int numTextureUnits)

renderBoundingVolume

protected void renderBoundingVolume(DrawContext dc,
                                    RectangularTessellator.RectTile tile)

renderMultiTexture

protected void renderMultiTexture(DrawContext dc,
                                  RectangularTessellator.RectTile tile,
                                  int numTextureUnits)

renderPatchBoundary

protected void renderPatchBoundary(DrawContext dc,
                                   RectangularTessellator.RectTile tile)

renderTileID

protected void renderTileID(DrawContext dc,
                            RectangularTessellator.RectTile tile)

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.

renderVA

protected void renderVA(DrawContext dc,
                        RectangularTessellator.RectTile tile,
                        int numTextureUnits)

renderVBO

protected boolean renderVBO(DrawContext dc,
                            RectangularTessellator.RectTile tile,
                            int numTextureUnits)

renderWireframe

protected void renderWireframe(DrawContext dc,
                               RectangularTessellator.RectTile tile,
                               boolean showTriangles,
                               boolean showTileBoundary)

resolvePick

protected PickedObject resolvePick(DrawContext dc,
                                   RectangularTessellator.RectTile tile,
                                   Point pickPoint)

selectVisibleTiles

protected void selectVisibleTiles(DrawContext dc,
                                  RectangularTessellator.RectTile tile)

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 interface Tessellator
Parameters:
makeTileSkirts - true if skirts are created, otherwise false.

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 interface Tessellator
Parameters:
updateFrequency - the update frequency, in milliseconds.

split

protected RectangularTessellator.RectTile[] split(DrawContext dc,
                                                  RectangularTessellator.RectTile tile)

tessellate

public SectorGeometryList tessellate(DrawContext dc)
Description copied from interface: Tessellator
Tessellate a globe for the currently visible region.

Specified by:
tessellate in interface Tessellator
Parameters:
dc - the current draw context.
Returns:
the tessellation, or null if the tessellation failed or the draw context identifies no visible region.

NASA World Wind