Version 11 (modified by robert, 6 years ago)

--

Collada

The Collada specification documents, forums, wiki, model bank and more can be found at the Official Collada website.

Collada features

Collada features Supported by OSG plugin
Geometry Yes
VisualScene Yes
Materials Yes, profile_COMMON
Animations No
PhysicsScene No, OSG has no Physics support

How to build

The OSG Collada plugin depends on the Open Source Collada DOM library. The current version of the DOM is 2.2. It can build a library for Collada version 1.4 or Collada version 1.5 documents. Both a static and a dynamic library can be build. The osg Collada plugin has only been tested to work with the 1.4 variants of the library. The Collada DOM library itself depends on (a part of) Boost, libxml2, pcre, pcrecpp, minizip, zlib. Precompiled libraries for different platforms and compilers are included in the Collada DOM download from sourceforge.

In order to build the Collada OSG plugin CMake will try to find the DOM library by using the COLLADA_DIR environment variable. If CMake can not find it specify the COLLADA_DOM_ROOT and reconfigure. The precompiled dependencies used by the DOM will automatically be found and filled in. If only the static library is found CMake will use this and if only the dynamic library is found it will use that library. If both static and dynamic libraries are found it will by default pick the static library. If you switch on the advanced options in CMake you may overrule this setting by manually changing the COLLADA_USE_STATIC option.

Step by step example for Windows and Visual Studio 2005

  • Download collada-dom-2.2.zip from Sourceforge
  • Unzip it into <yourinstalldir>
  • For Visual Studio 2005 open <yourinstalldir>/dom/projects/vc8-1.4/dom.sln and do > Batch Build... > Select all > Build
  • Set the environment variable COLLADA_DIR to <yourinstalldir>
  • Open CMake > configure > adjust COLLADA_DOM_ROOT if not correct > configure > check other COLLADA_ variables > OK
  • Build OpenSceneGraph and the dae plugin
  • Running with a statically linked DOM > Make sure the libxml2.dll can be found
  • Running with a dynamically linked DOM > Make sure to libcollada14dom21xxx.dll can be found

Step by step example for Linux (likely similar strategy will work on other unices

  • Download collada-dom-2.2.zip from Sourceforge
  • Unzip it into <yourinstalldir>
  • cd <yourinstalldir>
  • make make os=linux project=minizip
  • sudo make os=linux project=dom -C dom/
  • sudo make install

Option strings for Collada reader

OSG plugins can be given optional string arguments to influence their behaviour. For the Collada reader one can specify the following option string:

StrictTransparency Process transparent and transparency settings according to a strict interpretation of the Collada specification.

Plugin data for the Collada reader

OSG plugins can be given optional data arguments to influence their behaviour or receive feedback. For the Collada reader one can specify the following PluginData fields

DAE A pointer to a previously allocated Collada DOM DAE object- this object will be used to read the dae file and can then be used to programmatically access the loaded DAE database.
DAE-DocumentURI A pointer to a std::string object - This string will be set to the URI of the loaded document on exit
DAE-AssetUnitName A pointer to a std::string object - This string will be set to the AssetUnitName from the Collada document
DAE-AssetUnitMeter A pointer to a float - This will be set to the AssetUnitMeter value from the Collada document
DAE-AssetUp_axis A pointer to a domUpAxisType - This will be set to the AssetUp_Axis from the Collada document

Option strings for Collada writer

OSG plugins can be given optional string arguments to influence their behaviour. For the Collada writer one can specify the following options strings:

polygon Use polygons instead of polylists for element
GoogleMode Write files suitable for use by Google products. (Invert interpretation of A_ONE transparency as Google earth does)
NoExtras Do not write any <extra> elements

Plugin data for the Collada writer

OSG plugins can be given optional data arguments to influence their behaviour or receive feedback. For the Collada writer one can specify the following PluginData fields

DAE A pointer to a previously allocated Collada DOM DAE object- this object will be used to write the dae file and can then be used to programmatically access the loaded DAE database.
DAE-DocumentURI A pointer to a std::string object - This string will be set to the URI of the loaded document on exit

Example Collada dae models

Of course you may also Google for data, but be aware that there are also a lot of invalid Collada files available on the web.

Collada data may be tested for corruption at three levels:

  1. Well-formedness; conform to the XML syntax rules. Most of the Collada XML data on the web will be well formed, because this is the easiest to catch by tools/parsers.
  2. Validity; conform to the semantic rules specified in the Collada XML schema.
  3. Coherency; all element referencing and validation not in the scope of an XML schema. Are all used materials/textures available? Do arrays contain correct data? etc.

To do this you can use the CoherencyTest command-line tool or Java based GUI-tool Collada Refinery

Developer info

A description of the Collada extensions for specific OpenSceneGraph functionality can be found at the OSG Collada extensions page on the Collada wiki.

TODO/Wishlist

  • Solve differences in drawables, DAE reader should place multiple collation elements into multiple primitivesets in a single geometry where possible (only when same material)
  • solve differences in matrices
  • Multitexture support
  • Skinned mesh and generic animations using osgAnimation
  • Profile_GLSL based on AMD's Collada OpenGL Effects Viewer
  • Handling more <extra> to more closely mimic the intended lighting
  • Add proper <asset> info