Class Polygon
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.render.AbstractShape
-
- gov.nasa.worldwind.render.Polygon
-
- All Implemented Interfaces:
AVList,Draggable,MessageListener,Exportable,ExtentHolder,Movable,Movable2,Attributable,GeographicExtent,Highlightable,OrderedRenderable,PreRenderable,Renderable,Restorable,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
- Direct Known Subclasses:
KMLGroundOverlayPolygonImpl,KMLPolygonImpl
public class Polygon extends AbstractShape
/** A 3D polygon. The polygon may be complex with multiple internal but not intersecting contours.Polygons are safe to share among WorldWindows. They should not be shared among layers in the same WorldWindow.
In order to support simultaneous use of this shape with multiple globes (windows), this shape maintains a cache of data computed relative to each globe. During rendering, the data for the currently active globe, as indicated in the draw context, is made current. Subsequently called methods rely on the existence of this current data cache entry.
When drawn on a 2D globe, this shape uses a
SurfacePolygonto represent itself. The following features are not provided in this case: rotation and texture.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classPolygon.BoundaryInfoHolds information for each contour of the polygon.protected static classPolygon.ShapeDataThis class holds globe-specific data for this shape.-
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.AbstractShape
AbstractShape.AbstractShapeData
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.util.List<? extends Position>>boundariesThe location of each vertex in this shape's boundaries.protected static java.util.HashMap<java.lang.Integer,java.nio.IntBuffer>edgeIndexBuffersThis static hash map holds the vertex indices that define the shape's visual outline.protected intnumPositionsThe total number of positions in the entire polygon.protected java.lang.ObjectpreviousIntersectionGlobeStateKeyThe globe state key for the globe used in the most recent intersection calculation.protected Polygon.ShapeDatapreviousIntersectionShapeDataThe shape data used for the previous intersection calculation.protected TerrainpreviousIntersectionTerrainThe terrain used in the most recent intersection calculations.protected java.lang.DoublerotationThis shape's rotation, in degrees positive counterclockwise.protected WWTexturetextureIf an image source was specified, this is the WWTexture form.protected java.nio.FloatBuffertextureCoordsBufferThis shape's texture coordinates.protected static intVBO_THRESHOLDIndicates the number of vertices that must be present in order for VBOs to be used to render this shape.-
Fields inherited from class gov.nasa.worldwind.render.AbstractShape
activeAttributes, altitudeMode, BEogsh, currentData, DEFAULT_ALTITUDE_MODE, DEFAULT_GEOMETRY_GENERATION_INTERVAL, DEFAULT_HIGHLIGHT_MATERIAL, DEFAULT_INTERIOR_MATERIAL, DEFAULT_OUTLINE_MATERIAL, DEFAULT_OUTLINE_PICK_WIDTH, defaultAttributes, delegateOwner, dragEnabled, draggableSupport, enableBatchPicking, enableBatchRendering, enableDepthOffset, highlightAttrs, highlighted, maxExpiryTime, minExpiryTime, normalAttrs, outlinePickWidth, outlineShapeRenderer, pickLayer, pickSupport, referencePosition, sector, shapeDataCache, surfaceShape, viewDistanceExpiration, visible
-
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
-
-
Constructor Summary
Constructors Constructor Description Polygon()Construct a polygon with an empty outer boundary.Polygon(Position.PositionList corners)Construct a polygon for a specified list of outer-boundary positions.Polygon(java.lang.Iterable<? extends Position> corners)Construct a polygon for a specified outer boundary.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddInnerBoundary(java.lang.Iterable<? extends Position> corners)Add an inner boundary to this polygon.protected OGLStackHandlerbeginDrawing(DrawContext dc, int attrMask)Establish the OpenGL state needed to draw this shape.voidclearIntersectionGeometry()protected java.nio.FloatBuffercomputeBoundaryNormals(Polygon.BoundaryInfo boundary, java.nio.FloatBuffer nBuf)Compute normal vectors for a boundary's vertices.protected voidcomputeBoundaryVertices(Terrain terrain, Polygon.BoundaryInfo boundary, Vec4 refPoint, Matrix rotationMatrix)Compute the vertices associated with a specified boundary.protected ExtentcomputeExtent(Polygon.BoundaryInfo boundary, Vec4 refPoint)Computes the Cartesian extent of a polygon boundary.protected doublecomputeEyeDistance(DrawContext dc, Polygon.ShapeData shapeData)Computes the minimum distance between this polygon and the eye point.protected Vec4computePolygonNormal(DrawContext dc, Polygon.ShapeData shapeData)protected Vec4computeReferencePoint(Terrain terrain, Matrix rotationMatrix)protected MatrixcomputeRotationMatrix(Globe globe)protected intcountPositions()Counts the total number of positions in this shape, including all positions in all boundaries.protected AbstractShape.AbstractShapeDatacreateCacheEntry(DrawContext dc)Creates and returns a new cache entry specific to the subclass.protected voidcreateFullGeometry(DrawContext dc, Terrain terrain, Polygon.ShapeData shapeData, boolean skipOuterBoundary)Computes a shape's full geometry.protected voidcreateGeometry(DrawContext dc, Polygon.ShapeData shapeData)Compute the cap geometry.protected Polygon.ShapeDatacreateIntersectionGeometry(Terrain terrain)protected voidcreateMinimalGeometry(DrawContext dc, Polygon.ShapeData shapeData)Compute enough geometry to determine this polygon's extent, reference point and eye distance.protected voidcreateNormals(Polygon.ShapeData shapeData)Create this shape's vertex normals.protected SurfaceShapecreateSurfaceShape()Returns aSurfaceShapethat corresponds to this Path and is used for drawing on 2D globes.protected voidcreateTessllationGeometry(DrawContext dc, Polygon.ShapeData shapeData)Tessellates the polygon.protected voidcreateVertices(Terrain terrain, Polygon.ShapeData shapeData, boolean skipOuterBoundary)Computes the Cartesian vertices for this shape.protected voiddoDrawInterior(DrawContext dc)Draws this shape's interior.protected voiddoDrawInteriorVA(DrawContext dc, Polygon.ShapeData shapeData)protected voiddoDrawInteriorVBO(DrawContext dc, int[] vboIds, Polygon.ShapeData shapeData)protected voiddoDrawOutline(DrawContext dc)Draws this shape's outline.protected voiddoDrawOutlineVA(DrawContext dc, Polygon.ShapeData shapeData)protected voiddoDrawOutlineVBO(DrawContext dc, int[] vboIds, Polygon.ShapeData shapeData)protected voiddoExportAsKML(javax.xml.stream.XMLStreamWriter xmlWriter)Exports shape-specific fields.protected booleandoMakeOrderedRenderable(DrawContext dc)Produces the geometry and other state necessary to represent this shape as an ordered renderable.protected voidexportBoundaryAsLinearRing(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.Iterable<? extends LatLon> boundary)Writes the boundary in KML as either a list of lat, lon, altitude tuples or lat, lon tuples, depending on the type originally specified.protected java.util.List<? extends Position>fillBoundary(java.lang.Iterable<? extends Position> corners)Copies a boundary's positions to this shape's internal boundary list.protected voidfillVBO(DrawContext dc)Fill this shape's vertex buffer objects.protected voidgenerateInteriorIndices(Polygon.ShapeData shapeData)java.util.List<java.util.List<? extends Position>>getBoundaries()Returns this shape's boundaries.protected Polygon.ShapeDatagetCurrent()Returns the current shape data cache entry.ExtentgetExtent(Globe globe, double verticalExaggeration)Returns the objects enclosing volume as anExtentin model coordinates, given a specifiedGlobeand vertical exaggeration (seeSceneController.getVerticalExaggeration().java.lang.Iterable<? extends LatLon>getOuterBoundary()Returns the list of positions defining this polygon's outer boundary.PositiongetReferencePosition()A position associated with the object that indicates its aggregate geographic position.java.lang.DoublegetRotation()Indicates the amount of rotation applied to this polygon.SectorgetSector()Returns the object's geographic extent.protected WWTexturegetTexture()Get the texture applied to this polygon.float[]getTextureCoords()Returns the texture coordinates for this polygon.java.lang.ObjectgetTextureImageSource()Returns this polygon's texture image source.protected voidinitialize()Called during construction to establish any subclass-specific state such as different default values than those set by this class.protected voidintersect(Line line, Polygon.ShapeData shapeData, java.util.List<Intersection> intersections)java.util.List<Intersection>intersect(Line line, Terrain terrain)Compute the intersections of a specified line with this polygon.protected booleanisOrderedRenderableValid(DrawContext dc)Determines whether this shape's ordered renderable state is valid and can be rendered.protected booleanisOuterBoundaryValid()protected booleanisSameAsPreviousTerrain(Terrain terrain)voidmoveTo(Position position)Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.voidmoveTo(Globe globe, Position position)Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.protected booleanmustApplyTexture(DrawContext dc)Indicates whether texture should be applied to this shape.protected booleanmustRegenerateGeometry(DrawContext dc)Indicates whether this shape's renderable geometry must be recomputed, either as a result of an attribute or property change or the expiration of the geometry regeneration interval.java.util.List<? extends Position>outerBoundary()Returns a reference to the outer boundary of this polygon.voidrender(DrawContext dc)Causes thisRenderableto render itself using the provided draw context.protected voidreset()Void any computed data.voidsetOuterBoundary(java.lang.Iterable<? extends Position> corners)Specifies the latitude, longitude and altitude of the outer boundary positions defining this polygon.voidsetRotation(java.lang.Double rotation)Specifies the amount of rotation applied to this polygon.protected voidsetSurfacePolygonBoundaries(SurfaceShape shape)protected voidsetSurfacePolygonTexImageSource(SurfaceShape shape)voidsetTextureImageSource(java.lang.Object imageSource, float[] texCoords, int texCoordCount)Specifies the texture to apply to this polygon.protected booleanshouldUseVBOs(DrawContext dc)Indicates whether this shape should use OpenGL vertex buffer objects.protected voidtessellatePolygon(Polygon.ShapeData shapeData, Vec4 normal)Tessellates the polygon from its vertices.protected voidwriteKMLBoundaries(javax.xml.stream.XMLStreamWriter xmlWriter)Write the boundary of the polygon as KML.-
Methods inherited from class gov.nasa.worldwind.render.AbstractShape
addOrderedRenderable, checkViewDistanceExpiration, clearCachedVbos, computeExtentFromPositions, computePoint, computePoint, countTriangleVertices, createPickedObject, determineActiveAttributes, doDrag, doDrawOrderedRenderable, doGetRestorableState, doRestoreState, drag, drawBatched, drawInterior, drawOrderedRenderable, drawOutline, endDrawing, export, exportAsKML, getActiveAttributes, getAltitudeMode, getAttributes, getCurrentData, getDelegateOwner, getDistanceFromEye, getExtent, getGeometryRegenerationInterval, getHighlightAttributes, getOutlinePickWidth, getReferencePoint, getRestorableState, getVboIds, intersectsFrustum, isDragEnabled, isEnableBatchPicking, isEnableBatchRendering, isEnableDepthOffset, isExportFormatSupported, isHighlighted, isTerrainDependent, isViewDistanceExpiration, isVisible, makeOrderedRenderable, makeTexture, move, mustApplyLighting, mustApplyLighting, mustCreateNormals, mustCreateNormals, mustDrawInterior, mustDrawOutline, pick, prepareToDrawInterior, prepareToDrawOutline, preRender, restoreState, setAltitudeMode, setAttributes, setDelegateOwner, setDragEnabled, setEnableBatchPicking, setEnableBatchRendering, setEnableDepthOffset, setGeometryRegenerationInterval, setHighlightAttributes, setHighlighted, setOutlinePickWidth, setReferencePosition, setViewDistanceExpiration, setVisible, updateSurfaceShape
-
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
-
-
-
-
Field Detail
-
edgeIndexBuffers
protected static java.util.HashMap<java.lang.Integer,java.nio.IntBuffer> edgeIndexBuffers
This static hash map holds the vertex indices that define the shape's visual outline. The contents depend only on the number of locations in the source polygon, so they can be reused by all shapes with the same location count.
-
VBO_THRESHOLD
protected static final int VBO_THRESHOLD
Indicates the number of vertices that must be present in order for VBOs to be used to render this shape.
-
boundaries
protected java.util.List<java.util.List<? extends Position>> boundaries
The location of each vertex in this shape's boundaries. There is one list per boundary. There is always an entry for the outer boundary, but its list is empty if an outer boundary has not been specified.
-
numPositions
protected int numPositions
The total number of positions in the entire polygon.
-
texture
protected WWTexture texture
If an image source was specified, this is the WWTexture form.
-
rotation
protected java.lang.Double rotation
This shape's rotation, in degrees positive counterclockwise.
-
textureCoordsBuffer
protected java.nio.FloatBuffer textureCoordsBuffer
This shape's texture coordinates.
-
previousIntersectionTerrain
protected Terrain previousIntersectionTerrain
The terrain used in the most recent intersection calculations.
-
previousIntersectionGlobeStateKey
protected java.lang.Object previousIntersectionGlobeStateKey
The globe state key for the globe used in the most recent intersection calculation.
-
previousIntersectionShapeData
protected Polygon.ShapeData previousIntersectionShapeData
The shape data used for the previous intersection calculation.
-
-
Constructor Detail
-
Polygon
public Polygon()
Construct a polygon with an empty outer boundary.
-
Polygon
public Polygon(java.lang.Iterable<? extends Position> corners)
Construct a polygon for a specified outer boundary.- Parameters:
corners- the list of locations defining the polygon.- Throws:
java.lang.IllegalArgumentException- if the location list is null.
-
Polygon
public Polygon(Position.PositionList corners)
Construct a polygon for a specified list of outer-boundary positions.- Parameters:
corners- the list of positions -- latitude longitude and altitude -- defining the polygon. The current altitude mode determines whether the positions are considered relative to mean sea level (they are "absolute") or the ground elevation at the associated latitude and longitude.- Throws:
java.lang.IllegalArgumentException- if the position list is null.
-
-
Method Detail
-
createCacheEntry
protected AbstractShape.AbstractShapeData createCacheEntry(DrawContext dc)
Description copied from class:AbstractShapeCreates and returns a new cache entry specific to the subclass.- Specified by:
createCacheEntryin classAbstractShape- Parameters:
dc- the current draw context.- Returns:
- a data cache entry for the state in the specified draw context.
-
getCurrent
protected Polygon.ShapeData getCurrent()
Returns the current shape data cache entry.- Returns:
- the current data cache entry.
-
initialize
protected void initialize()
Description copied from class:AbstractShapeCalled during construction to establish any subclass-specific state such as different default values than those set by this class.- Specified by:
initializein classAbstractShape
-
reset
protected void reset()
Void any computed data. Called when a factor affecting the computed data is changed.- Overrides:
resetin classAbstractShape
-
countPositions
protected int countPositions()
Counts the total number of positions in this shape, including all positions in all boundaries.- Returns:
- the number of positions in this shape.
-
getOuterBoundary
public java.lang.Iterable<? extends LatLon> getOuterBoundary()
Returns the list of positions defining this polygon's outer boundary.- Returns:
- this polygon's outer boundary positions. The list may be empty but will not be null.
-
outerBoundary
public java.util.List<? extends Position> outerBoundary()
Returns a reference to the outer boundary of this polygon.- Returns:
- this polygon's outer boundary. The list may be empty but will not be null.
-
isOuterBoundaryValid
protected boolean isOuterBoundaryValid()
-
setOuterBoundary
public void setOuterBoundary(java.lang.Iterable<? extends Position> corners)
Specifies the latitude, longitude and altitude of the outer boundary positions defining this polygon.- Parameters:
corners- this polygon's positions. A copy of the list is made and retained, and a duplicate of the first position is appended to the copy if the first and last positions are not identical.- Throws:
java.lang.IllegalArgumentException- if the location list is null or contains fewer than three locations.
-
fillBoundary
protected java.util.List<? extends Position> fillBoundary(java.lang.Iterable<? extends Position> corners)
Copies a boundary's positions to this shape's internal boundary list. Closes the boundary if it's not already closed.- Parameters:
corners- the boundary's positions.- Returns:
- a list of the boundary positions.
-
addInnerBoundary
public void addInnerBoundary(java.lang.Iterable<? extends Position> corners)
Add an inner boundary to this polygon. A duplicate of the first position is appended to the list if the list's last position is not identical to the first.- Parameters:
corners- the new boundary positions. A copy of the list is created and retained, and a duplicate of the first position is added to the list if the first and last positions are not identical.- Throws:
java.lang.IllegalArgumentException- if the location list is null or contains fewer than three locations.
-
getBoundaries
public java.util.List<java.util.List<? extends Position>> getBoundaries()
Returns this shape's boundaries.- Returns:
- this shape's boundaries.
-
getTextureImageSource
public java.lang.Object getTextureImageSource()
Returns this polygon's texture image source.- Returns:
- the texture image source, or null if no source has been specified.
-
getTexture
protected WWTexture getTexture()
Get the texture applied to this polygon. The texture is loaded on a background thread. This method will return null until the texture has been loaded.- Returns:
- the texture, or null if there is no texture or the texture is not yet available.
-
getTextureCoords
public float[] getTextureCoords()
Returns the texture coordinates for this polygon.- Returns:
- the texture coordinates, or null if no texture coordinates have been specified.
-
setTextureImageSource
public void setTextureImageSource(java.lang.Object imageSource, float[] texCoords, int texCoordCount)Specifies the texture to apply to this polygon.- Parameters:
imageSource- the texture image source. May be aStringidentifying a file path or URL, aFile, or aURL.texCoords- the (s, t) texture coordinates aligning the image to the polygon. There must be one texture coordinate pair, (s, t), for each polygon location in the polygon's outer boundary.texCoordCount- the number of texture coordinates, (s, v) pairs, specified.- Throws:
java.lang.IllegalArgumentException- if the image source is not null and either the texture coordinates are null or inconsistent with the specified texture-coordinate count, or there are fewer than three texture coordinate pairs.
-
getReferencePosition
public Position getReferencePosition()
Description copied from interface:MovableA position associated with the object that indicates its aggregate geographic position. The chosen position varies among implementers of this interface. For objects defined by a list of positions, the reference position is typically the first position in the list. For symmetric objects the reference position is often the center of the object. In many cases the object's reference position may be explicitly specified by the application.- Returns:
- the object's reference position, or null if no reference position is available.
-
getRotation
public java.lang.Double getRotation()
Indicates the amount of rotation applied to this polygon.- Returns:
- the rotation in degrees, or null if no rotation is specified.
-
setRotation
public void setRotation(java.lang.Double rotation)
Specifies the amount of rotation applied to this polygon. Positive rotation is counter-clockwise.- Parameters:
rotation- the amount of rotation to apply, in degrees, or null to apply no rotation.
-
createSurfaceShape
protected SurfaceShape createSurfaceShape()
Description copied from class:AbstractShapeReturns aSurfaceShapethat corresponds to this Path and is used for drawing on 2D globes.- Overrides:
createSurfaceShapein classAbstractShape- Returns:
- The surface shape to represent this Path on a 2D globe.
-
setSurfacePolygonBoundaries
protected void setSurfacePolygonBoundaries(SurfaceShape shape)
-
setSurfacePolygonTexImageSource
protected void setSurfacePolygonTexImageSource(SurfaceShape shape)
-
getExtent
public Extent getExtent(Globe globe, double verticalExaggeration)
Description copied from interface:ExtentHolderReturns the objects enclosing volume as anExtentin model coordinates, given a specifiedGlobeand vertical exaggeration (seeSceneController.getVerticalExaggeration().- Specified by:
getExtentin interfaceExtentHolder- Overrides:
getExtentin classAbstractShape- Parameters:
globe- the Globe the object is related to.verticalExaggeration- the vertical exaggeration of the scene containing this object.- Returns:
- the object's Extent in model coordinates.
-
computeExtent
protected Extent computeExtent(Polygon.BoundaryInfo boundary, Vec4 refPoint)
Computes the Cartesian extent of a polygon boundary.- Parameters:
boundary- The boundary to compute the extent for.refPoint- the shape's reference point.- Returns:
- the boundary's extent. Returns null if the boundary's vertices have not been computed.
-
getSector
public Sector getSector()
Description copied from interface:GeographicExtentReturns the object's geographic extent.- Returns:
- the object's geographic extent.
-
mustApplyTexture
protected boolean mustApplyTexture(DrawContext dc)
Description copied from class:AbstractShapeIndicates whether texture should be applied to this shape. Called during rendering to determine whether texture state should be established during preparation for interior drawing.Note: This method always returns false during the pick pass.
- Specified by:
mustApplyTexturein classAbstractShape- Parameters:
dc- the current draw context- Returns:
- true if texture should be applied, otherwise false.
-
shouldUseVBOs
protected boolean shouldUseVBOs(DrawContext dc)
Description copied from class:AbstractShapeIndicates whether this shape should use OpenGL vertex buffer objects.- Overrides:
shouldUseVBOsin classAbstractShape- Parameters:
dc- the current draw context.- Returns:
- true if this shape should use vertex buffer objects, otherwise false.
-
mustRegenerateGeometry
protected boolean mustRegenerateGeometry(DrawContext dc)
Description copied from class:AbstractShapeIndicates whether this shape's renderable geometry must be recomputed, either as a result of an attribute or property change or the expiration of the geometry regeneration interval.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Overrides:
mustRegenerateGeometryin classAbstractShape- Parameters:
dc- the current draw context.- Returns:
- true if this shape's geometry must be regenerated, otherwise false.
-
render
public void render(DrawContext dc)
Description copied from interface:RenderableCauses thisRenderableto render itself using the provided draw context.- Specified by:
renderin interfaceRenderable- Overrides:
renderin classAbstractShape- Parameters:
dc- theDrawContextto be used- See Also:
DrawContext
-
doMakeOrderedRenderable
protected boolean doMakeOrderedRenderable(DrawContext dc)
Description copied from class:AbstractShapeProduces the geometry and other state necessary to represent this shape as an ordered renderable. Places this shape on the draw context's ordered renderable list for subsequent rendering. This method is called duringAbstractShape.pick(DrawContext, java.awt.Point)andAbstractShape.render(DrawContext)when it's been determined that the shape is likely to be visible.- Specified by:
doMakeOrderedRenderablein classAbstractShape- Parameters:
dc- the current draw context.- Returns:
- true if the ordered renderable state was successfully computed, otherwise false, in which case the current pick or render pass is terminated for this shape. Subclasses should return false if it is not possible to create the ordered renderable state.
- See Also:
AbstractShape.pick(DrawContext, java.awt.Point),AbstractShape.render(DrawContext)
-
isOrderedRenderableValid
protected boolean isOrderedRenderableValid(DrawContext dc)
Description copied from class:AbstractShapeDetermines whether this shape's ordered renderable state is valid and can be rendered. Called byAbstractShape.makeOrderedRenderable(DrawContext)just prior to adding the shape to the ordered renderable list.- Specified by:
isOrderedRenderableValidin classAbstractShape- Parameters:
dc- the current draw context.- Returns:
- true if this shape is ready to be rendered as an ordered renderable.
-
beginDrawing
protected OGLStackHandler beginDrawing(DrawContext dc, int attrMask)
Description copied from class:AbstractShapeEstablish the OpenGL state needed to draw this shape.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Overrides:
beginDrawingin classAbstractShape- Parameters:
dc- the current draw context.attrMask- an attribute mask indicating state the caller will set. This base class implementation setsGL_CURRENT_BIT, GL_LINE_BIT, GL_HINT_BIT, GL_POLYGON_BIT, GL_COLOR_BUFFER_BIT, and GL_TRANSFORM_BIT.- Returns:
- the stack handler used to set the OpenGL state. Callers should use this to set additional state, especially state indicated in the attribute mask argument.
-
doDrawOutline
protected void doDrawOutline(DrawContext dc)
Description copied from class:AbstractShapeDraws this shape's outline. Called immediately after callingAbstractShape.prepareToDrawOutline(DrawContext, ShapeAttributes, ShapeAttributes), which establishes OpenGL state for lighting, blending, pick color and line attributes. Subclasses should execute the drawing commands specific to the type of shape.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Specified by:
doDrawOutlinein classAbstractShape- Parameters:
dc- the current draw context.
-
doDrawOutlineVA
protected void doDrawOutlineVA(DrawContext dc, Polygon.ShapeData shapeData)
-
doDrawOutlineVBO
protected void doDrawOutlineVBO(DrawContext dc, int[] vboIds, Polygon.ShapeData shapeData)
-
doDrawInterior
protected void doDrawInterior(DrawContext dc)
Description copied from class:AbstractShapeDraws this shape's interior. Called immediately after callingAbstractShape.prepareToDrawInterior(DrawContext, ShapeAttributes, ShapeAttributes), which establishes OpenGL state for lighting, blending, pick color and interior attributes. Subclasses should execute the drawing commands specific to the type of shape.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Specified by:
doDrawInteriorin classAbstractShape- Parameters:
dc- the current draw context.
-
doDrawInteriorVA
protected void doDrawInteriorVA(DrawContext dc, Polygon.ShapeData shapeData)
-
doDrawInteriorVBO
protected void doDrawInteriorVBO(DrawContext dc, int[] vboIds, Polygon.ShapeData shapeData)
-
createMinimalGeometry
protected void createMinimalGeometry(DrawContext dc, Polygon.ShapeData shapeData)
Compute enough geometry to determine this polygon's extent, reference point and eye distance.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Parameters:
dc- the current draw context.shapeData- the current shape data for this shape.
-
computeEyeDistance
protected double computeEyeDistance(DrawContext dc, Polygon.ShapeData shapeData)
Computes the minimum distance between this polygon and the eye point.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Parameters:
dc- the draw context.shapeData- the current shape data for this shape.- Returns:
- the minimum distance from the shape to the eye point.
-
createFullGeometry
protected void createFullGeometry(DrawContext dc, Terrain terrain, Polygon.ShapeData shapeData, boolean skipOuterBoundary)
Computes a shape's full geometry.- Parameters:
dc- the current draw context.terrain- the terrain to use when computing the geometry.shapeData- the current shape data for this shape.skipOuterBoundary- true if outer boundaries vertices do not need to be calculated, otherwise false.
-
createVertices
protected void createVertices(Terrain terrain, Polygon.ShapeData shapeData, boolean skipOuterBoundary)
Computes the Cartesian vertices for this shape.- Parameters:
terrain- the terrain to use if the altitude mode is relative to the terrain.shapeData- the current shape data for this shape.skipOuterBoundary- if true, don't calculate the vertices for the outer boundary. This is used when the outer boundary vertices were computed as minimal geometry.
-
computeBoundaryVertices
protected void computeBoundaryVertices(Terrain terrain, Polygon.BoundaryInfo boundary, Vec4 refPoint, Matrix rotationMatrix)
Compute the vertices associated with a specified boundary.- Parameters:
terrain- the terrain to use when calculating vertices relative to the ground.boundary- the boundary to compute vertices for.refPoint- the reference point. Vertices are computed relative to this point, which is usually the shape's reference point.rotationMatrix- the rotation matrix to apply to the vertices.
-
createGeometry
protected void createGeometry(DrawContext dc, Polygon.ShapeData shapeData)
Compute the cap geometry.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Parameters:
dc- the current draw context.shapeData- boundary vertices are calculated duringcreateMinimalGeometry(DrawContext, gov.nasa.worldwind.render.Polygon.ShapeData)).
-
createNormals
protected void createNormals(Polygon.ShapeData shapeData)
Create this shape's vertex normals.- Parameters:
shapeData- the current shape data holding the vertex coordinates and in which the normal vectors are added. The normal vectors are appended to the vertex coordinates in the same buffer. The shape data's coordinate buffer must have sufficient capacity to hold the vertex normals.
-
fillVBO
protected void fillVBO(DrawContext dc)
Fill this shape's vertex buffer objects. If the vertex buffer object resource IDs don't yet exist, create them.- Specified by:
fillVBOin classAbstractShape- Parameters:
dc- the current draw context.
-
computeBoundaryNormals
protected java.nio.FloatBuffer computeBoundaryNormals(Polygon.BoundaryInfo boundary, java.nio.FloatBuffer nBuf)
Compute normal vectors for a boundary's vertices.- Parameters:
boundary- the boundary to compute normals for.nBuf- the buffer in which to place the computed normals. Must have enough remaining space to hold the normals.- Returns:
- the buffer specified as input, with its limit incremented by the number of vertices copied, and its position set to 0.
-
createTessllationGeometry
protected void createTessllationGeometry(DrawContext dc, Polygon.ShapeData shapeData)
Tessellates the polygon.This method catches
OutOfMemoryErrorexceptions and if the draw context is not null passes the exception to the rendering exception listener (seeWorldWindow.addRenderingExceptionListener(gov.nasa.worldwind.event.RenderingExceptionListener)).- Parameters:
dc- the draw context.shapeData- the current shape data for this shape.
-
computePolygonNormal
protected Vec4 computePolygonNormal(DrawContext dc, Polygon.ShapeData shapeData)
-
tessellatePolygon
protected void tessellatePolygon(Polygon.ShapeData shapeData, Vec4 normal)
Tessellates the polygon from its vertices.- Parameters:
shapeData- the polygon boundaries.normal- a unit normal vector for the plane containing the polygon vertices. Even though the the vertices might not be coplanar, only one representative normal is used for tessellation.
-
generateInteriorIndices
protected void generateInteriorIndices(Polygon.ShapeData shapeData)
-
isSameAsPreviousTerrain
protected boolean isSameAsPreviousTerrain(Terrain terrain)
-
clearIntersectionGeometry
public void clearIntersectionGeometry()
-
intersect
public java.util.List<Intersection> intersect(Line line, Terrain terrain) throws java.lang.InterruptedException
Compute the intersections of a specified line with this polygon. If the polygon's altitude mode is other thanWorldWind.ABSOLUTE, the polygon's geometry is created relative to the specified terrain rather than the terrain used during rendering, which may be at lower level of detail than required for accurate intersection determination.- Specified by:
intersectin classAbstractShape- Parameters:
line- the line to intersect.terrain- theTerrainto use when computing the polygon's geometry.- Returns:
- a list of intersections identifying where the line intersects the polygon, or null if the line does not intersect the polygon.
- Throws:
java.lang.InterruptedException- if the operation is interrupted.- See Also:
Terrain
-
createIntersectionGeometry
protected Polygon.ShapeData createIntersectionGeometry(Terrain terrain)
-
intersect
protected void intersect(Line line, Polygon.ShapeData shapeData, java.util.List<Intersection> intersections) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
moveTo
public void moveTo(Position position)
Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.Note that this method overwrites the boundary locations lists, and therefore no longer refer to the originally specified boundary lists.
- Parameters:
position- the new position of the shape's reference position.- Throws:
java.lang.IllegalArgumentException- if the position is null.
-
moveTo
public void moveTo(Globe globe, Position position)
Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.Note that this method overwrites the boundary locations lists, and therefore no longer refer to the originally specified boundary lists.
- Specified by:
moveToin interfaceMovable2- Overrides:
moveToin classAbstractShape- Parameters:
globe- the globe on which to move this shape.position- the new position of the shape's reference position.- Throws:
java.lang.IllegalArgumentException- if the globe or position is null.
-
doExportAsKML
protected void doExportAsKML(javax.xml.stream.XMLStreamWriter xmlWriter) throws java.io.IOException, javax.xml.stream.XMLStreamExceptionExports shape-specific fields.- Specified by:
doExportAsKMLin classAbstractShape- Parameters:
xmlWriter- the export writer to write to.- Throws:
java.io.IOException- if an IO error occurs while writing to the output destination.javax.xml.stream.XMLStreamException- if an exception occurs converting this shape's fields to XML.
-
writeKMLBoundaries
protected void writeKMLBoundaries(javax.xml.stream.XMLStreamWriter xmlWriter) throws java.io.IOException, javax.xml.stream.XMLStreamExceptionWrite the boundary of the polygon as KML.- Parameters:
xmlWriter- XML writer to receive the output.- Throws:
java.io.IOException- If an exception occurs writing the XML stream.javax.xml.stream.XMLStreamException- If an exception occurs writing the XML stream.
-
exportBoundaryAsLinearRing
protected void exportBoundaryAsLinearRing(javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.Iterable<? extends LatLon> boundary) throws javax.xml.stream.XMLStreamExceptionWrites the boundary in KML as either a list of lat, lon, altitude tuples or lat, lon tuples, depending on the type originally specified.- Parameters:
xmlWriter- the XML writer.boundary- the boundary to write.- Throws:
javax.xml.stream.XMLStreamException- if an error occurs during writing.
-
-