Attention: open in a new window. PDFPrint


Using the COLLADA DOM libraries is straight forward, if you know, where to start. So I will give a little example, how to load a .dae-file and how to locate some information inside the dom tree. First of all, we have to include COLLADA into our C/C++ file using the following includes:

#include <dae.h>
#include <dom/domCOLLADA.h>

We extend our application by a little main method that loads a .dae-File. If you need a .dae-file



#include <dae.h>
#include <dom/domCOLLADA.h>
#include <vector>
#include <iostream>
int main(int argc, char** argv) {
 DAE* dae;
 daeElement* daeRoot;
 // open dae file
 dae = new DAE;
 daeRoot = dae->open("put filename here.dae");
 // get vector containing the geometry objects
 std::vector<domGeometry*> geometries
   = this->_dae->getDatabase()->typeLookup<domGeometry >();
 std::cout << "File contains " << geometries.size() << " geometry objects." << std::endl;

The code above loads a .dae-File and reads a vector containing all geometry objects of the .dae-file. The geometry objects contain the information of vertices, normals and texture-coordinates you would need to render the object. So this is a good point to start. Store example to DaeExample.cpp.

To be able to use COLLADA in our application, we have to make shure, that our compiler knows, where to find the includes. So we just add

-I/usr/include/colladadom -I/usr/include/colladadom/1.4

to our CFLAGS and

-lcollada14dom -lboost_filesystem

to our LDFLAGS.

No we should be able to compile it:

g++ -Wall -o DaeExample DaeExample.cpp -I/usr/include/colladadom -I/usr/include/colladadom/1.4 -lstd -lcollada14dom -lboost_filesystem

And you can execute the result by calling