Package gov.nasa.worldwind.render
Class RigidShape
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.WWObjectImpl
-
- gov.nasa.worldwind.render.AbstractShape
-
- gov.nasa.worldwind.render.RigidShape
-
- All Implemented Interfaces:
AVList,Draggable,MessageListener,Exportable,ExtentHolder,Movable,Movable2,Attributable,GeographicExtent,Highlightable,OrderedRenderable,PreRenderable,Renderable,Restorable,WWObject,java.beans.PropertyChangeListener,java.util.EventListener
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
Nested Classes Modifier and Type Class Description classRigidShape.Offsetsprotected static classRigidShape.ShapeDataMaintains 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
Fields Modifier and Type Field Description protected PositioncenterPositionprotected static longDEFAULT_GEOMETRY_CACHE_SIZEprotected doubledetailHintprotected doubleeastWestRadiusprotected intfaceCountprotected static java.lang.StringGEOMETRY_CACHE_KEYprotected static java.lang.StringGEOMETRY_CACHE_NAMEprotected GeometryBuildergeometryBuilderprotected Angleheadingprotected java.util.Map<java.lang.Integer,java.lang.Object>imageSourcesThe image source of the shape's texture.protected doublenorthSouthRadiusprotected java.util.Map<java.lang.Integer,OffsetsList>offsetsprotected java.util.Map<java.lang.Integer,java.nio.FloatBuffer>offsetTextureCoordsprotected java.lang.ObjectpreviousIntersectionGlobeStateKeyThe globe state key for the globe used in the most recent intersection calculation.protected RigidShape.ShapeDatapreviousIntersectionShapeDataThe shape data used for the previous intersection calculation.protected TerrainpreviousIntersectionTerrainThe terrain used in the most recent intersection calculations.protected booleanrenderExtentprotected Anglerollprotected AngleskewEastWestprotected AngleskewNorthSouthprotected java.util.Map<java.lang.Integer,WWTexture>texturesTheWWTexturecreated for the image source, if any.protected Angletiltprotected doubleverticalRadius-
Fields inherited from class gov.nasa.worldwind.render.AbstractShape
activeAttributes, altitudeMode, BEogsh, currentData, DEFAULT_ALTITUDE_MODE, DEFAULT_GEOMETRY_GENERATION_INTERVAL, DEFAULT_HIGHLIGHT_MATERIAL, DEFAULT_INTERIOR_MATERIAL, DEFAULT_OUTLINE_MATERIAL, DEFAULT_OUTLINE_PICK_WIDTH, defaultAttributes, delegateOwner, dragEnabled, draggableSupport, enableBatchPicking, enableBatchRendering, enableDepthOffset, highlightAttrs, highlighted, maxExpiryTime, minExpiryTime, normalAttrs, outlinePickWidth, outlineShapeRenderer, pickLayer, pickSupport, referencePosition, sector, shapeDataCache, surfaceShape, VBO_THRESHOLD, viewDistanceExpiration, visible
-
Fields inherited from interface gov.nasa.worldwind.Exportable
FORMAT_NOT_SUPPORTED, FORMAT_PARTIALLY_SUPPORTED, FORMAT_SUPPORTED
-
-
Constructor Summary
Constructors Constructor Description RigidShape()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected OGLStackHandlerbeginDrawing(DrawContext dc, int attrMask)Establish the OpenGL state needed to draw this shape.protected voidclearCachedVbos(DrawContext dc)Removes from the GPU resource cache the entry for the current data cache entry's VBOs.voidclearIntersectionGeometry()protected ExtentcomputeExtent(DrawContext dc)Computes the shape's extent using a bounding box.protected Vec4computeReferencePoint(Globe globe, double verticalExaggeration)Sets the shape's referencePoint, which is essentially its centerPosition in Cartesian coordinates.Vec4computeReferencePoint(DrawContext dc)Sets the shape's referencePoint, which is essentially its centerPosition in Cartesian coordinates.MatrixcomputeRenderMatrix(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 scaleMatrixcomputeRenderMatrix(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 scaleMatrixcomputeRenderMatrixInverse(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 voidcomputeSubdivisions(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 java.nio.FloatBuffercomputeTransformedVertices(java.nio.FloatBuffer vertices, int numVertices, Matrix matrix)Transform all vertices with the provided matrixprotected AbstractShape.AbstractShapeDatacreateCacheEntry(DrawContext dc)Creates and returns a new cache entry specific to the subclass.protected abstract RigidShape.ShapeDatacreateIntersectionGeometry(Terrain terrain)protected voiddoDrawInterior(DrawContext dc)Draws this shape's interior.protected voiddoDrawOutline(DrawContext dc)Draws this shape's outline.protected voiddoGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)protected booleandoMakeOrderedRenderable(DrawContext dc)Produces the geometry and other state necessary to represent this shape as an ordered renderable.protected voiddoRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)protected abstract voiddrawGeometry(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.protected voiddrawGeometry(DrawContext dc, RigidShape.ShapeData shapeData, int index)Renders the Rigid Shapeprotected voidfillVBO(DrawContext dc)Fill this shape's vertex buffer objects.PositiongetCenterPosition()Indicates this shape's center position.protected RigidShape.ShapeDatagetCurrentShapeData()Returns the current shape data cache entry.doublegetDetailHint()Indicates the shape's detail hint, which is described insetDetailHint(double).doublegetEastWestRadius()Indicates the radius of this shape's axis in the east-west (longitudinal) direction.ExtentgetExtent(Globe globe, double verticalExaggeration)Computes the shape's extent using a bounding box.intgetFaceCount()Returns the number of separate faces that comprise this shape.protected GeometryBuildergetGeometryBuilder()protected MemoryCachegetGeometryCache()Retrieve the geometry cache supporting the Level of Detail system.AnglegetHeading()Indicates this shape's azimuth, its rotation about its vertical axis.java.lang.ObjectgetImageSource(int index)Indicates the image source for this shape's optional texture for the #index piece of geometry.doublegetNorthSouthRadius()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.PositiongetReferencePosition()Returns the shape's referencePosition, which is its centerPositionjava.lang.StringgetRestorableState()Returns an XML document string describing the object's state.AnglegetRoll()Indicates this shape's roll, its rotation about its north-south axis.SectorgetSector()Computes the shape's sector.AnglegetSkewEastWest()Indicates this shape's skew, its shearing along its east-west axis.AnglegetSkewNorthSouth()Indicates this shape's skew, its shearing along its north-south axis.abstract intgetSubdivisions()protected WWTexturegetTexture(int index)Returns the texture applied to this shape's #index piece of geometry.AnglegetTilt()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.doublegetVerticalRadius()Indicates the radius of this shape's axis in the vertical (altitudinal) direction.protected voidinitialize()Called during construction to establish any subclass-specific state such as different default values than those set by this class.protected voidintersect(Line line, RigidShape.ShapeData shapeData, java.util.List<Intersection> intersections, int index)java.util.List<Intersection>intersect(Line line, Terrain terrain)Compute the intersections of a specified line with this shape.java.util.List<Intersection>intersect(Line line, Terrain terrain, int index)java.util.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 booleanisOrderedRenderableValid(DrawContext dc)Determines whether this shape's ordered renderable state is valid and can be rendered.protected booleanisSameAsPreviousTerrain(Terrain terrain)protected abstract voidmakeGeometry(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.voidmoveTo(Position position)Move the Rigid Shape to the specified destination.protected booleanmustApplyTexture(int index)protected booleanmustApplyTexture(DrawContext dc)Indicates whether texture should be applied to this shape.protected booleanmustRegenerateGeometry(DrawContext dc)Indicates whether this shape's renderable geometry must be recomputed, either as a result of an attribute or property change or the expiration of the geometry regeneration interval.protected voidreset()Invalidates computed values.voidrestoreState(java.lang.String stateInXml)Restores the object's state to what is described in the specified XML document string.voidsetCenterPosition(Position centerPosition)Specifies this shape's center position.voidsetDetailHint(double detailHint)Modifies the relationship of the shape's tessellation resolution to its distance from the eye.voidsetEastWestRadius(double eastWestRadius)Specifies this shape's radius in meters in the east-west (longitudinal) direction.protected voidsetFaceCount(int faces)Sets the number of separate faces that comprise this shape.voidsetHeading(Angle heading)Specifies this shape's azimuth, its rotation about its vertical axis.voidsetImageSource(int index, java.lang.Object imageSource)Specifies the image source for this shape's #index optional texture.voidsetImageSources(java.lang.Iterable imageSources)Specifies the image sources for this shape's optional textures.voidsetImageSources(java.lang.Object imageSource)Specifies the single image source for this shape's optional texture, to be placed on every face.protected voidsetModelViewMatrix(DrawContext dc)Called during drawing to set the modelview matrix to apply the correct position, scale and orientation for this shape.voidsetNorthSouthRadius(double northSouthRadius)Specifies this shape's radius in meters in the north-south (latitudinal) direction.voidsetOffset(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.voidsetRoll(Angle roll)Specifies this shape's roll, its rotation about its north-south axis.voidsetSkewEastWest(Angle skew)Specifies this shape's skew, its shearing along its east-west axis.voidsetSkewNorthSouth(Angle skew)Specifies this shape's skew, its shearing along its north-south axis.protected voidsetTexture(int index, WWTexture texture)Establishes the texture for this piece of the shape's geometry.voidsetTilt(Angle tilt)Specifies this shape's pitch, its rotation about its east-west axis.protected voidsetUpGeometryCache()Create the geometry cache supporting the Level of Detail system.voidsetVerticalRadius(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, computePoint, countTriangleVertices, createPickedObject, createSurfaceShape, determineActiveAttributes, doDrag, doDrawOrderedRenderable, doExportAsKML, drag, drawBatched, drawInterior, drawOrderedRenderable, drawOutline, endDrawing, export, exportAsKML, getActiveAttributes, getAltitudeMode, getAttributes, getCurrentData, getDelegateOwner, getDistanceFromEye, getExtent, getGeometryRegenerationInterval, getHighlightAttributes, getOutlinePickWidth, getReferencePoint, getVboIds, intersectsFrustum, isDragEnabled, isEnableBatchPicking, isEnableBatchRendering, isEnableDepthOffset, isExportFormatSupported, isHighlighted, isTerrainDependent, isViewDistanceExpiration, isVisible, makeOrderedRenderable, makeTexture, move, moveTo, mustApplyLighting, mustApplyLighting, mustCreateNormals, mustCreateNormals, mustDrawInterior, mustDrawOutline, pick, prepareToDrawInterior, prepareToDrawOutline, preRender, render, setAltitudeMode, setAttributes, setDelegateOwner, setDragEnabled, setEnableBatchPicking, setEnableBatchRendering, setEnableDepthOffset, setGeometryRegenerationInterval, setHighlightAttributes, setHighlighted, setOutlinePickWidth, setReferencePosition, setViewDistanceExpiration, setVisible, shouldUseVBOs, updateSurfaceShape
-
Methods inherited from class gov.nasa.worldwind.WWObjectImpl
onMessage, propertyChange
-
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gov.nasa.worldwind.avlist.AVList
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getEntries, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
-
-
-
-
Field Detail
-
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
-
geometryBuilder
protected GeometryBuilder geometryBuilder
-
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
TheWWTexturecreated 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.
-
-
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:AbstractShapeInvalidates computed values. Called when this shape's contents or certain attributes change.- Overrides:
resetin classAbstractShape
-
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 aFile, file path, a stream, a URL or aBufferedImage.
-
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 beFile, file path, a stream, a URL or aBufferedImage.
-
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 aFile, file path, a stream, a URL or aBufferedImage.
-
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 pairoffsetIndex- 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 offsetsoffsetIndex- the index of the particular texture coordinate we would like to set offsets foruOffset- the offset in the u directionvOffset- 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:AbstractShapeCalled during construction to establish any subclass-specific state such as different default values than those set by this class.- Specified by:
initializein classAbstractShape
-
getDetailHint
public double getDetailHint()
Indicates the shape's detail hint, which is described insetDetailHint(double).- Returns:
- the detail hint
- See Also:
setDetailHint(double)
-
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.
-
createCacheEntry
protected AbstractShape.AbstractShapeData createCacheEntry(DrawContext dc)
Description copied from class:AbstractShapeCreates and returns a new cache entry specific to the subclass.- Specified by:
createCacheEntryin classAbstractShape- Parameters:
dc- the current draw context.- Returns:
- a data cache entry for the state in the specified draw context.
-
mustApplyTexture
protected boolean mustApplyTexture(DrawContext dc)
Description copied from class:AbstractShapeIndicates whether texture should be applied to this shape. Called during rendering to determine whether texture state should be established during preparation for interior drawing.Note: This method always returns false during the pick pass.
- Specified by:
mustApplyTexturein classAbstractShape- Parameters:
dc- the current draw context- Returns:
- true if texture should be applied, otherwise false.
-
mustApplyTexture
protected boolean mustApplyTexture(int index)
-
mustRegenerateGeometry
protected boolean mustRegenerateGeometry(DrawContext dc)
Description copied from class:AbstractShapeIndicates whether this shape's renderable geometry must be recomputed, either as a result of an attribute or property change or the expiration of the geometry regeneration interval.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Overrides:
mustRegenerateGeometryin classAbstractShape- Parameters:
dc- the current draw context.- Returns:
- true if this shape's geometry must be regenerated, otherwise false.
-
doMakeOrderedRenderable
protected boolean doMakeOrderedRenderable(DrawContext dc)
Description copied from class:AbstractShapeProduces the geometry and other state necessary to represent this shape as an ordered renderable. Places this shape on the draw context's ordered renderable list for subsequent rendering. This method is called duringAbstractShape.pick(DrawContext, java.awt.Point)andAbstractShape.render(DrawContext)when it's been determined that the shape is likely to be visible.- Specified by:
doMakeOrderedRenderablein classAbstractShape- Parameters:
dc- the current draw context.- Returns:
- true if the ordered renderable state was successfully computed, otherwise false, in which case the current pick or render pass is terminated for this shape. Subclasses should return false if it is not possible to create the ordered renderable state.
- See Also:
AbstractShape.pick(DrawContext, java.awt.Point),AbstractShape.render(DrawContext)
-
isOrderedRenderableValid
protected boolean isOrderedRenderableValid(DrawContext dc)
Description copied from class:AbstractShapeDetermines whether this shape's ordered renderable state is valid and can be rendered. Called byAbstractShape.makeOrderedRenderable(DrawContext)just prior to adding the shape to the ordered renderable list.- Specified by:
isOrderedRenderableValidin classAbstractShape- Parameters:
dc- the current draw context.- Returns:
- true if this shape is ready to be rendered as an ordered renderable.
-
beginDrawing
protected OGLStackHandler beginDrawing(DrawContext dc, int attrMask)
Description copied from class:AbstractShapeEstablish the OpenGL state needed to draw this shape.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Overrides:
beginDrawingin classAbstractShape- Parameters:
dc- the current draw context.attrMask- an attribute mask indicating state the caller will set. This base class implementation setsGL_CURRENT_BIT, GL_LINE_BIT, GL_HINT_BIT, GL_POLYGON_BIT, GL_COLOR_BUFFER_BIT, and GL_TRANSFORM_BIT.- Returns:
- the stack handler used to set the OpenGL state. Callers should use this to set additional state, especially state indicated in the attribute mask argument.
-
doDrawOutline
protected void doDrawOutline(DrawContext dc)
Description copied from class:AbstractShapeDraws this shape's outline. Called immediately after callingAbstractShape.prepareToDrawOutline(DrawContext, ShapeAttributes, ShapeAttributes), which establishes OpenGL state for lighting, blending, pick color and line attributes. Subclasses should execute the drawing commands specific to the type of shape.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Specified by:
doDrawOutlinein classAbstractShape- Parameters:
dc- the current draw context.
-
doDrawInterior
protected void doDrawInterior(DrawContext dc)
Description copied from class:AbstractShapeDraws this shape's interior. Called immediately after callingAbstractShape.prepareToDrawInterior(DrawContext, ShapeAttributes, ShapeAttributes), which establishes OpenGL state for lighting, blending, pick color and interior attributes. Subclasses should execute the drawing commands specific to the type of shape.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Specified by:
doDrawInteriorin classAbstractShape- Parameters:
dc- the current draw context.
-
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:
getExtentin interfaceExtentHolder- Overrides:
getExtentin classAbstractShape- Parameters:
globe- the current globeverticalExaggeration- 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 transformnumVertices- 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 globeverticalExaggeration- 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 globeverticalExaggeration- 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 globeverticalExaggeration- 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.
-
getGeometryBuilder
protected GeometryBuilder getGeometryBuilder()
-
drawGeometry
protected void drawGeometry(DrawContext dc, RigidShape.ShapeData shapeData, int index)
Renders the Rigid Shape- Parameters:
dc- the current draw contextshapeData- the current shape dataindex- 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 contextmode- the render modecount- the number of elements to be drawntype- the data type of the elements to be drawnelementBuffer- the buffer containing the list of elements to be drawnshapeData- this shape's current globe-specific shape dataindex- 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.AbstractShapeDatamust 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.
-
clearCachedVbos
protected void clearCachedVbos(DrawContext dc)
Removes from the GPU resource cache the entry for the current data cache entry's VBOs.A
AbstractShape.AbstractShapeDatamust be current when this method is called.- Overrides:
clearCachedVbosin classAbstractShape- Parameters:
dc- the current draw context.
-
fillVBO
protected void fillVBO(DrawContext dc)
Fill this shape's vertex buffer objects. If the vertex buffer object resource IDs don't yet exist, create them.- Specified by:
fillVBOin classAbstractShape- Parameters:
dc- the current draw context.
-
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 thanWorldWind.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:
intersectin classAbstractShape- Parameters:
line- the line to intersect.terrain- theTerrainto 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
-
createIntersectionGeometry
protected abstract RigidShape.ShapeData createIntersectionGeometry(Terrain terrain)
-
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 intersectionsrenderMatrix- 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:RestorableReturns an XML document string describing the object's state. This state can be restored later by callingrestoreStateand passing the XML document.- Specified by:
getRestorableStatein interfaceRestorable- Overrides:
getRestorableStatein classAbstractShape- Returns:
- an XML document string describing the object's state.
-
doGetRestorableState
protected void doGetRestorableState(RestorableSupport rs, RestorableSupport.StateObject context)
- Overrides:
doGetRestorableStatein classAbstractShape
-
restoreState
public void restoreState(java.lang.String stateInXml)
Description copied from interface:RestorableRestores the object's state to what is described in the specified XML document string.- Specified by:
restoreStatein interfaceRestorable- Overrides:
restoreStatein classAbstractShape- Parameters:
stateInXml- an XML document string describing an object's state.
-
doRestoreState
protected void doRestoreState(RestorableSupport rs, RestorableSupport.StateObject context)
- Overrides:
doRestoreStatein classAbstractShape
-
-