public class ColladaRoot extends ColladaAbstractObject implements ColladaRenderable, Highlightable
gov.nasa.worldwind.ogc.collada
.Modifier and Type | Field and Description |
---|---|
protected int |
altitudeMode
This shape's altitude mode.
|
protected ColladaDoc |
colladaDoc
Reference to the ColladaDoc representing the COLLADA file.
|
protected XMLEventReader |
eventReader
The event reader used to parse the document's XML.
|
protected InputStream |
eventStream
The input stream underlying the event reader.
|
protected Angle |
heading
This shape's heading, positive values are clockwise from north.
|
protected boolean |
highlighted
Indicates whether or not the COLLADA model is highlighted.
|
protected Matrix |
matrix
Transform matrix computed from the document's scale and orientation.
|
protected Vec4 |
modelScale
A scale to apply to the model.
|
protected ColladaParserContext |
parserContext
The parser context for the document.
|
protected Angle |
pitch
This shape's pitch (often called tilt), its rotation about the model's X axis.
|
protected Position |
position
This shape's geographic location.
|
protected ColladaResourceResolver |
resourceResolver
Resource resolver to resolve relative file paths.
|
protected Angle |
roll
This shape's roll, its rotation about the model's Y axis.
|
protected double |
scale
Scale applied to the model.
|
protected boolean |
scaleFetched
Flag to indicate that the scale has been computed.
|
protected ColladaScene |
scene
Cached COLLADA scene.
|
protected boolean |
sceneFetched
Flag to indicate that the scene has been retrieved from the hash map.
|
CHARACTERS_CONTENT, fields, namespaceURI, parent
Constructor and Description |
---|
ColladaRoot(ColladaDoc docSource)
Create a new
ColladaRoot for a ColladaDoc instance. |
ColladaRoot(File docSource)
Create a new
ColladaRoot for a File . |
ColladaRoot(InputStream docSource)
Create a new
ColladaRoot for a InputStream . |
ColladaRoot(URL docSource)
Create a new
ColladaRoot for a URL . |
Modifier and Type | Method and Description |
---|---|
protected boolean |
canParseContentType(String mimeType)
Determines if a MIME type can be parsed as COLLADA.
|
protected void |
closeEventStream()
Closes the event stream associated with this context's XML event reader.
|
protected double |
computeScale()
Indicates the scale defined by the asset/unit element.
|
static ColladaRoot |
create(Object docSource)
Creates a Collada root for an untyped source.
|
static ColladaRoot |
createAndParse(Object docSource)
Creates and parses a Collada root for an untyped source.
|
protected ColladaParserContext |
createParserContext(XMLEventReader reader)
Invoked during
initialize() to create the parser context. |
protected XMLEventReader |
createReader(Object docSource)
Creates the event reader.
|
int |
getAltitudeMode()
Returns this shape's altitude mode.
|
ColladaAsset |
getAsset()
Indicates the asset field of this document.
|
protected ColladaDoc |
getColladaDoc()
Indicates the document that is the source of this root.
|
Angle |
getHeading()
Indicates this shape's heading, its rotation clockwise from north.
|
Object |
getItemByID(String id)
Finds a named element in the document.
|
Box |
getLocalExtent(ColladaTraversalContext tc)
Returns this renderable's model coordinate extent.
|
protected Matrix |
getMatrix()
Indicates the transform matrix applied to this document.
|
Vec4 |
getModelScale()
Indicates this shape's scale, if any.
|
protected XMLEventParserContext |
getParserContext()
Indicates the parser context used by this document.
|
Angle |
getPitch()
Indicates this shape's pitch -- often referred to as tilt -- the angle to rotate this shape's model about its X
axis.
|
Position |
getPosition()
Indicates this shape's geographic position.
|
ColladaResourceResolver |
getResourceResolver()
Indicates the resource resolver used to resolve relative file paths.
|
Angle |
getRoll()
Indicates this shape's roll, the angle to rotate this shape's model about its Y axis.
|
protected double |
getScale()
Indicates the scale factored applied to this document.
|
ColladaScene |
getScene()
Indicates the scene contained in this document.
|
String |
getSupportFilePath(String link)
Determines the path of a supporting file (such an image).
|
protected void |
initialize()
Called just before the constructor returns.
|
boolean |
isHighlighted()
Indicates whether to highlight the shape.
|
ColladaRoot |
parse(Object... args)
Starts document parsing.
|
protected ColladaRoot |
parseCachedColladaFile(URL url,
String linkBase)
Open and parse the specified file expressed as a file: URL..
|
void |
preRender(ColladaTraversalContext tc,
DrawContext dc)
Pre-Render this element.
|
void |
render(ColladaTraversalContext tc,
DrawContext dc)
Render this element.
|
protected void |
reset()
Clear cached values.
|
protected Object |
resolveLocalReference(String linkBase,
String linkRef)
Resolves a reference to a local element identified by address and identifier, where
linkBase identifies a
document, including the current document, and linkRef is the id of the desired element. |
Object |
resolveReference(String link)
Resolves a reference to a local or remote file or element.
|
Object |
resolveRemoteReference(String linkBase,
String linkRef)
Resolves a reference to a remote element identified by address and identifier, where
linkBase identifies
a remote document, and linkRef is the id of the desired element. |
void |
setAltitudeMode(int altitudeMode)
Specifies this shape's altitude mode, one of
WorldWind.ABSOLUTE , WorldWind.RELATIVE_TO_GROUND or
WorldWind.CLAMP_TO_GROUND . |
void |
setHeading(Angle heading)
Specifies this shape's heading, its rotation clockwise from north.
|
void |
setHighlighted(boolean highlighted)
Specifies whether to highlight the shape.
|
void |
setModelScale(Vec4 modelScale)
Specifies this shape's scale.
|
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.
|
void |
setPosition(Position position)
Specifies this shape's geographic position.
|
void |
setResourceResolver(ColladaResourceResolver resourceResolver)
Specifies a resource resolver to resolve relative file paths.
|
void |
setRoll(Angle roll)
Specifies this shape's roll, the angle to rotate this shape's model about its Y axis.
|
getRoot
allocate, doAddCharacters, doAddEventAttribute, doAddEventContent, doParseEventAttributes, doParseEventContent, freeResources, getAConstructor, getCharacters, getField, getField, getFields, getNamespaceURI, getParent, hasField, hasField, hasFields, mergeFields, newInstance, overrideFields, parse, parseCharacterContent, removeField, setField, setField, setFields, setNamespaceURI, setParent
protected int altitudeMode
WorldWind.CLAMP_TO_GROUND
, WorldWind.RELATIVE_TO_GROUND
, or WorldWind.ABSOLUTE
.protected ColladaDoc colladaDoc
protected XMLEventReader eventReader
protected InputStream eventStream
protected Angle heading
protected boolean highlighted
protected Matrix matrix
protected Vec4 modelScale
protected ColladaParserContext parserContext
protected Angle pitch
protected Position position
protected ColladaResourceResolver resourceResolver
protected Angle roll
protected double scale
protected boolean scaleFetched
protected ColladaScene scene
protected boolean sceneFetched
public ColladaRoot(ColladaDoc docSource) throws IOException
ColladaRoot
for a ColladaDoc
instance. A ColladaDoc represents COLLADA files
from either files or input streams.docSource
- the ColladaDoc instance representing the COLLADA document.IllegalArgumentException
- if the document source is null.IOException
- if an error occurs while reading the COLLADA document.public ColladaRoot(File docSource) throws IOException
ColladaRoot
for a File
.docSource
- the File containing the document.IllegalArgumentException
- if the document source is null.IOException
- if an error occurs while reading the Collada document.public ColladaRoot(InputStream docSource) throws IOException
ColladaRoot
for a InputStream
.docSource
- the URL of the document.IllegalArgumentException
- if the document source is null.IOException
- if an error occurs while reading the Collada document.public ColladaRoot(URL docSource) throws IOException
ColladaRoot
for a URL
.docSource
- the URL of the document.IllegalArgumentException
- if the document source is null.IOException
- if an error occurs while reading the Collada document.protected boolean canParseContentType(String mimeType)
mimeType
- Type to test. May be null.true
if mimeType
can be parsed as COLLADA.protected void closeEventStream()
protected double computeScale()
public static ColladaRoot create(Object docSource) throws IOException
File
or a String
identifying either a file path or a URL
. Null is returned if the source type is not recognized.docSource
- either a File
or a String
identifying a file path or URL
.ColladaRoot
for the specified source, or null if the source type is not supported.IllegalArgumentException
- if the source is null.IOException
- if an error occurs while reading the source.public static ColladaRoot createAndParse(Object docSource) throws IOException, XMLStreamException
File
or a String
identifying either a file path or a URL
. Null is returned if the source type is not recognized.docSource
- either a File
or a String
identifying a file path or URL
.ColladaRoot
for the specified source, or null if the source type is not supported.IllegalArgumentException
- if the source is null.IOException
- if an error occurs while reading the source.XMLStreamException
protected ColladaParserContext createParserContext(XMLEventReader reader)
initialize()
to create the parser context. The parser context is created by the global
XMLEventParserContextFactory
.reader
- the reader to associate with the parser context.protected XMLEventReader createReader(Object docSource)
docSource
- the document source to create a reader for. The type can be any of those supported by WWXML.openEventReader(Object)
.public int getAltitudeMode()
setAltitudeMode(int)
public ColladaAsset getAsset()
protected ColladaDoc getColladaDoc()
public Angle getHeading()
public Object getItemByID(String id)
id
- the element's identifier. If null, null is returned.public Box getLocalExtent(ColladaTraversalContext tc)
ColladaAbstractObject
getLocalExtent
in interface ColladaRenderable
getLocalExtent
in class ColladaAbstractObject
tc
- The traversal context to use when determining the extent.protected Matrix getMatrix()
public Vec4 getModelScale()
protected XMLEventParserContext getParserContext()
public Angle getPitch()
public Position getPosition()
public ColladaResourceResolver getResourceResolver()
public Angle getRoll()
protected double getScale()
asset
/unit
element.public ColladaScene getScene()
public String getSupportFilePath(String link) throws IOException
link
- Relative path to resolve.IOException
- If an error occurs while attempting to resolve the resource.protected void initialize() throws IOException
super.initialize()
.IOException
- if an I/O error occurs attempting to open the document source.public boolean isHighlighted()
isHighlighted
in interface Highlightable
public ColladaRoot parse(Object... args) throws XMLStreamException
args
- optional arguments to pass to parsers of sub-elements.this
if parsing is successful, otherwise null.XMLStreamException
- if an exception occurs while attempting to read the event stream.protected ColladaRoot parseCachedColladaFile(URL url, String linkBase) throws IOException, XMLStreamException
url
- the URL of the file to open, expressed as a URL with a scheme of "file".linkBase
- the original address of the document if the file is a retrieved and cached file.ColladaRoot
representing the file's COLLADA contents.IOException
- if an I/O error occurs during opening and parsing.XMLStreamException
- if a server parsing error is encountered.public void preRender(ColladaTraversalContext tc, DrawContext dc)
preRender
in interface ColladaRenderable
tc
- the current COLLADA traversal context.dc
- the current draw context.public void render(ColladaTraversalContext tc, DrawContext dc)
render
in interface ColladaRenderable
tc
- the current COLLADA traversal context.dc
- the current draw context.protected void reset()
protected Object resolveLocalReference(String linkBase, String linkRef)
linkBase
identifies a
document, including the current document, and linkRef
is the id of the desired element.
If linkBase
refers to a local COLLADA file and linkRef
is non-null, the return value is the
element identified by linkRef
. If linkRef
is null, the return value is a parsed ColladaRoot
for the COLLADA file identified by linkBase
. Otherwise, linkBase
is returned.linkBase
- the address of the document containing the requested element.linkRef
- the element's identifier.IllegalArgumentException
- if the address is null.public Object resolveReference(String link)
link
- the address of the document or element to resolve. This may be a full URL, a URL fragment that
identifies an element in the current document ("#myElement"), or a URL and a fragment identifier
("http://server.com/model.dae#myElement").IllegalArgumentException
- if the address is null.public Object resolveRemoteReference(String linkBase, String linkRef)
linkBase
identifies
a remote document, and linkRef
is the id of the desired element. This method retrieves resources
asynchronously using the FileStore
.
The return value is null if the file is not yet available in the FileStore. If linkBase
refers to a
COLLADA file and linkRef
is non-null, the return value is the element identified by linkRef
. If
linkBase
refers to a COLLADA file and linkRef
is null, the return value is a parsed ColladaRoot
for the COLLADA file identified by linkBase
. Otherwise the return value is a URL
to
the file in the file cache.linkBase
- the address of the document containing the requested element.linkRef
- the element's identifier.IllegalArgumentException
- if the linkBase
is null.public void setAltitudeMode(int altitudeMode)
WorldWind.ABSOLUTE
, WorldWind.RELATIVE_TO_GROUND
or
WorldWind.CLAMP_TO_GROUND
.
Note: If the altitude mode is unrecognized, WorldWind.ABSOLUTE
is used.
Note: Subclasses may recognize additional altitude modes or may not recognize the ones described above.altitudeMode
- the altitude mode. The default value is WorldWind.ABSOLUTE
.public void setHeading(Angle heading)
heading
- this shape's heading. May be null.public void setHighlighted(boolean highlighted)
setHighlighted
in interface Highlightable
highlighted
- true to highlight the shape, otherwise false.public void setModelScale(Vec4 modelScale)
modelScale
- this shape's scale. May be null, in which case no scaling is applied.public void setPitch(Angle pitch)
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.public void setPosition(Position position)
position
- this shape's geographic position.IllegalArgumentException
- if the position is null.public void setResourceResolver(ColladaResourceResolver resourceResolver)
resourceResolver
- New resource resolver. May be null.public void setRoll(Angle roll)
roll
- this shape's roll. May be null. Positive values are clockwise as observed looking along the model's Y
axis toward the origin.