Class AbstractGeneralShape

  • All Implemented Interfaces:
    AVList, Draggable, MessageListener, Exportable, ExtentHolder, Movable, Movable2, Attributable, GeographicExtent, Highlightable, OrderedRenderable, PreRenderable, Renderable, Restorable, WWObject, java.beans.PropertyChangeListener, java.util.EventListener
    Direct Known Subclasses:
    ColladaMeshShape

    public abstract class AbstractGeneralShape
    extends AbstractShape
    A shape that is positioned and oriented independently of its defining geometry. This shape typically represents 3D models imported from COLLADA and other 3D file formats. The model's geometry is defined in its own coordinate system; properties of this shape place and orient the model geographically. Specific model types subclass this class to provide their implementation and any additional properties.

    This class also accepts a resource map to independently link resources named in the model definition (the defining model file) to actual resources. Each map entry's key is a resource name as expressed in the model definition. Each map entry's value is the reference to the actual resource. The reference is interpreted by rules specific to the model format, but typically may be a relative or absolute file reference or a URL to a local or remote resource. If the map or an entry referred to by the model definition is not defined, resource references are typically considered relative to the location of the model definition's location.

    In the case of a COLLADA file referenced from a KML file, relative references are considered relative to the location of the KML file. If the file is KMZ, relative references are considered references to resources within the KMZ archive.

    This class applies ShapeAttributes to the shape, but the effect of some of those attributes, such as ShapeAttributes.isDrawOutline() is dependent on the specific implementation of this AbstractGeneralShape. See the class description of those shapes to determine how shape attributes are applied.

    • Field Detail

      • modelPosition

        protected Position modelPosition
        This shape's geographic location. The altitude is relative to this shapes altitude mode.
      • heading

        protected Angle heading
        This shape's heading, positive values are clockwise from north. Null is an allowed value.
      • pitch

        protected Angle pitch
        This shape's pitch (often called tilt), its rotation about the model's X axis. Positive values are clockwise. Null is an allowed value.
      • roll

        protected Angle roll
        This shape's roll, its rotation about the model's Y axis. Positive values are clockwise. Null is an allowed Value.
      • modelScale

        protected Vec4 modelScale
        A scale to apply to the model. Null is an allowed value.
      • resourceMap

        protected java.util.Map<java.lang.String,​java.lang.Object> resourceMap
        A map indicating the actual location of resources named in the model. Null is an allowed value.
    • Constructor Detail

      • AbstractGeneralShape

        public AbstractGeneralShape()
        Constructs a shape at 0 latitude, longitude and altitude. Because the shape's default altitude mode is ABSOLUTE, the default altitude is relative to mean sea level.
    • Method Detail

      • getCurrent

        protected AbstractGeneralShape.ShapeData getCurrent()
        Returns the current shape data cache entry.
        Returns:
        the current data cache entry.
      • 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
      • getResourceMap

        public java.util.Map<java.lang.String,​java.lang.Object> getResourceMap()
        Returns this shape's resource map.
        Returns:
        this shape's resource map, or null if this shape has no resource map.
      • setResourceMap

        public void setResourceMap​(java.util.Map<java.lang.String,​java.lang.Object> resourceMap)
        Specifies this shape's resource map. The resource map is described above in this class' description.
        Parameters:
        resourceMap - the resource map for this shape. May be null, in which case no resource map is used.
      • getModelPosition

        public Position getModelPosition()
        Indicates this shape's geographic position.
        Returns:
        this shape's geographic position. The position's altitude is relative to this shape's altitude mode.
      • setModelPosition

        public void setModelPosition​(Position modelPosition)
        Specifies this shape's geographic position. The position's altitude is relative to this shape's altitude mode.
        Parameters:
        modelPosition - this shape's geographic position.
        Throws:
        java.lang.IllegalArgumentException - if the position is null.
      • getModelScale

        public Vec4 getModelScale()
        Indicates this shape's scale, if any.
        Returns:
        this shape's scale, or null if no scale has been specified.
      • setModelScale

        public void setModelScale​(Vec4 modelScale)
        Specifies this shape's scale. The scale is applied to the shape's model definition in the model's coordinate system prior to oriented and positioning the model.
        Parameters:
        modelScale - this shape's scale. May be null, in which case no scaling is applied.
      • getHeading

        public Angle getHeading()
        Indicates this shape's heading, its rotation clockwise from north.
        Returns:
        this shape's heading, or null if no heading has been specified.
      • setHeading

        public void setHeading​(Angle heading)
        Specifies this shape's heading, its rotation clockwise from north.
        Parameters:
        heading - this shape's heading. May be null.
      • getPitch

        public Angle getPitch()
        Indicates this shape's pitch -- often referred to as tilt -- the angle to rotate this shape's model about its X axis.
        Returns:
        this shape's pitch, or null if no pitch has been specified. Positive values are clockwise as observed looking along the model's X axis toward the model's origin.
      • setPitch

        public void setPitch​(Angle pitch)
        Specifies this shape's pitch -- often referred to as tilt -- the angle to rotate this shape's model about its X axis.
        Parameters:
        pitch - this shape's pitch. Positive values are clockwise as observed looking along the model's X axis toward the model's origin. May be null.
      • getRoll

        public Angle getRoll()
        Indicates this shape's roll, the angle to rotate this shape's model about its Y axis.
        Returns:
        this shape's roll, or null if no roll has been specified. Positive values are clockwise as observed looking along the model's Y axis toward the origin.
      • setRoll

        public void setRoll​(Angle roll)
        Specifies this shape's roll, the angle to rotate this shape's model about its Y axis.
        Parameters:
        roll - this shape's roll. May be null. Positive values are clockwise as observed looking along the model's Y axis toward the origin.
      • getReferencePosition

        public Position getReferencePosition()
        Description copied from interface: Movable
        A position associated with the object that indicates its aggregate geographic position. The chosen position varies among implementers of this interface. For objects defined by a list of positions, the reference position is typically the first position in the list. For symmetric objects the reference position is often the center of the object. In many cases the object's reference position may be explicitly specified by the application.
        Returns:
        the object's reference position, or null if no reference position is available.
      • computeReferencePoint

        protected Vec4 computeReferencePoint​(Terrain terrain)
      • computeEyeDistance

        protected double computeEyeDistance​(DrawContext dc,
                                            AbstractGeneralShape.ShapeData shapeData)
        Computes the minimum distance between this shape and the eye point.

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

        Parameters:
        dc - the current draw context.
        shapeData - the current shape data for this shape.
        Returns:
        the minimum distance from the shape to the eye point.
      • moveTo

        public void moveTo​(Position position)
        Description copied from interface: Movable
        Move the shape over the globe's surface while maintaining its original azimuth, its orientation relative to North.
        Parameters:
        position - the new position of the shape's reference position.
      • doExportAsKML

        protected void doExportAsKML​(javax.xml.stream.XMLStreamWriter xmlWriter)
                              throws java.io.IOException,
                                     javax.xml.stream.XMLStreamException
        Description copied from class: AbstractShape
        Exports shape-specific fields.
        Specified by:
        doExportAsKML in class AbstractShape
        Parameters:
        xmlWriter - the export writer to write to.
        Throws:
        java.io.IOException - if an IO error occurs while writing to the output destination.
        javax.xml.stream.XMLStreamException - if an exception occurs converting this shape's fields to XML.
      • getSector

        public Sector getSector()
        Returns the object's geographic extent. Not currently supported.
        Returns:
        the object's geographic extent.