Game Development Reference
In-Depth Information
One very common mistake made by COLLADA importers and exporters is to
rely on the name attribute of elements rather than on the id attribute. This is
because a lot of applications are internally using a name as the unique identifier for
an object, but COLLADA does not attach any convention to the name attribute;
the name is optional and contains human-readable information, whereas the id is
the only attribute that is guaranteed to be unique within a document, and used
to reference an element from another element. In COLLADA the name attribute
should be considered as additional metadata that can be attached to an element.
Although the specification provides the <extra> child element to add additional
information, most implementations do not understand or carry over the information
stored in the <extra> element. It turns out that most applications load and save
back the string stored in the name attribute, so several implementations have been
done using this container to carry special information between components of their
content pipeline.
For example, Crytek is using the name to carry engine-specific data between the
modeler and the engine [Crytex 10], which will be used as a parameter to how the
COLLADA content should be consumed by the engine. For example the name
CryExportNode_example-CGF-example-DoExport-MergeNodes carries the infor-
mation that this node is a static geometry (CGF), and can be merged (simpli-
fied hierarchy) by the loader. Other parameters such as level of detail (LOD), and
physics parameters are transported in the name as described in the XSI CryEngine2
documentation.
This example is a practical use of name and demonstrates the difference between
id and name in COLLADA, but it is a bit of an extreme usage—using name does not
provide the capability of correctly defining and exposing extension to COLLADA.
It is recommended instead to use the built-in concept of <extra> elements and to
use the published extension repository to document extensions so that other tool
vendors or COLLADA users can take advantage of those extensions. It is also
recommended to check the already published extensions before creating your own:
https://collada.org/mediawiki/index.php/Portal:Extensions directory
9.8 XPath
The XML Path Language (XPath) is a query language for selecting nodes from an
XML document. In addition, XPath may be used to compute values (e.g., strings,
numbers, or Boolean values) from the content of an XML document. An easy-to-
follow tutorial is provided on the web by W3Schools [W3Schools 11a]. There is a
large choice of implementations available. One common usage of XPath is to use
it as a query mechanism for XML databases [Bourret 11]. Using a database to
store COLLADA documents is a powerful idea, one that can be used as a mech-
anism for content repository and collaborative development, version management
and archival. Using XPath, a simple query can be sent to a database or used
Search WWH ::




Custom Search