您的位置:首页 > 其它

COLLADA - 交互3D数字资产交换方案

2010-01-29 16:28 330 查看

COLLADA - 交互3D数字资产交换方案

    COLLADA™ 是面向交互式 3D 应用程序的基于 XML 的数字资产交换方案,使 3D 创作应用程序可以自由地交换数字资产而不损失信息 -
使多种DCC和3D处理软件包可以组合成强大的工具链管道。独特的交互模式提供了广泛全面的视觉编译。COLLADA FX支持使用 OpenGL
ES 着色语言创作和封装着色器,以使一流的 3D 创作工具可以有效协作创建 OpenGL / OpenGL ES 应用程序和资产。

    COLLADA is a COLLAborative Design Activity for establishing an open standard digital asset schema for interactive 3D applications.

DOM guide: Introduction

Overview:

The COLLADA DOM is a comprehensive framework for the development of
COLLADA applications. The DOM provides a C++ programming interface to
load, query, and translate COLLADA instance data. The DOM loads COLLADA
data into a runtime database consisting of structures that mirror those defined in the COLLADA schema.


XML Schema

    :一份XML schema文件描述了XML文档的结构。

COLLADA schema
    :The COLLADA schema is a W3C XML schema that defines valid COLLADA syntax for COLLADA instance documents. The content of the schema is described in the COLLADA Specification.

    :定义COLLADA文档的语法结构,规格说明。

COLLADA document
    :
A COLLADA document, short for COLLADA instance document, is an XML file that contains valid COLLADA content as defined in the COLLADA schema. The filename extension is usually .dae (for digital asset exchange), although it might also be .xml or a proprietary extension for COLLADA content from a specific application.
    :COLLADA文档,后缀一般为.dae,以为遵循XML规范,只是区别是COLLADA文档格式用于特定的应用程。

COLLADA DOM
    :The COLLADA Document Object Model (DOM) is an application programming interface (API) that provides a C++ object representation of a COLLADA XML instance document.

The COLLADA DOM framework includes these basic components:

DOM object model. Includes:
The digital asset exchange (DAE) object model, which is a reflective object system that allows easy creation, manipulation, reading, and writing of COLLADA elements.

The COLLADA object model, a custom C++ DOM based on the DAE object model and the COLLADA schema.

DOM runtime database. Manages COLLADA elements. A reference implementation is provided via the C++ standard library. Includes:
The C++ structures for specific instances of the COLLADA object model.

A mechanism for converting COLLADA object model elements to user-defined data structures.

A database query manager.

I/O plug-in: Components responsible for translating external COLLADA instance data into C++ runtime COLLADA objects.

These components are described in more detail in DOM guide: Architecture.

DOM guide: Architecture

    The COLLADA DOM architecture provides access to, and manipulation of, COLLADA documents.

Components:



Figure 1 - The COLLADA DOM
The key components are:


External instance data: The nonresident storage of COLLADA instance documents or databases.

COLLADA DOM:
I/O plug-in:
The components responsible for translating external COLLADA instance
data into C++ runtime COLLADA objects. The default plug-in uses the libxml2 library to intelligently parse and translate the XML instance data.

DAE interface:
Provides the means through which applications interact with the COLLADA
DOM. This interface provides document load and save functionality,
access to the runtime database, access to the object model, and registration of integration objects.

Object model: A set of C++ objects (COLLADA dom* objects) generated directly from the COLLADA schema. Each COLLADA dom* object derives from a specialized base class designed to provide reflectivity and robustness to the API. The generated object model is the basis of the runtime database, and is a C++ representation of the COLLADA schema elements.

Runtime database:
A resident, active cache of COLLADA elements. This cache is based on
C++ COLLADA elements handed to the cache by the COLLADA I/O plug-in.

Client application: The client application uses the COLLADA DOM
to interact with COLLADA documents. Perhaps the client is a game engine
that wants to load a COLLADA model for rendering in the game world. Or
the client could be a 3D model editing package that wants to write a
COLLADA model created by a user to a file.

DAE Interface:

The DAE class provides a simple, general-purpose interface to the
replaceable I/O plug-in and runtime database. This class serves as a
wrapper for the entire pipeline, ensuring a consistent interface
regardless of extensions to, or replacements for, the various DOM
components.The COLLADA DOM was designed to allow the underlying database mechanism
to be supplemented or replaced without affecting performance of the
rest of the API components. The included front-end interface hands off
generic queries through the API to any configured I/O plug-in. Query
results assembled by the I/O plug-in are handed back to the runtime
database for delivery in response to the original query. In addition,
the front-end interface itself could be extended to provide a more
robust or specific query feature set.

Object Model:

The COLLADA DOM is built upon a C++ object model that includes a
reflective object system (ROS) and an object model that corresponds
directly to the COLLADA XML schema definition.


Figure 2 - The COLLADA Object Model

Reflective Object System (ROS):

The COLLADA DOM is built upon a set of functionality that defines a
self-managed, reflective object system (ROS). The ROS creates, manages,
and manipulates DOM objects and the data that define their structure
(meta-data) and contents.

COLLADA Object Model:

The COLLADA object model is a C++ equivalent representation of the elements defined in the COLLADA schema.

Runtime Database:

At the heart of the COLLADA DOM is a runtime database, a resident cache
of COLLADA elements. The runtime database is implemented as a C++
object, daeDatabase, with a virtual interface. The runtime database
allows for simple requests of COLLADA objects by name, type, document,
or any combination of the three through the database interface.

Database Query Manager:

The COLLADA DOM does not include a query manager at this time, but it
warrants mention because the addition of this component may be a useful
extension to the runtime database. The COLLADA I/O plug-in is
essentially a wrapper providing access to a persistent data store.
While the provided mechanism uses local XML files, it is expected that
extensions for binary file formats as well as full database systems
will be implemented. An intelligent query manager in the runtime
database could cooperate with a particular plug-in data store to
optimize query and retrieval of data for a particular application. The
API has attempted to facilitate these extensions.

I/O Plug-In:

The COLLADA DOM I/O plug-in consists of an abstract class, daeIOPlugin,
with a virtual interface for reading and writing COLLADA to and from a
persistent data store. Included with the API is one implementation, daeLIBXMLPlugin, which uses the libxml2
library to provide fully standards-compliant XML document loading. It
is expected that other implementations of this interface would yield
I/O modules for other types of persistent data stores, for example,
binary files and database systems.

Integration Library:

The COLLADA integration library is a set of generated template classes
that exactly mirror the DOM objects. Every integration class is
prefixed with int. Each integration class derives from a base class, daeIntegrationObject,
which provides a virtual interface that defines the semantics for
translation of COLLADA data to application structures. Starting with
the COLLADA DOM integration library, developers need only define object
equivalence by filling in translation functions from one C++ structure
to another.

DOM guide: Integration templates

When you load a COLLADA XML instance document into the COLLADA DOM,
it creates a DOM object for each XML element in the COLLADA document.
An application can then use DOM methods to read and manipulate the DOM
objects. However, your application might already have its own data
structures designed to represent the data coming from COLLADA XML
elements and its own tools for manipulating those data structures. In
that case, you can implement the COLLADA DOM's integration templates,
which, when loading a COLLADA document, convert DOM objects into your
application's data structures, and back again when saving. The
integration templates cannot be used to create new COLLADA documents
based on your runtime data structures.

Overview:

The COLLADA Object Model is a set of runtime COLLADA DOM objects that correspond to elements in a COLLADA XML instance document (a COLLADA document).
For importing, the COLLADA DOM builds these objects when it parses a
COLLADA document. For exporting into a COLLADA document, you need to
provide code to build the appropriate DOM objects.
To convert data contained in COLLADA DOM objects into your own
application's data structures, the DOM provides integration templates
for every object. The integration templates include plug-in points
where you can insert conversion code (otherwise, the templates do
nothing). After a COLLADA document has been imported by the DOM into
COLLADA DOM objects, the DOM calls your conversion code to convert
between the DOM objects and the application's data structures.


This figure shows what happens during a load when integration templates are used.The basic steps during integration are the following:

Application initializes the COLLADA DOM by creating a DAE object.

Application registers its application-specific integration libraries.

When importing a COLLADA document:
Application begins the import by calling load.

The DOM reads the COLLADA document and places its elements into runtime COLLADA DOM objects.

The COLLADA runtime calls the conversion methods in the
integration libraries to convert the content of COLLADA DOM objects
into their associated data structures.

When exporting to a COLLADA document:
Application begins the export of a COLLADA DAE structure by calling save.

The COLLADA runtime calls registered conversion methods in the
integration libraries to convert the content of the application's data
structures into COLLADA DOM objects.

The DOM exports the COLLADA document.

COLLADA DOM Integration Templates:

Integration templates are used to convert DOM objects to your run-time
data structures. Each DOM object has its own integration template
consisting of a header (.h) file and a code (.cpp) file. For example,
the DOM object for the COLLADA element is domNode, and the template files to convert domNode objects to or from application data structures are intNode.cpp and intNode.h.

Copy into your application directory the template files for the
elements that you want to convert from DOM objects into
application-specific data structures. These copies are the starting
points for your customized integration libraries. You can then add code
to these integration libraries to do the conversion.

The plug-in points for your code are identified in comments in the template source, which is available in the integrationTemplates folder.

Integration Objects:

Your integration library provides the code that defines an
integration object for each DOM object. The integration object serves
as the focal point for all information about the conversion. It defines
methods that perform the conversion, and it provides data members that
bind the DOM object with the application-specific data structure being
converted to.

Integration objects are represented with the daeIntegrationObject class. Every class derived from daeElement provides for an integration object through the data member daeElement::_intObject.

The integration object class for each element is defined with the prefix "int". For example, the domGeometry class provides an intGeometry integration object.

When you define integration code for a DOM object, your code
binds the DOM object with your application-specific object, via the _element and _object data members of the integration object. You can use methods daeIntegrationObject::getElement and getObject to access these data members.

When you load a COLLADA instance document, the DOM automatically creates the appropriate integration objects.

To get the integration object for an element, use the method daeElement::getIntObject, which also initiates the conversion process for any objects that have not yet been converted.

Integration Template Plugin Points:

The integration class for each DOM object provides six plug-in
points into which you can add conversion code. The plug-in points are
implemented as methods; you provide the code for the method bodies. You
need to implement the body of the methods only for those plug-in points
that are relevant to your application.

The methods are:

createFrom: Defines the code to create the
application-specific data structure associated with the DAE class for
this template. This method sets up the integration object for the DAE
class.

fromCOLLADA: Defines the code to covert a DOM object into your application-specific data structure.

fromCOLLADAPostProcess: Defines any post-processing code that must execute after the basic conversion to your data structure.

createTo: Defines code to create the DOM object
associated with the DAE class for this template if such a structure
does not already exist (for example, if it was not created while
importing).

toCOLLADA: Defines the code to covert the content of your application’s data structures into DOM objects.

toCOLLADAPostProcess: Defines any post-processing code that must execute after the basic conversion from your application’s data structure.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: