Class RigidShape

    • Field Detail

      • faceCount

        protected int faceCount
      • centerPosition

        protected Position centerPosition
      • northSouthRadius

        protected double northSouthRadius
      • verticalRadius

        protected double verticalRadius
      • eastWestRadius

        protected double eastWestRadius
      • heading

        protected Angle heading
      • tilt

        protected Angle tilt
      • roll

        protected Angle roll
      • skewNorthSouth

        protected Angle skewNorthSouth
      • skewEastWest

        protected Angle skewEastWest
      • renderExtent

        protected boolean renderExtent
      • detailHint

        protected double detailHint
      • GEOMETRY_CACHE_KEY

        protected static final java.lang.String GEOMETRY_CACHE_KEY
      • DEFAULT_GEOMETRY_CACHE_SIZE

        protected static final long DEFAULT_GEOMETRY_CACHE_SIZE
        See Also:
        Constant Field Values
      • GEOMETRY_CACHE_NAME

        protected static final java.lang.String GEOMETRY_CACHE_NAME
        See Also:
        Constant Field Values
      • imageSources

        protected java.util.Map<java.lang.Integer,​java.lang.Object> imageSources
        The image source of the shape's texture.
      • textures

        protected java.util.Map<java.lang.Integer,​WWTexture> textures
        The WWTexture created for the image source, if any.
      • offsets

        protected java.util.Map<java.lang.Integer,​OffsetsList> offsets
      • offsetTextureCoords

        protected java.util.Map<java.lang.Integer,​java.nio.FloatBuffer> offsetTextureCoords
      • 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 RigidShape.ShapeData previousIntersectionShapeData
        The shape data used for the previous intersection calculation.
    • Constructor Detail

      • RigidShape

        public RigidShape()
    • Method Detail

      • getCurrentShapeData

        protected RigidShape.ShapeData getCurrentShapeData()
        Returns the current shape data cache entry.
        Returns:
        the current data cache entry.
      • 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
      • getTexture

        protected WWTexture getTexture​(int index)
        Returns the texture applied to this shape's #index piece of geometry. This method returns null if this piece of geometry's image source has not yet been retrieved.
        Parameters:
        index - the index of the piece of geometry whose texture will be returned.
        Returns:
        the texture, or null if there is no texture or the texture is not yet available.
      • setTexture

        protected void setTexture​(int index,
                                  WWTexture texture)
        Establishes the texture for this piece of the shape's geometry.
        Parameters:
        index - the index of the piece of geometry for which we are setting the texture.
        texture - the texture for this shape.
      • getImageSource

        public java.lang.Object getImageSource​(int index)
        Indicates the image source for this shape's optional texture for the #index piece of geometry.
        Parameters:
        index - the index of the piece of geometry for which we are retrieving the texture.
        Returns:
        the image source of #index texture.
      • setImageSources

        public void setImageSources​(java.lang.Object imageSource)
        Specifies the single image source for this shape's optional texture, to be placed on every face.
        Parameters:
        imageSource - the texture image source. May be a File, file path, a stream, a URL or a BufferedImage.
      • setImageSources

        public void setImageSources​(java.lang.Iterable imageSources)
        Specifies the image sources for this shape's optional textures.
        Parameters:
        imageSources - the list of texture image sources. May be File, file path, a stream, a URL or a BufferedImage.
      • setImageSource

        public void setImageSource​(int index,
                                   java.lang.Object imageSource)
        Specifies the image source for this shape's #index optional texture.
        Parameters:
        index - the index of the piece of geometry for which we are setting the imageSource.
        imageSource - the texture image source. May be a File, file path, a stream, a URL or a BufferedImage.
      • getFaceCount

        public int getFaceCount()
        Returns the number of separate faces that comprise this shape.
        Returns:
        number of faces
      • setFaceCount

        protected void setFaceCount​(int faces)
        Sets the number of separate faces that comprise this shape.
        Parameters:
        faces - integer indicating how many different faces this shape has
      • getSubdivisions

        public abstract int getSubdivisions()
      • getOffsets

        public float[] getOffsets​(int faceIndex,
                                  int offsetIndex)
        Returns the pair of texture coordinate offsets corresponding to the shape face and texture coordinate specified by the faceIndex and offsetIndex.
        Parameters:
        faceIndex - the shape face from which to retrieve the offset pair
        offsetIndex - the index of the specific texture coordinate on the face whose offsets we wish to retrieve
        Returns:
        the specified texture offset pair
      • setOffset

        public void setOffset​(int faceIndex,
                              int offsetIndex,
                              float uOffset,
                              float vOffset)
        Sets the u and v texture coordinate offsets for the specified texture coordinate on the specified shape face.
        Parameters:
        faceIndex - the shape face on which we would like to set the texture coordinate offsets
        offsetIndex - the index of the particular texture coordinate we would like to set offsets for
        uOffset - the offset in the u direction
        vOffset - the offset in the v direction
      • getCenterPosition

        public Position getCenterPosition()
        Indicates this shape's center position.
        Returns:
        this shape's center position.
      • setCenterPosition

        public void setCenterPosition​(Position centerPosition)
        Specifies this shape's center position.
        Parameters:
        centerPosition - this shape's center position.
      • getReferencePosition

        public Position getReferencePosition()
        Returns the shape's referencePosition, which is its centerPosition
        Returns:
        the centerPosition of the shape
      • getNorthSouthRadius

        public double getNorthSouthRadius()
        Indicates the radius of this shape's axis in the north-south (latitudinal) direction.
        Returns:
        this shape's radius in the north-south direction.
      • setNorthSouthRadius

        public void setNorthSouthRadius​(double northSouthRadius)
        Specifies this shape's radius in meters in the north-south (latitudinal) direction. The radius must be greater than 0.
        Parameters:
        northSouthRadius - the shape radius in the north-south direction. Must be greater than 0.
        Throws:
        java.lang.IllegalArgumentException - if the radius is not greater than 0.
      • getEastWestRadius

        public double getEastWestRadius()
        Indicates the radius of this shape's axis in the east-west (longitudinal) direction.
        Returns:
        this shape's radius in the east-west direction.
      • setEastWestRadius

        public void setEastWestRadius​(double eastWestRadius)
        Specifies this shape's radius in meters in the east-west (longitudinal) direction. The radius must be greater than 0.
        Parameters:
        eastWestRadius - the shape radius in the east-west direction. Must be greater than 0.
        Throws:
        java.lang.IllegalArgumentException - if the radius is not greater than 0.
      • getVerticalRadius

        public double getVerticalRadius()
        Indicates the radius of this shape's axis in the vertical (altitudinal) direction.
        Returns:
        this shape's radius in the vertical direction.
      • setVerticalRadius

        public void setVerticalRadius​(double verticalRadius)
        Specifies this shape's radius in meters in the vertical (altitudinal) direction. The radius must be greater than 0.
        Parameters:
        verticalRadius - the shape radius in the vertical direction. Must be greater than 0.
        Throws:
        java.lang.IllegalArgumentException - if the radius is not greater than 0.
      • getHeading

        public Angle getHeading()
        Indicates this shape's azimuth, its rotation about its vertical axis. North corresponds to an azimuth of 0. Angles are in degrees and positive clockwise.
        Returns:
        this shape's azimuth.
      • setHeading

        public void setHeading​(Angle heading)
        Specifies this shape's azimuth, its rotation about its vertical axis. North corresponds to an azimuth of 0. Angles are in degrees and positive clockwise.
        Parameters:
        heading - the shape's azimuth, in degrees.
      • getTilt

        public Angle getTilt()
        Indicates this shape's pitch, its rotation about its east-west axis. Angles are positive clockwise.
        Returns:
        this shape's azimuth.
      • setTilt

        public void setTilt​(Angle tilt)
        Specifies this shape's pitch, its rotation about its east-west axis. Angles are positive clockwise.
        Parameters:
        tilt - the shape's pitch, in degrees.
      • getRoll

        public Angle getRoll()
        Indicates this shape's roll, its rotation about its north-south axis. Angles are positive clockwise.
        Returns:
        this shape's azimuth.
      • setRoll

        public void setRoll​(Angle roll)
        Specifies this shape's roll, its rotation about its north-south axis. Angles are in degrees and positive clockwise.
        Parameters:
        roll - the shape's roll, in degrees.
      • getSkewNorthSouth

        public Angle getSkewNorthSouth()
        Indicates this shape's skew, its shearing along its north-south axis. Angles are positive counter-clockwise.
        Returns:
        this shape's North-South skew.
      • setSkewNorthSouth

        public void setSkewNorthSouth​(Angle skew)
        Specifies this shape's skew, its shearing along its north-south axis. Angles are in degrees and positive counter-clockwise.
        Parameters:
        skew - the shape's skew in the North-South direction.
      • getSkewEastWest

        public Angle getSkewEastWest()
        Indicates this shape's skew, its shearing along its east-west axis. Angles are positive counter-clockwise.
        Returns:
        this shape's East-West skew.
      • setSkewEastWest

        public void setSkewEastWest​(Angle skew)
        Specifies this shape's skew, its shearing along its east-west axis. Angles are in degrees and positive counter-clockwise.
        Parameters:
        skew - the shape's skew in the East-West direction.
      • 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
      • setDetailHint

        public void setDetailHint​(double detailHint)
        Modifies the relationship of the shape's tessellation resolution to its distance from the eye. Values greater than 0 cause higher resolution tessellation, but at an increased performance cost. Values less than 0 decrease the default tessellation resolution at any given distance from the eye. The default value is 0. Values typically range between -0.5 and 0.5.
        Parameters:
        detailHint - the degree to modify the default tessellation resolution of the shape. Values greater than 1 increase the resolution. Values less than zero decrease the resolution. The default value is 0.
      • setUpGeometryCache

        protected void setUpGeometryCache()
        Create the geometry cache supporting the Level of Detail system.
      • getGeometryCache

        protected MemoryCache getGeometryCache()
        Retrieve the geometry cache supporting the Level of Detail system.
        Returns:
        the geometry cache.
      • 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.
      • mustApplyTexture

        protected boolean mustApplyTexture​(int index)
      • 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.
      • 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.
      • computeExtent

        protected Extent computeExtent​(DrawContext dc)
        Computes the shape's extent using a bounding box. Code within this class assumes that this shape's extent is computed from the shape's fields rather than its computed geometry. If you override this method, be sure that this lack of dependency on computed geometry is adhered to by the overriding method. See doMakeOrderedRenderable above for a description of why this assumption is made. Also see WWJ-482.
        Parameters:
        dc - the current drawContext
        Returns:
        the computed extent.
      • getExtent

        public Extent getExtent​(Globe globe,
                                double verticalExaggeration)
        Computes the shape's extent using a bounding box.
        Specified by:
        getExtent in interface ExtentHolder
        Overrides:
        getExtent in class AbstractShape
        Parameters:
        globe - the current globe
        verticalExaggeration - the current vertical exaggeration
        Returns:
        the computed extent.
        Throws:
        java.lang.IllegalArgumentException - if the globe is null.
      • getSector

        public Sector getSector()
        Computes the shape's sector. Not currently supported.
        Returns:
        the bounding sector for this shape
      • computeTransformedVertices

        protected java.nio.FloatBuffer computeTransformedVertices​(java.nio.FloatBuffer vertices,
                                                                  int numVertices,
                                                                  Matrix matrix)
        Transform all vertices with the provided matrix
        Parameters:
        vertices - the buffer of vertices to transform
        numVertices - the number of distinct vertices in the buffer (assume 3-space)
        matrix - the matrix for transforming the vertices
        Returns:
        the transformed vertices.
      • computeReferencePoint

        public Vec4 computeReferencePoint​(DrawContext dc)
        Sets the shape's referencePoint, which is essentially its centerPosition in Cartesian coordinates.
        Parameters:
        dc - the current DrawContext
        Returns:
        the computed reference point relative to the globe associated with the draw context.
      • computeReferencePoint

        protected Vec4 computeReferencePoint​(Globe globe,
                                             double verticalExaggeration)
        Sets the shape's referencePoint, which is essentially its centerPosition in Cartesian coordinates.
        Parameters:
        globe - the current globe
        verticalExaggeration - the current vertical exaggeration
        Returns:
        the computed reference point, or null if the point could not be computed.
      • computeRenderMatrix

        public Matrix computeRenderMatrix​(Globe globe,
                                          double verticalExaggeration)
        Computes the transform to use during rendering to convert the unit sphere geometry representation of this shape to its correct shape location, orientation and scale
        Parameters:
        globe - the current globe
        verticalExaggeration - the current vertical exaggeration
        Returns:
        the modelview transform for this shape
        Throws:
        java.lang.IllegalArgumentException - if globe is null
      • computeRenderMatrix

        public Matrix computeRenderMatrix​(DrawContext dc)
        Computes the transform to use during rendering to convert the unit sphere geometry representation of this shape to its correct shape location, orientation and scale
        Parameters:
        dc - the current draw context
        Returns:
        the modelview transform for this shape
        Throws:
        java.lang.IllegalArgumentException - if draw context is null or the referencePoint is null
      • computeRenderMatrixInverse

        public Matrix computeRenderMatrixInverse​(Globe globe,
                                                 double verticalExaggeration)
        Computes the inverse of the transform to use during rendering to convert the unit geometry representation of this shape to its correct shape location, orientation and scale, essentially bringing the shape back into local coordinate space.
        Parameters:
        globe - the current globe
        verticalExaggeration - the current vertical exaggeration
        Returns:
        the inverse of the modelview transform for this shape
        Throws:
        java.lang.IllegalArgumentException - if draw context is null or the referencePoint is null
      • setModelViewMatrix

        protected void setModelViewMatrix​(DrawContext dc)
        Called during drawing to set the modelview matrix to apply the correct position, scale and orientation for this shape.
        Parameters:
        dc - the current DrawContext
        Throws:
        java.lang.IllegalArgumentException - if draw context is null or the draw context GL is null
      • moveTo

        public void moveTo​(Position position)
        Move the Rigid Shape to the specified destination.
        Parameters:
        position - the position to move the shape to
      • computeSubdivisions

        protected abstract void computeSubdivisions​(DrawContext dc,
                                                    RigidShape.ShapeData shapeData)
        Computes the number of subdivisions necessary to achieve the expected Level of Detail given the shape's relationship to the viewer.
        Parameters:
        dc - the current drawContext.
        shapeData - the current globe-specific shape data
      • makeGeometry

        protected abstract void makeGeometry​(RigidShape.ShapeData shapeData)
        Sets the Geometry mesh for this shape, either by pulling it from the geometryCache, or by creating it anew if the appropriate geometry does not yet exist in the cache.
        Parameters:
        shapeData - the current shape data.
      • drawGeometry

        protected void drawGeometry​(DrawContext dc,
                                    RigidShape.ShapeData shapeData,
                                    int index)
        Renders the Rigid Shape
        Parameters:
        dc - the current draw context
        shapeData - the current shape data
        index - the index of the shape face to render
        Throws:
        java.lang.IllegalArgumentException - if the draw context is null or the element buffer is null
      • drawGeometry

        protected abstract void drawGeometry​(DrawContext dc,
                                             int mode,
                                             int count,
                                             int type,
                                             java.nio.Buffer elementBuffer,
                                             RigidShape.ShapeData shapeData,
                                             int index)
        Renders the shape, using data from the provided buffer and the given parameters.
        Parameters:
        dc - the current draw context
        mode - the render mode
        count - the number of elements to be drawn
        type - the data type of the elements to be drawn
        elementBuffer - the buffer containing the list of elements to be drawn
        shapeData - this shape's current globe-specific shape data
        index - the index of the shape face to render
      • getVboIds

        protected int[] getVboIds​(int index,
                                  DrawContext dc)
        Get or create OpenGL resource IDs for the current data cache entry.

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

        Parameters:
        index - the index of the LOD whose VboID's will be retrieved.
        dc - the current draw context.
        Returns:
        an array containing the coordinate vertex buffer ID in the first position and the index vertex buffer ID in the second position.
      • 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:
        fillVBO in class AbstractShape
        Parameters:
        dc - the current draw context.
      • 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 shape. If the shape's altitude mode is other than WorldWind.ABSOLUTE, the shape'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 wedge's geometry.
        Returns:
        a list of intersections identifying where the line intersects the shape, or null if the line does not intersect the shape.
        Throws:
        java.lang.InterruptedException - if the operation is interrupted.
        See Also:
        Terrain
      • intersect

        public java.util.List<Intersection> intersect​(Line line,
                                                      Terrain terrain,
                                                      int index)
                                               throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • intersect

        protected void intersect​(Line line,
                                 RigidShape.ShapeData shapeData,
                                 java.util.List<Intersection> intersections,
                                 int index)
                          throws java.lang.InterruptedException
        Throws:
        java.lang.InterruptedException
      • intersectFace

        public java.util.List<Intersection> intersectFace​(Line line,
                                                          int index,
                                                          Matrix renderMatrix)
                                                   throws java.lang.InterruptedException
        Returns intersections of line with the ith face of this shape, Assumes we already know the line intersects the shape somewhere (but perhaps not on this face)
        Parameters:
        line - the line to intersect.
        index - the index of the face to test for intersections
        renderMatrix - the current renderMatrix
        Returns:
        a list of intersections identifying where the line intersects this shape face, or null if the line does not intersect this face.
        Throws:
        java.lang.InterruptedException - if the operation is interrupted.
      • getRestorableState

        public java.lang.String getRestorableState()
        Description copied from interface: Restorable
        Returns an XML document string describing the object's state. This state can be restored later by calling restoreState and passing the XML document.
        Specified by:
        getRestorableState in interface Restorable
        Overrides:
        getRestorableState in class AbstractShape
        Returns:
        an XML document string describing the object's state.
      • restoreState

        public void restoreState​(java.lang.String stateInXml)
        Description copied from interface: Restorable
        Restores the object's state to what is described in the specified XML document string.
        Specified by:
        restoreState in interface Restorable
        Overrides:
        restoreState in class AbstractShape
        Parameters:
        stateInXml - an XML document string describing an object's state.