NASA World Wind

gov.nasa.worldwind.render
Class RigidShape

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.WWObjectImpl
          extended by gov.nasa.worldwind.render.AbstractShape
              extended by gov.nasa.worldwind.render.RigidShape
All Implemented Interfaces:
AVList, MessageListener, Exportable, ExtentHolder, Movable, GeographicExtent, Highlightable, OrderedRenderable, Renderable, Restorable, WWObject, PropertyChangeListener, EventListener
Direct Known Subclasses:
Box, Cone, Cylinder, Ellipsoid, Pyramid, Wedge

public abstract class RigidShape
extends AbstractShape

A general rigid volume defined by a center position and the three axis radii. If A is the radius in the north-south direction, and b is the radius in the east-west direction, and c is the radius in the vertical direction (increasing altitude), then A == B == C defines a unit shape, A == B > C defines a vertically flattened shape (disk-shaped), A == B < C defines a vertically stretched shape.


Nested Class Summary
 class RigidShape.Offsets
           
protected static class RigidShape.ShapeData
          Maintains globe-dependent computed data such as Cartesian vertices and extents.
 
Nested classes/interfaces inherited from class gov.nasa.worldwind.render.AbstractShape
AbstractShape.AbstractShapeData
 
Field Summary
protected  Position centerPosition
           
protected static long DEFAULT_GEOMETRY_CACHE_SIZE
           
protected  double detailHint
           
protected  double eastWestRadius
           
protected  int faceCount
           
protected static String GEOMETRY_CACHE_KEY
           
protected static String GEOMETRY_CACHE_NAME
           
protected  GeometryBuilder geometryBuilder
           
protected  Angle heading
           
protected  Map<Integer,Object> imageSources
          The image source of the shape's texture.
protected  double northSouthRadius
           
protected  Map<Integer,OffsetsList> offsets
           
protected  Map<Integer,FloatBuffer> offsetTextureCoords
           
protected  Object previousIntersectionGlobeStateKey
          The globe state key for the globe used in the most recent intersection calculation.
protected  RigidShape.ShapeData previousIntersectionShapeData
          The shape data used for the previous intersection calculation.
protected  Terrain previousIntersectionTerrain
          The terrain used in the most recent intersection calculations.
protected  boolean renderExtent
           
protected  Angle roll
           
protected  Angle skewEastWest
           
protected  Angle skewNorthSouth
           
protected  Map<Integer,WWTexture> textures
          The WWTexture created for the image source, if any.
protected  Angle tilt
           
protected  double verticalRadius
           
 
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, enableBatchPicking, enableBatchRendering, enableDepthOffset, highlightAttrs, highlighted, maxExpiryTime, minExpiryTime, normalAttrs, outlinePickWidth, outlineShapeRenderer, pickLayer, pickSupport, referencePosition, sector, shapeDataCache, VBO_THRESHOLD, viewDistanceExpiration, visible
 
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
 
Constructor Summary
RigidShape()
           
 
Method Summary
protected  OGLStackHandler beginDrawing(DrawContext dc, int attrMask)
          Establish the OpenGL state needed to draw this shape.
protected  void clearCachedVbos(DrawContext dc)
          Removes from the GPU resource cache the entry for the current data cache entry's VBOs.
 void clearIntersectionGeometry()
           
protected  Extent computeExtent(DrawContext dc)
          Computes the shape's extent using a bounding box.
 Vec4 computeReferencePoint(DrawContext dc)
          Sets the shape's referencePoint, which is essentially its centerPosition in Cartesian coordinates.
protected  Vec4 computeReferencePoint(Globe globe, double verticalExaggeration)
          Sets the shape's referencePoint, which is essentially its centerPosition in Cartesian coordinates.
 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
 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
 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.
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.
protected  FloatBuffer computeTransformedVertices(FloatBuffer vertices, int numVertices, Matrix matrix)
          Transform all vertices with the provided matrix
protected  AbstractShape.AbstractShapeData createCacheEntry(DrawContext dc)
          Creates and returns a new cache entry specific to the subclass.
protected abstract  RigidShape.ShapeData createIntersectionGeometry(Terrain terrain)
           
protected  void doDrawInterior(DrawContext dc)
          Draws this shape's interior.
protected  void doDrawOutline(DrawContext dc)
          Draws this shape's outline.
protected  void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected  boolean doMakeOrderedRenderable(DrawContext dc)
          Produces the geometry and other state necessary to represent this shape as an ordered renderable.
protected  void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
           
protected abstract  void drawGeometry(DrawContext dc, int mode, int count, int type, Buffer elementBuffer, RigidShape.ShapeData shapeData, int index)
          Renders the shape, using data from the provided buffer and the given parameters.
protected  void drawGeometry(DrawContext dc, RigidShape.ShapeData shapeData, int index)
          Renders the Rigid Shape
protected  void fillVBO(DrawContext dc)
          Fill this shape's vertex buffer objects.
 Position getCenterPosition()
          Indicates this shape's center position.
protected  RigidShape.ShapeData getCurrentShapeData()
          Returns the current shape data cache entry.
 double getDetailHint()
          Indicates the shape's detail hint, which is described in setDetailHint(double).
 double getEastWestRadius()
          Indicates the radius of this shape's axis in the east-west (longitudinal) direction.
 Extent getExtent(Globe globe, double verticalExaggeration)
          Computes the shape's extent using a bounding box.
 int getFaceCount()
          Returns the number of separate faces that comprise this shape.
protected  GeometryBuilder getGeometryBuilder()
           
protected  MemoryCache getGeometryCache()
          Retrieve the geometry cache supporting the Level of Detail system.
 Angle getHeading()
          Indicates this shape's azimuth, its rotation about its vertical axis.
 Object getImageSource(int index)
          Indicates the image source for this shape's optional texture for the #index piece of geometry.
 double getNorthSouthRadius()
          Indicates the radius of this shape's axis in the north-south (latitudinal) direction.
 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.
 Position getReferencePosition()
          Returns the shape's referencePosition, which is its centerPosition
 String getRestorableState()
          Returns an XML document string describing the object's state.
 Angle getRoll()
          Indicates this shape's roll, its rotation about its north-south axis.
 Sector getSector()
          Computes the shape's sector.
 Angle getSkewEastWest()
          Indicates this shape's skew, its shearing along its east-west axis.
 Angle getSkewNorthSouth()
          Indicates this shape's skew, its shearing along its north-south axis.
abstract  int getSubdivisions()
           
protected  WWTexture getTexture(int index)
          Returns the texture applied to this shape's #index piece of geometry.
 Angle getTilt()
          Indicates this shape's pitch, its rotation about its east-west axis.
protected  int[] getVboIds(int index, DrawContext dc)
          Get or create OpenGL resource IDs for the current data cache entry.
 double getVerticalRadius()
          Indicates the radius of this shape's axis in the vertical (altitudinal) direction.
protected  void initialize()
          Called during construction to establish any subclass-specific state such as different default values than those set by this class.
protected  void intersect(Line line, RigidShape.ShapeData shapeData, List<Intersection> intersections, int index)
           
 List<Intersection> intersect(Line line, Terrain terrain)
          Compute the intersections of a specified line with this shape.
 List<Intersection> intersect(Line line, Terrain terrain, int index)
           
 List<Intersection> intersectFace(Line line, int index, Matrix renderMatrix)
          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)
protected  boolean isOrderedRenderableValid(DrawContext dc)
          Determines whether this shape's ordered renderable state is valid and can be rendered.
protected  boolean isSameAsPreviousTerrain(Terrain terrain)
           
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.
 void moveTo(Position position)
          Move the Rigid Shape to the specified destination.
protected  boolean mustApplyTexture(DrawContext dc)
          Indicates whether texture should be applied to this shape.
protected  boolean mustApplyTexture(int index)
           
protected  boolean mustRegenerateGeometry(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.
protected  void reset()
          Invalidates computed values.
 void restoreState(String stateInXml)
          Restores the object's state to what is described in the specified XML document string.
 void setCenterPosition(Position centerPosition)
          Specifies this shape's center position.
 void setDetailHint(double detailHint)
          Modifies the relationship of the shape's tessellation resolution to its distance from the eye.
 void setEastWestRadius(double eastWestRadius)
          Specifies this shape's radius in meters in the east-west (longitudinal) direction.
protected  void setFaceCount(int faces)
          Sets the number of separate faces that comprise this shape.
 void setHeading(Angle heading)
          Specifies this shape's azimuth, its rotation about its vertical axis.
 void setImageSource(int index, Object imageSource)
          Specifies the image source for this shape's #index optional texture.
 void setImageSources(Iterable imageSources)
          Specifies the image sources for this shape's optional textures.
 void setImageSources(Object imageSource)
          Specifies the single image source for this shape's optional texture, to be placed on every face.
protected  void setModelViewMatrix(DrawContext dc)
          Called during drawing to set the modelview matrix to apply the correct position, scale and orientation for this shape.
 void setNorthSouthRadius(double northSouthRadius)
          Specifies this shape's radius in meters in the north-south (latitudinal) direction.
 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.
 void setRoll(Angle roll)
          Specifies this shape's roll, its rotation about its north-south axis.
 void setSkewEastWest(Angle skew)
          Specifies this shape's skew, its shearing along its east-west axis.
 void setSkewNorthSouth(Angle skew)
          Specifies this shape's skew, its shearing along its north-south axis.
protected  void setTexture(int index, WWTexture texture)
          Establishes the texture for this piece of the shape's geometry.
 void setTilt(Angle tilt)
          Specifies this shape's pitch, its rotation about its east-west axis.
protected  void setUpGeometryCache()
          Create the geometry cache supporting the Level of Detail system.
 void setVerticalRadius(double verticalRadius)
          Specifies this shape's radius in meters in the vertical (altitudinal) direction.
 
Methods inherited from class gov.nasa.worldwind.render.AbstractShape
addOrderedRenderable, checkViewDistanceExpiration, computeExtentFromPositions, computePoint, countTriangleVertices, createPickedObject, determineActiveAttributes, doDrawOrderedRenderable, doExportAsKML, drawBatched, drawInterior, drawOrderedRenderable, drawOutline, endDrawing, export, exportAsKML, getActiveAttributes, getAltitudeMode, getAttributes, getCurrentData, getDelegateOwner, getDistanceFromEye, getExtent, getGeometryRegenerationInterval, getHighlightAttributes, getOutlinePickWidth, getReferencePoint, getVboIds, intersectsFrustum, isEnableBatchPicking, isEnableBatchRendering, isEnableDepthOffset, isExportFormatSupported, isHighlighted, isTerrainDependent, isViewDistanceExpiration, isVisible, makeOrderedRenderable, makeTexture, move, mustApplyLighting, mustApplyLighting, mustCreateNormals, mustCreateNormals, mustDrawInterior, mustDrawOutline, pick, prepareToDrawInterior, prepareToDrawOutline, render, setAltitudeMode, setAttributes, setDelegateOwner, setEnableBatchPicking, setEnableBatchRendering, setEnableDepthOffset, setGeometryRegenerationInterval, setHighlightAttributes, setHighlighted, setOutlinePickWidth, setReferencePosition, setViewDistanceExpiration, setVisible, shouldUseVBOs
 
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 

Field Detail

centerPosition

protected Position centerPosition

DEFAULT_GEOMETRY_CACHE_SIZE

protected static final long DEFAULT_GEOMETRY_CACHE_SIZE
See Also:
Constant Field Values

detailHint

protected double detailHint

eastWestRadius

protected double eastWestRadius

faceCount

protected int faceCount

GEOMETRY_CACHE_KEY

protected static final String GEOMETRY_CACHE_KEY

GEOMETRY_CACHE_NAME

protected static final String GEOMETRY_CACHE_NAME
See Also:
Constant Field Values

geometryBuilder

protected GeometryBuilder geometryBuilder

heading

protected Angle heading

imageSources

protected Map<Integer,Object> imageSources
The image source of the shape's texture.


northSouthRadius

protected double northSouthRadius

offsets

protected Map<Integer,OffsetsList> offsets

offsetTextureCoords

protected Map<Integer,FloatBuffer> offsetTextureCoords

previousIntersectionGlobeStateKey

protected 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.


previousIntersectionTerrain

protected Terrain previousIntersectionTerrain
The terrain used in the most recent intersection calculations.


renderExtent

protected boolean renderExtent

roll

protected Angle roll

skewEastWest

protected Angle skewEastWest

skewNorthSouth

protected Angle skewNorthSouth

textures

protected Map<Integer,WWTexture> textures
The WWTexture created for the image source, if any.


tilt

protected Angle tilt

verticalRadius

protected double verticalRadius
Constructor Detail

RigidShape

public RigidShape()
Method Detail

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.

clearCachedVbos

protected void clearCachedVbos(DrawContext dc)
Removes from the GPU resource cache the entry for the current data cache entry's VBOs.

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

Overrides:
clearCachedVbos in class AbstractShape
Parameters:
dc - the current draw context.

clearIntersectionGeometry

public void clearIntersectionGeometry()

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.

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(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:
IllegalArgumentException - if draw context is null or the referencePoint is null

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:
IllegalArgumentException - if globe 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:
IllegalArgumentException - if draw context is null or the referencePoint is null

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

computeTransformedVertices

protected FloatBuffer computeTransformedVertices(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.

createCacheEntry

protected AbstractShape.AbstractShapeData createCacheEntry(DrawContext dc)
Description copied from class: AbstractShape
Creates and returns a new cache entry specific to the subclass.

Specified by:
createCacheEntry in class AbstractShape
Parameters:
dc - the current draw context.
Returns:
a data cache entry for the state in the specified draw context.

createIntersectionGeometry

protected abstract RigidShape.ShapeData createIntersectionGeometry(Terrain terrain)

doDrawInterior

protected void doDrawInterior(DrawContext dc)
Description copied from class: AbstractShape
Draws this shape's interior. Called immediately after calling AbstractShape.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.AbstractShapeData must be current when this method is called.

Specified by:
doDrawInterior in class AbstractShape
Parameters:
dc - the current draw context.

doDrawOutline

protected void doDrawOutline(DrawContext dc)
Description copied from class: AbstractShape
Draws this shape's outline. Called immediately after calling AbstractShape.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.AbstractShapeData must be current when this method is called.

Specified by:
doDrawOutline in class AbstractShape
Parameters:
dc - the current draw context.

doGetRestorableState

protected void doGetRestorableState(RestorableSupport rs,
                                    RestorableSupport.StateObject context)
Overrides:
doGetRestorableState in class AbstractShape

doMakeOrderedRenderable

protected boolean doMakeOrderedRenderable(DrawContext dc)
Description copied from class: AbstractShape
Produces 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 during AbstractShape.pick(DrawContext, java.awt.Point) and AbstractShape.render(DrawContext) when it's been determined that the shape is likely to be visible.

Specified by:
doMakeOrderedRenderable in class AbstractShape
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)

doRestoreState

protected void doRestoreState(RestorableSupport rs,
                              RestorableSupport.StateObject context)
Overrides:
doRestoreState in class AbstractShape

drawGeometry

protected abstract void drawGeometry(DrawContext dc,
                                     int mode,
                                     int count,
                                     int type,
                                     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

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:
IllegalArgumentException - if the draw context is null or the element buffer is null

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.

getCenterPosition

public Position getCenterPosition()
Indicates this shape's center position.

Returns:
this shape's center position.

getCurrentShapeData

protected RigidShape.ShapeData getCurrentShapeData()
Returns the current shape data cache entry.

Returns:
the current data cache entry.

getDetailHint

public double getDetailHint()
Indicates the shape's detail hint, which is described in setDetailHint(double).

Returns:
the detail hint
See Also:
setDetailHint(double)

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.

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:
IllegalArgumentException - if the globe is null.

getFaceCount

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

Returns:
number of faces

getGeometryBuilder

protected GeometryBuilder getGeometryBuilder()

getGeometryCache

protected MemoryCache getGeometryCache()
Retrieve the geometry cache supporting the Level of Detail system.

Returns:
the geometry cache.

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.

getImageSource

public 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.

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.

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

getReferencePosition

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

Returns:
the centerPosition of the shape

getRestorableState

public 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.

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.

getSector

public Sector getSector()
Computes the shape's sector. Not currently supported.

Returns:
the bounding sector for this shape

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.

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.

getSubdivisions

public abstract int getSubdivisions()

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.

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.

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.

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.

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

intersect

protected void intersect(Line line,
                         RigidShape.ShapeData shapeData,
                         List<Intersection> intersections,
                         int index)
                  throws InterruptedException
Throws:
InterruptedException

intersect

public List<Intersection> intersect(Line line,
                                    Terrain terrain)
                             throws 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:
InterruptedException - if the operation is interrupted.
See Also:
Terrain

intersect

public List<Intersection> intersect(Line line,
                                    Terrain terrain,
                                    int index)
                             throws InterruptedException
Throws:
InterruptedException

intersectFace

public List<Intersection> intersectFace(Line line,
                                        int index,
                                        Matrix renderMatrix)
                                 throws 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:
InterruptedException - if the operation is interrupted.

isOrderedRenderableValid

protected boolean isOrderedRenderableValid(DrawContext dc)
Description copied from class: AbstractShape
Determines whether this shape's ordered renderable state is valid and can be rendered. Called by AbstractShape.makeOrderedRenderable(DrawContext)just prior to adding the shape to the ordered renderable list.

Specified by:
isOrderedRenderableValid in class AbstractShape
Parameters:
dc - the current draw context.
Returns:
true if this shape is ready to be rendered as an ordered renderable.

isSameAsPreviousTerrain

protected boolean isSameAsPreviousTerrain(Terrain terrain)

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.

moveTo

public void moveTo(Position position)
Move the Rigid Shape to the specified destination.

Parameters:
position - the position to move the shape to

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.

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

restoreState

public void restoreState(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.

setCenterPosition

public void setCenterPosition(Position centerPosition)
Specifies this shape's center position.

Parameters:
centerPosition - this shape's center position.

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.

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:
IllegalArgumentException - if the radius is not greater than 0.

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

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.

setImageSource

public void setImageSource(int index,
                           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.

setImageSources

public void setImageSources(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.

setImageSources

public void setImageSources(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.

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:
IllegalArgumentException - if draw context is null or the draw context GL is null

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:
IllegalArgumentException - if the radius is not greater than 0.

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

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.

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.

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.

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.

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.

setUpGeometryCache

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


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:
IllegalArgumentException - if the radius is not greater than 0.

NASA World Wind