Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Writing with COLLADA-DOM?

  1. #11
    Senior Member Frequent Contributor
    Join Date
    Aug 2004
    Quote Originally Posted by Xenon
    Maybe it's just that the COLLADA-DOM project isn't mature to the point where the introductory documentation is there yet. I work on the OSG (OpenSceneGraph) project, and that was an issue we suffered for a long time -- great code, but beginners were lost without a lot of demos.
    That's a fair comparison. We are working to improve the DOM documentation and would appreciate any feedback you can offer on that.

    Btw: we are looking to revive the COLLADA plugin for OSG as well!

  2. #12
    Member Newbie
    Join Date
    Dec 2004
    SCEA, Foster City
    It would be good to have some small introduction and a basic sample that imports a textured cube or triangle, for both FCollada and COLLADA-DOM.

    Both COLLADA-DOM and FCollada are quite complex indeed. I've experimented with both to get basic collision shape import, and especially the DOM is unintuitive, even if you know the COLLADA 1.4 specification... FCollada appeared a bit easier to use, but at that time (over a month ago) it didn't support writing yet, and convex meshes were broken. Both might be fixed now.

    COLLADA-RT includes a very basic viewer based on COLLADA-DOM. The FeelingViewer, which imports COLLADA 1.4 using FCollada, is unfortunately closed source, unless you become Khronos member. So if you want to go the FCollada route, that might be an option (including Feeling Software consultancy). In case you become interested in importing COLLADA 1.4 collision/physics data, you can learn from my import struggle in the open source Bullet physics engine. It includes a basic and preliminary import sample (supporting either COLLADA-DOM or FCollada).

    Download from
    In particular check for Demos/ColladaDemo/ColladaDemo.cpp


  3. #13
    Member Contributor
    Join Date
    Jul 2006
    I think the key point to understanding COLLADA for import or export is that there is a lot of indirection going on. This is pretty much essential for making a format that's flexible enough for anyone, but it does make the learinig curve pretty steep. Once you understand how the indirections go together, the whole thing becomes much easier. Some of this you can get from the spec, other things become clearer when you follow the id links in a sample file and see how they connect together. Starting from a primitive (<triangles>) or a <node> and working your way back is a good way to see all the links.

    I'd advise against doing import/export with printf/scanf, this may look easier at first but in the end you will have to do a lot more work to insure things are read/written in the proper order and format. Resolving all the forward/backward references by hand can be quite a job. Either FCollada or the COLLADA DOM will take care of this for you, resolving most indirections and converting most data to/from binary formats.

    I'm looking into what code I have that might be useful as samples, but it may take some time to get it cleaned up, approved and posted.

  4. #14
    Junior Member Newbie
    Join Date
    Aug 2007

    Sample code?

    In the year since this was last posted to, has anyone developed some demo code for either FCollada or COLLADA DOM? I'd really love to see some sample code that does nothing more than imports the sample duck.dae. I'm intrigued by Collada, but that's where I should say my interest ends. I would like to use it, but if there isn't any sample code out there to learn from, it makes more sense for me to continue using more standard formats. And I should say, I am not in any way looking for more documentation on the schema -- I have had my fill of that. I am trying to find a simple example of using either of the two parsers to read and write something simple (like a sphere, cube or the duck). I should also say that I am not looking for a massive project (e.g. somebody's thesis) that can import/export something like duck.dae; but rather, something that is very lightweight that can be used to learn from.

  5. #15
    Senior Member Regular Contributor
    Join Date
    Jul 2004
    Santa Clara
    You can find a tutorial / User guide on collada-DOM in the tutorials, from the front page.
    Loading a .dae document in the COLLADA-DOM is only a few lines of code, documented in the Working with documents tutorial page.
    I hope this helps

  6. #16
    Junior Member Newbie
    Join Date
    Aug 2007
    Thanks, Remi. Maybe I should have been more specific. I am looking for a tutorial on how to get information out of that object once it has been loaded.

    So for instance, I am looking for sample code that shows you (and walks you through) how to do things like accessing a material's ambient values. (Note that for simplicity's sake, in my example below, I have removed all error checking.)

    DAE* colladaDom = new DAE();


    int effectsCount = colladaDom->getDatabase()->getElementCount( \\

    for(int effectIndex = 0; effectIndex < effectsCount; effectIndex++)
    domEffect* effect;
    colladaDom->getDatabase()->getElement((daeElement**)&effect, \\

    / Or if you already have the material:
    / domEffect* effect = daeSafeCast< domEffect > \\
    / (getElementFromURI(material->getInstance_effect()->getUrl()));

    for( arrayIndex = 0; arrayIndex < \\
    effect->getFx_profile_abstract_array().getCount; arrayIndex++) {

    domProfile_COMMON* commonProfile = daeSafeCast \\
    <domProfile_COMMON > \\

    domProfile_COMMON::domTechnique::domBlinn* blinn = \\

    domFloat4 &colorValues = blinn->getAmbient->getColor->getValue();
    float ambient[4] = { colorValues[0], colorValues[1], \\
    colorValues[2], colorValues[3] };
    std::cerr << "ambientValues: " << colorValues[0] << "," << \\
    colorValues[1] << "," << colorValues[2] << "," << \\
    colorValues[3] << std::endl;

    Granted the code above is somewhat pointless as it just iterates through all of the materials and effects, then just prints out the ambient values, and it does not even check to see if any of these objects are there before it performs method calls on them. But for a beginner, I know I would really benefit from seeing simple examples like this for extracting information out of COLLADA DOM. It is especially difficult to know if there are preferred ways to do things like this.

    If you do know of any resources like that, I would really appreciate it. Thanks again for the quick response.

  7. #17
    Is there some sample source anywhere that shows FCollada being used to write something like a cube, start to finish?
    There is now some example of how to load some dae files. But how to write them ? Is there some sample source available ?

    When writing, does the Dom or FCollada API take care of everything to generate the xml file ?

    If yes, does someone know how to 'attach' an integer array to each vertex of a mesh (when the mesh is loaded) ?

    Thanks a lot for this forum , it helps a lot for learning Collada

  8. #18
    Senior Member Frequent Contributor
    Join Date
    Jan 2006
    Foster City, CA
    Quote Originally Posted by Mat_
    There is now some example of how to load some dae files. But how to write them ? Is there some sample source available ?
    There's sample code for creating documents with the DOM here.
    Quote Originally Posted by Mat_
    When writing, does the Dom or FCollada API take care of everything to generate the xml file ?
    I don't know how FCollada works, but with the DOM you use a C++ object model to create the elements/attributes you want, then you call a save function to serialize everything to an xml file.
    Quote Originally Posted by Mat_
    If yes, does someone know how to 'attach' an integer array to each vertex of a mesh (when the mesh is loaded) ?
    <mesh> allows for <extra> elements, so you could put your custom integer array in an <extra> element you create in the <mesh>. Documentation for working with custom data in the DOM is available here.

  9. #19
    Thank u very much sthomas !
    I'm gonna read the concept of the domAny class to store extra custom data

    I found a very very good sample file of "how to create a cube from scratch" and exporting it as dae. All made with Collada Dom. I post the information here cause it can interests some people.

    When u download & Install Collada Dom
    Go To ColladaDomPath\samples\export

    There is a source code explaining step by step how to create and export a cube. We can open the Visual Studio project at the same location to run it. (After Setting up the compiler like explained it the Programming guide)
    There is a lot of comments in the source code, but still not enough for me But i'm not dead yet ^^ I'll try again & again to work with the dom

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 4
    Last Post: 02-21-2011, 09:15 PM
  2. Replies: 1
    Last Post: 11-10-2010, 03:00 AM
  3. KML, COLLADA, Goolge Earth: using spline tag in COLLADA
    By imported_sphere in forum COLLADA
    Replies: 1
    Last Post: 01-04-2010, 12:50 PM
  4. Replies: 1
    Last Post: 11-02-2005, 02:18 AM
  5. writing to buffer WITHOUT writing to screen
    By mrshirts in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 10-01-2000, 02:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean