Class ExtrudedPolygon

  • 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:
    KMLExtrudedPolygonImpl

    public class ExtrudedPolygon
    extends AbstractShape
    A multi-sided 3D shell formed by a base polygon in latitude and longitude extruded from the terrain to either a specified height or an independent height per location. The base polygon may be complex with multiple internal but not intersecting contours.

    Extruded polygon boundaries may be specified using either LatLon locations or Position positions, but all the shape's boundary vertices must be the same type.

    Extruded polygons may optionally be textured. Textures may be applied to both the faces of the outer and inner boundaries or just the outer boundaries. Texture can also be applied independently to the cap. Standard lighting is optionally applied. Texture source images are lazily retrieved and loaded. This can cause a brief period in which the texture is not displayed while it is retrieved from disk or network.

    ExtrudedPolygon side faces and cap have independent attributes for both normal and highlighted drawing.

    When specifying a single height (altitude mode WorldWind.CONSTANT, the height is relative to a reference location designated by one of the specified polygon locations in the outer boundary. The default reference location is the first one in the polygon's outer boundary. An alternative location may be specified by calling setReferenceLocation(LatLon). The extruded polygon is capped with a plane at the specified height and tangent to the ellipsoid at the reference location. Since locations other than the reference location may resolve to points at elevations other than that at the reference location, the distances from those points to the cap are adjusted so that the adjacent sides precisely meet the cap. When specifying polygons using a single height, only the latitudes and longitudes of polygon boundary positions must be specified.

    Independent per-location heights may be specified via the altitude field of Positions defining the polygon's inner and outer boundaries. Depending on the specified altitude mode, the position altitudes may be interpreted as altitudes relative to mean sea level or altitudes above the ground at the associated latitude and longitude locations.

    Boundaries are required to be closed, their first location must be equal to their last location. Boundaries that are not closed are explicitly closed by this shape when they are specified.

    Extruded polygons are safe to share among WorldWindows. They should not be shared among layers in the same World Window.

    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 SurfacePolygon to represent itself. Cap texture is not supported in this case.

    • Field Detail

      • DEFAULT_SIDES_INTERIOR_MATERIAL

        protected static final Material DEFAULT_SIDES_INTERIOR_MATERIAL
        The default interior color for sides.
      • DEFAULT_ALTITUDE_MODE

        protected static final int DEFAULT_ALTITUDE_MODE
        The default altitude mode.
        See Also:
        Constant Field Values
      • defaultSideAttributes

        protected static final ShapeAttributes defaultSideAttributes
        The attributes used if attributes are not specified.
      • baseDepth

        protected double baseDepth
      • capEdgeIndexBuffers

        protected static java.util.HashMap<java.lang.Integer,​java.nio.IntBuffer> capEdgeIndexBuffers
      • sideFillIndexBuffers

        protected static java.util.HashMap<java.lang.Integer,​java.nio.IntBuffer> sideFillIndexBuffers
      • sideEdgeIndexBuffers

        protected static java.util.HashMap<java.lang.Integer,​java.nio.IntBuffer> sideEdgeIndexBuffers
      • 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 LatLon>> 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.
      • totalNumLocations

        protected int totalNumLocations
        The total number of locations in all boundaries.
      • totalFaceCount

        protected int totalFaceCount
        The total number of faces in all this shape's boundaries.
      • height

        protected double height
        This shape's height. Default is 1.
      • sideAttributes

        protected ShapeAttributes sideAttributes
        The attributes to use when drawing this shape's sides.
      • sideHighlightAttributes

        protected ShapeAttributes sideHighlightAttributes
        The attributes to use when drawing this shape's sides in highlight mode.
      • activeSideAttributes

        protected ShapeAttributes activeSideAttributes
        The currently active side attributes, derived from the specified attributes. Current only during rendering.
      • sideTextures

        protected java.util.List<java.util.List<WWTexture>> sideTextures
        This shape's side textures.
      • capTexture

        protected WWTexture capTexture
        This shape's cap texture.
      • capTextureCoords

        protected java.nio.FloatBuffer capTextureCoords
        This shape's cap texture coordinates.
      • enableCap

        protected boolean enableCap
        Indicates whether the cap should be drawn.
      • enableSides

        protected boolean enableSides
        Indicates whether the sides should be drawn.
      • 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 ExtrudedPolygon.ShapeData previousIntersectionShapeData
        The shape data used for the previous intersection calculation.
    • Constructor Detail

      • ExtrudedPolygon

        public ExtrudedPolygon()
        Constructs an extruded polygon with an empty outer boundary and a default height of 1 meter.
      • ExtrudedPolygon

        public ExtrudedPolygon​(java.lang.Double height)
        Constructs an extruded polygon of a specified height and an empty outer boundary.
        Parameters:
        height - the shape height, in meters. May be null, in which case a height of 1 is used. The height is used only when the altitude mode is WorldWind.CONSTANT, which is the default for this shape.
      • ExtrudedPolygon

        public ExtrudedPolygon​(java.lang.Iterable<? extends LatLon> corners,
                               java.lang.Double height)
        Constructs an extruded polygon for a specified list of outer boundary locations and a height.
        Parameters:
        corners - the list of locations defining this extruded polygon's outer boundary.
        height - the shape height, in meters. May be null, in which case a height of 1 is used. The height is used only when the altitude mode is WorldWind.CONSTANT, which is the default for this shape.
        Throws:
        java.lang.IllegalArgumentException - if the location list is null or the height is specified but less than or equal to zero.
      • ExtrudedPolygon

        public ExtrudedPolygon​(java.lang.Iterable<? extends LatLon> corners,
                               double height,
                               java.lang.Iterable<?> imageSources)
        Constructs an extruded polygon from an outer boundary, a height, and images for its outer faces.
        Parameters:
        corners - the list of locations defining this polygon's outer boundary.
        height - the shape height, in meters. May be null, in which case a height of 1 is used. The height is used only when the altitude mode is WorldWind.CONSTANT, which is the default for this shape.
        imageSources - images to apply to the polygon's outer faces. One image for each face must be included. May also be null.
        Throws:
        java.lang.IllegalArgumentException - if the location list is null or the height is specified but less than or equal to zero.
      • ExtrudedPolygon

        public ExtrudedPolygon​(java.lang.Iterable<? extends Position> corners)
        Constructs an extruded polygon from an outer boundary.
        Parameters:
        corners - the list of outer boundary positions -- latitude longitude and altitude. The 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.
      • ExtrudedPolygon

        public ExtrudedPolygon​(Position.PositionList corners)
        Constructs an extruded polygon from an outer boundary specified with position heights.
        Parameters:
        corners - the list of positions -- latitude longitude and altitude -- defining the polygon's outer boundary. The 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.
      • ExtrudedPolygon

        public ExtrudedPolygon​(java.lang.Iterable<? extends Position> corners,
                               java.lang.Iterable<?> imageSources)
        Constructs an extruded polygon from an outer boundary and apply specified textures to its outer faces.
        Parameters:
        corners - the list of positions -- latitude longitude and altitude -- defining the polygon. The 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.
        imageSources - textures to apply to the polygon's outer faces. One texture for each face must be included. May also be null.
        Throws:
        java.lang.IllegalArgumentException - if the position list is null.
    • Method Detail

      • getCurrent

        protected ExtrudedPolygon.ShapeData getCurrent()
        Indicates the currently active shape data.
        Returns:
        the currently active shape data.
      • initialize

        protected void initialize()
        Description copied from class: AbstractShape
        Called during construction to establish any subclass-specific state such as different default values than those set by this class.
        Specified by:
        initialize in class AbstractShape
      • reset

        protected void reset()
        Description copied from class: AbstractShape
        Invalidates computed values. Called when this shape's contents or certain attributes change.
        Overrides:
        reset in class AbstractShape
      • countLocations

        protected int countLocations()
        Counts the total number of locations in this polygon's boundaries, not including positions introduced by extrusion.
        Returns:
        the number of locations in the polygon boundaries.
      • getOuterBoundary

        public java.lang.Iterable<? extends LatLon> getOuterBoundary()
        Returns the list of locations or positions defining this polygon's outer boundary.
        Returns:
        this polygon's positions.
      • outerBoundary

        protected java.util.List<? extends LatLon> outerBoundary()
        Returns a reference to the outer boundary of this polygon.
        Returns:
        this polygon's outer boundary.
      • isOuterBoundaryValid

        protected boolean isOuterBoundaryValid()
        Indicates whether this shape's outer boundary exists and has more than two points.
        Returns:
        true if the outer boundary is valid, otherwise false.s
      • setOuterBoundary

        public void setOuterBoundary​(java.lang.Iterable<? extends LatLon> corners)
        Specifies the latitude and longitude of the locations defining the outer boundary of this polygon. To specify altitudes, pass Positions rather than LatLons. The shape's height is not modified.
        Parameters:
        corners - the outer boundary locations.
        Throws:
        java.lang.IllegalArgumentException - if the location list is null or contains fewer than three locations.
      • setOuterBoundary

        public void setOuterBoundary​(java.lang.Iterable<? extends LatLon> corners,
                                     java.lang.Iterable<?> imageSources)
        Specifies the latitudes, longitudes and outer-boundary images for the outer boundary of this polygon. To specify altitudes, pass Positions rather than LatLons.
        Parameters:
        corners - the polygon locations.
        imageSources - images to apply to the outer faces. One image must be specified for each face. May be null.
        Throws:
        java.lang.IllegalArgumentException - if the location list is null.
      • setOuterBoundary

        public void setOuterBoundary​(java.lang.Iterable<? extends LatLon> corners,
                                     java.lang.Double height)
        Specifies the latitude and longitude of the outer boundary locations defining this polygon, and optionally the extruded polygon's height. To specify altitudes for each boundary location, pass Positions rather than LatLons, but those altitudes are used only when the shape's altitude mode is WorldWind.ABSOLUTE.
        Parameters:
        corners - the outer boundary locations.
        height - the shape height, in meters.
        Throws:
        java.lang.IllegalArgumentException - if the location list is null or contains fewer than three locations.
      • fillBoundary

        protected java.util.List<? extends LatLon> fillBoundary​(java.lang.Iterable<? extends LatLon> corners)
      • addInnerBoundary

        public void addInnerBoundary​(java.lang.Iterable<? extends LatLon> corners)
        Add an inner boundary to this polygon.
        Parameters:
        corners - the boundary's locations.
        Throws:
        java.lang.IllegalArgumentException - if the location list is null or contains fewer than three locations.
      • addInnerBoundary

        public void addInnerBoundary​(java.lang.Iterable<? extends LatLon> corners,
                                     java.lang.Iterable<?> imageSources)
        Add an inner boundary to this polygon and specify images to apply to each of the boundary's faces. Specify LatLons to use the polygon's single height, or Positions, to include individual altitudes.
        Parameters:
        corners - the boundary's locations.
        imageSources - images to apply to the boundary's faces. One image must be specified for each face. May be null.
        Throws:
        java.lang.IllegalArgumentException - if the location list is null.
      • getBoundaries

        protected java.util.List<java.util.List<? extends LatLon>> getBoundaries()
        Returns this shape's boundaries.
        Returns:
        this shape's boundaries.
      • fillImageList

        protected java.util.List<WWTexture> fillImageList​(java.lang.Iterable<?> imageSources)
        Creates texture object for a boundary's image sources.
        Parameters:
        imageSources - the images to apply for this boundary.
        Returns:
        the list of texture objects, or null if the imageSources argument is null.
      • getCapImageSource

        public java.lang.Object getCapImageSource()
        Returns this extruded polygon's cap image.
        Returns:
        the texture image source, or null if no source has been specified.
      • setCapImageSource

        public void setCapImageSource​(java.lang.Object imageSource,
                                      float[] texCoords,
                                      int texCoordCount)
        Specifies the image to apply to this extruded polygon's cap.
        Parameters:
        imageSource - the image source. May be a String identifying a file path or URL, a File, or a URL.
        texCoords - the (s, t) texture coordinates aligning the image to the polygon. There must be one texture coordinate pair, (s, t), for each 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.
      • getTextureCoords

        public float[] getTextureCoords()
        Returns the texture coordinates for this polygon's cap.
        Returns:
        the texture coordinates, or null if no cap texture coordinates have been specified.
      • getCapTexture

        protected WWTexture getCapTexture()
        Get the texture applied to this extruded polygon's cap.
        Returns:
        The texture, or null if there is no texture or the texture is not yet available.
      • getHeight

        public double getHeight()
        Returns the height of this extruded polygon.
        Returns:
        the height originally specified, in meters.
      • setHeight

        public void setHeight​(double height)
        Specifies the height of this extruded polygon.
        Parameters:
        height - the height, in meters.
        Throws:
        java.lang.IllegalArgumentException - if the height is less than or equal to zero.
      • isEnableCap

        public boolean isEnableCap()
        Indicates whether the cap of this extruded polygon is drawn.
        Returns:
        true to draw the cap, otherwise false.
      • setEnableCap

        public void setEnableCap​(boolean enableCap)
        Specifies whether the cap of this extruded polygon is drawn.
        Parameters:
        enableCap - true to draw the cap, otherwise false.
      • isEnableSides

        public boolean isEnableSides()
        Indicates whether the sides of this extruded polygon are drawn.
        Returns:
        true to draw the sides, otherwise false.
      • setEnableSides

        public void setEnableSides​(boolean enableSides)
        Specifies whether to draw the sides of this extruded polygon.
        Parameters:
        enableSides - true to draw the sides, otherwise false.
      • getSideAttributes

        public ShapeAttributes getSideAttributes()
        Returns the attributes applied to this polygon's side faces.
        Returns:
        this polygon's side attributes.
      • setSideAttributes

        public void setSideAttributes​(ShapeAttributes attributes)
        Specifies the attributes applied to this polygon's side faces.
        Parameters:
        attributes - this polygon's side attributes.
        Throws:
        java.lang.IllegalArgumentException - if attributes is null.
      • getCapAttributes

        public ShapeAttributes getCapAttributes()
        Returns the attributes applied to this polygon's cap.
        Returns:
        this polygon's cap attributes.
      • setCapAttributes

        public void setCapAttributes​(ShapeAttributes attributes)
        Specifies the attributes applied to this polygon's cap.
        Parameters:
        attributes - this polygon's cap attributes.
        Throws:
        java.lang.IllegalArgumentException - if attributes is null.
      • getSideHighlightAttributes

        public ShapeAttributes getSideHighlightAttributes()
        Returns the highlight attributes applied to this polygon's side faces.
        Returns:
        this polygon's side highlight attributes.
      • setSideHighlightAttributes

        public void setSideHighlightAttributes​(ShapeAttributes attributes)
        Specifies the highlight attributes applied to this polygon's side faces.
        Parameters:
        attributes - this polygon's side highlight attributes.
        Throws:
        java.lang.IllegalArgumentException - if attributes is null.
      • getCapHighlightAttributes

        public ShapeAttributes getCapHighlightAttributes()
        Returns the highlight attributes applied to this polygon's cap.
        Returns:
        this polygon's cap highlight attributes.
      • setCapHighlightAttributes

        public void setCapHighlightAttributes​(ShapeAttributes attributes)
        Specifies the highlight attributes applied to this polygon's cap.
        Parameters:
        attributes - this polygon's cap highlight attributes.
        Throws:
        java.lang.IllegalArgumentException - if attributes is null.
      • getActiveSideAttributes

        protected ShapeAttributes getActiveSideAttributes()
        Each time this polygon is rendered the appropriate attributes for the current mode are determined. This method returns the resolved attributes.
        Returns:
        the currently active attributes for this polygon's side faces.
      • getActiveCapAttributes

        protected ShapeAttributes getActiveCapAttributes()
        Each time this polygon is rendered the appropriate attributes for the current mode are determined. This method returns the resolved attributes.
        Returns:
        the currently active attributes for this polygon's cap.
      • getSector

        public Sector getSector()
        Description copied from interface: GeographicExtent
        Returns the object's geographic extent.
        Returns:
        the object's geographic extent.
      • getReferenceLocation

        public LatLon getReferenceLocation()
        Indicates the location to use as a reference location for computed geometry.
        Returns:
        the reference location, or null if no reference location has been specified.
        See Also:
        getReferencePosition()
      • setReferenceLocation

        public void setReferenceLocation​(LatLon referenceLocation)
        Specifies the location to use as a reference location for computed geometry. This value should typically be left to the default, which is the first location in the extruded polygon's outer boundary.
        Parameters:
        referenceLocation - the reference location. May be null, in which case the first location of the outer boundary is the reference location.
        See Also:
        AbstractShape.setReferencePosition(gov.nasa.worldwind.geom.Position)
      • getReferencePosition

        public Position getReferencePosition()
        Indicates the position used as a reference position for this extruded polygon's computed geometry.
        Returns:
        the reference position, or null if no reference position has been specified.
      • getBaseDepth

        public double getBaseDepth()
        Returns this object's base depth.
        Returns:
        This object's base depth, in meters.
        See Also:
        setBaseDepth(double)
      • setBaseDepth

        public void setBaseDepth​(double baseDepth)
        Specifies a depth below the terrain at which to place this extruded polygon's base vertices. This value does not affect the height of the extruded polygon nor the position of its cap. It positions the base vertices such that they are the specified distance below the terrain. The default value is zero, therefore the base vertices are position on the terrain.
        Parameters:
        baseDepth - the depth in meters to position the base vertices below the terrain. Specify positive values to position the base vertices below the terrain. (Negative values position the base vertices above the terrain.)
      • getImageSources

        public java.util.List<java.util.List<java.lang.Object>> getImageSources()
        Returns this extruded polygon's side images.
        Returns:
        a collection of lists each identifying the image sources for the associated outer or inner polygon boundary.
      • hasSideTextures

        public boolean hasSideTextures()
        Indicates whether side images have been specified for this extruded polygon.
        Returns:
        true if side textures have been specified, otherwise false.
      • mustApplyTexture

        protected boolean mustApplyTexture​(DrawContext dc)
        Description copied from class: AbstractShape
        Indicates 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:
        mustApplyTexture in class AbstractShape
        Parameters:
        dc - the current draw context
        Returns:
        true if texture should be applied, otherwise false.
      • isTerrainDependent

        protected boolean isTerrainDependent()
        Description copied from class: AbstractShape
        Indicates whether this shape's geometry depends on the terrain.
        Overrides:
        isTerrainDependent in class AbstractShape
        Returns:
        true if this shape's geometry depends on the terrain, otherwise false.
      • mustApplySideTextures

        protected boolean mustApplySideTextures()
      • mustDrawInterior

        protected boolean mustDrawInterior()
        Indicates whether the interior of either the sides or cap must be drawn.
        Overrides:
        mustDrawInterior in class AbstractShape
        Returns:
        true if an interior must be drawn, otherwise false.
      • mustDrawOutline

        protected boolean mustDrawOutline()
        Indicates whether the polygon's outline should be drawn.
        Overrides:
        mustDrawOutline in class AbstractShape
        Returns:
        true if the outline should be drawn, otherwise false.
      • mustRegenerateGeometry

        protected boolean mustRegenerateGeometry​(DrawContext dc)
        Description copied from class: AbstractShape
        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.

        A AbstractShape.AbstractShapeData must be current when this method is called.

        Overrides:
        mustRegenerateGeometry in class AbstractShape
        Parameters:
        dc - the current draw context.
        Returns:
        true if this shape's geometry must be regenerated, otherwise false.
      • getExtent

        public Extent getExtent​(Globe globe,
                                double verticalExaggeration)
        Description copied from interface: ExtentHolder
        Returns the objects enclosing volume as an Extent in model coordinates, given a specified Globe and vertical exaggeration (see SceneController.getVerticalExaggeration().
        Specified by:
        getExtent in interface ExtentHolder
        Overrides:
        getExtent in class AbstractShape
        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​(ExtrudedPolygon.ExtrudedBoundaryInfo outerBoundary,
                                       Vec4 refPoint)
        Computes this shapes extent. If a reference point is specified, the extent is translated to that reference point.
        Parameters:
        outerBoundary - the shape's outer boundary.
        refPoint - a reference point to which the extent is translated. May be null.
        Returns:
        the computed extent, or null if the extent cannot be computed.
      • setSurfacePolygonBoundaries

        protected void setSurfacePolygonBoundaries​(SurfaceShape shape)
      • beginDrawing

        protected OGLStackHandler beginDrawing​(DrawContext dc,
                                               int attrMask)
        Description copied from class: AbstractShape
        Establish the OpenGL state needed to draw this shape.

        A AbstractShape.AbstractShapeData must be current when this method is called.

        Overrides:
        beginDrawing in class AbstractShape
        Parameters:
        dc - the current draw context.
        attrMask - an attribute mask indicating state the caller will set. This base class implementation sets GL_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.
      • drawCapOutline

        public void drawCapOutline​(DrawContext dc,
                                   ExtrudedPolygon.ShapeData shapeData)
        Draws the cap's outline.

        This base implementation draws the outline of the basic polygon. Subclasses should override it to draw their outline or an alternate outline of the basic polygon.

        Parameters:
        dc - the draw context.
        shapeData - the current shape data.
      • drawSideOutline

        protected void drawSideOutline​(DrawContext dc,
                                       ExtrudedPolygon.ShapeData shapeData)
        Draws this extruded polygon's side outline.
        Parameters:
        dc - the draw context.
        shapeData - the current shape data.
      • drawCapInterior

        public void drawCapInterior​(DrawContext dc,
                                    ExtrudedPolygon.ShapeData shapeData)
        Draws the filled interior of this shape's cap.
        Parameters:
        dc - the draw context.
        shapeData - this shape's current globe-specific data.
      • drawSideInteriors

        protected void drawSideInteriors​(DrawContext dc,
                                         ExtrudedPolygon.ShapeData shapeData)
        Draws this shape's sides.
        Parameters:
        dc - the draw context.
        shapeData - this shape's current globe-specific data.
      • createMinimalGeometry

        protected void createMinimalGeometry​(DrawContext dc,
                                             ExtrudedPolygon.ShapeData shapeData)
        Computes the information necessary to determine this extruded polygon's extent.
        Parameters:
        dc - the current draw context.
        shapeData - this shape's current globe-specific data.
      • computeEyeDistance

        protected double computeEyeDistance​(DrawContext dc,
                                            ExtrudedPolygon.ShapeData shapeData)
        Computes the minimum distance between this shape and the eye point.
        Parameters:
        dc - the draw context.
        shapeData - this shape's current globe-specific data.
        Returns:
        the minimum distance from the shape to the eye point.
      • computeReferencePoint

        protected void computeReferencePoint​(Terrain terrain,
                                             ExtrudedPolygon.ShapeData shapeData)
        Computes and sets this shape's reference point, the Cartesian position corresponding to its geographic location.
        Parameters:
        terrain - the terrain to use when computing the reference point. The reference point is always on the terrain.
        shapeData - the current shape data.
      • createFullGeometry

        protected void createFullGeometry​(DrawContext dc,
                                          Terrain terrain,
                                          ExtrudedPolygon.ShapeData shapeData,
                                          boolean skipOuterBoundary)
        Computes a boundary set's full geometry.
        Parameters:
        dc - the current draw context.
        terrain - the terrain to use when computing the geometry.
        shapeData - the boundary set to compute the geometry for.
        skipOuterBoundary - true if outer boundaries vertices do not need to be calculated, otherwise false.
      • createVertices

        protected void createVertices​(Terrain terrain,
                                      ExtrudedPolygon.ShapeData shapeData,
                                      boolean skipOuterBoundary)
        Creates this shape's Cartesian vertices.
        Parameters:
        terrain - the terrain to use when computing the vertices.
        shapeData - the current shape data.
        skipOuterBoundary - if true, do not compute the outer boundary's vertices because they have already been computed.
      • computeBoundaryVertices

        protected void computeBoundaryVertices​(Terrain terrain,
                                               ExtrudedPolygon.ExtrudedBoundaryInfo boundary,
                                               Vec4 refPoint)
        Compute and set the Cartesian vertices for one specified boundary of this shape.
        Parameters:
        terrain - the terrain to use when computing the vertices.
        boundary - the boundary for which to compute the vertices.
        refPoint - the reference point specifying the coordinate origin of the vertices.
      • createSideGeometry

        protected void createSideGeometry​(ExtrudedPolygon.ShapeData shapeData)
        Constructs the Cartesian geometry of this shape's sides and sets it in the specified shape data.
        Parameters:
        shapeData - the current shape data.
      • createSideTextureCoords

        protected void createSideTextureCoords​(ExtrudedPolygon.ShapeData shapeData)
        Creates the texture coordinates for this shape's sides.
        Parameters:
        shapeData - the current shape data.
      • computeCapNormals

        protected java.nio.FloatBuffer computeCapNormals​(ExtrudedPolygon.ExtrudedBoundaryInfo boundary,
                                                         java.nio.FloatBuffer nBuf)
        Compute normal vectors for an extruded polygon's cap 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.
      • fillSideVertexBuffer

        protected java.nio.FloatBuffer fillSideVertexBuffer​(Vec4[] topVerts,
                                                            Vec4[] bottomVerts,
                                                            java.nio.FloatBuffer vBuf)
      • fillSideNormalBuffer

        protected java.nio.FloatBuffer fillSideNormalBuffer​(Vec4[] topVerts,
                                                            Vec4[] bottomVerts,
                                                            java.nio.FloatBuffer nBuf)
      • fillSideTexCoordBuffer

        protected void fillSideTexCoordBuffer​(Vec4[] topVerts,
                                              Vec4[] bottomVerts,
                                              java.nio.FloatBuffer tBuf)
        Computes the texture coordinates for a boundary of this shape.
        Parameters:
        topVerts - the boundary's top Cartesian coordinates.
        bottomVerts - the boundary's bottom Cartesian coordinates.
        tBuf - the buffer in which to place the computed texture coordinates.
      • getCapEdgeIndices

        protected java.nio.IntBuffer getCapEdgeIndices​(int n)
        Returns the indices defining the cap vertices.
        Parameters:
        n - the number of positions in the polygon.
        Returns:
        a buffer of indices that can be passed to OpenGL to draw all the shape's edges.
      • getSideIndices

        protected java.nio.IntBuffer getSideIndices​(int n)
        Returns the indices defining the vertices of each face of this extruded polygon.
        Parameters:
        n - the number of positions in this extruded polygon.
        Returns:
        a buffer of indices that can be passed to OpenGL to draw all face of the shape.
      • getSideEdgeIndices

        protected java.nio.IntBuffer getSideEdgeIndices​(int n)
        Returns the indices defining the vertices of a boundary's face edges.
        Parameters:
        n - the number of positions in the boundary.
        Returns:
        a buffer of indices that can be passed to OpenGL to draw all the boundary's edges.
      • fillVBO

        protected void fillVBO​(DrawContext dc)
        Description copied from class: AbstractShape
        Fill this shape's vertex buffer objects. If the vertex buffer object resource IDs don't yet exist, create them.

        A AbstractShape.AbstractShapeData must be current when this method is called.

        Specified by:
        fillVBO in class AbstractShape
        Parameters:
        dc - the current draw context.
      • tessellatePolygon

        protected void tessellatePolygon​(ExtrudedPolygon.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.
      • generateCapInteriorIndices

        protected void generateCapInteriorIndices​(ExtrudedPolygon.ShapeData shapeData)
        Construct the lists of indices that identify the tessellated shape's vertices in the vertex buffer.
        Parameters:
        shapeData - the current shape data.
      • isSameAsPreviousTerrain

        protected boolean isSameAsPreviousTerrain​(Terrain terrain)
      • intersect

        public java.util.List<Intersection> intersect​(Line line,
                                                      Terrain terrain)
                                               throws java.lang.InterruptedException
        Compute the intersections of a specified line with this extruded polygon. If the polygon's altitude mode is other than WorldWind.ABSOLUTE, the extruded 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:
        intersect in class AbstractShape
        Parameters:
        line - the line to intersect.
        terrain - the Terrain to use when computing the extruded polygon's geometry.
        Returns:
        a list of intersections identifying where the line intersects the extruded polygon, or null if the line does not intersect the extruded polygon.
        Throws:
        java.lang.InterruptedException - if the operation is interrupted.
        See Also:
        Terrain
      • intersectBoundarySides

        protected java.util.List<Intersection> intersectBoundarySides​(Line line,
                                                                      ExtrudedPolygon.ExtrudedBoundaryInfo boundary)
                                                               throws java.lang.InterruptedException
        Intersects a line with the sides of an individual boundary.
        Parameters:
        line - the line to intersect.
        boundary - the boundary to intersect.
        Returns:
        the computed intersections, or null if there are no intersections.
        Throws:
        java.lang.InterruptedException - if the operation is interrupted.
      • intersectCap

        protected void intersectCap​(Line line,
                                    ExtrudedPolygon.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.
      • doExportAsKML

        protected void doExportAsKML​(javax.xml.stream.XMLStreamWriter xmlWriter)
                              throws java.io.IOException,
                                     javax.xml.stream.XMLStreamException
        Description copied from class: AbstractShape
        Exports shape-specific fields.
        Specified by:
        doExportAsKML in class AbstractShape
        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.XMLStreamException
        Throws:
        java.io.IOException
        javax.xml.stream.XMLStreamException
      • exportBoundaryAsLinearRing

        protected void exportBoundaryAsLinearRing​(javax.xml.stream.XMLStreamWriter xmlWriter,
                                                  java.lang.Iterable<? extends LatLon> boundary)
                                           throws javax.xml.stream.XMLStreamException
        Writes 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.