利用者:Chingachgook/Gsoc2009/About the COLLADA Module

提供: wiki
移動先: 案内検索

About the COLLADA module

OPENCOLLADA

Erwin Coumans recommended to use this library because NextGen were sponsored by Sony to develop OpenCollada.

OpenCollada differs from a regular DOM in that it writes/reads data "on the fly".

This is done for memory and speed efficiency.

OpenCollada depends on two libraries: pcre (217K on linux) and expat (202K).

EXPORT

File is written just as new elements are added.

The following steps are repeated:

  • prepare element, or element hierarchy
  • write it

Collada allows multiple scene storage, this fits nicely with Blender database.

Currently the exporter writes active scene taken from context. It exports scene graph by looping through scene->base linked list. Only mesh objects are taken into account now, but other types like cameras, lights can be added later.

Inside scene graph, nodes link to geometry and material data by ids (XML referencing method). The geometry and material data is defined separately. For example geometries are stored in <library_geometries>.

IMPORT

Similar approach: "catch things on the fly".

Importer implements an interface which defines callbacks that are called by OpenCollada as it reads DAE.

Some callback examples:

  • writeGeometry - geometry data is passed
  • writeVisualScene - scene graph is passed
  • writeMaterial

These can be called by SAX parser in any order.

Each callback is passed a pointer to data which is OpenCollada frees once callback returns.

So what we're going to do here:

  • create a Mesh, fill it's geometry data and add it to Blender database in writeGeometry
  • create Objects in writeVisualScene. Here we get node info: parenting, transforms and data links (material, geometry)
  • link Object with Mesh in the "end" callback which is called when DAE reading finishes

Although it is possible to read DAE in two passes:

  • first pass: read scene graph info
  • second pass: read data (geometry, etc.) and link nodes to data

ColladaMaya importer does so, but for now doing this seems redundant.