COLLADA loading for DirectX

Well I promised I would put it up in the next week or so, here it is! It’s been a long time coming, even though this blog is new I been writing this thing on and off for a while and finally bothered to finish it.

This is a complete tutorial for loading static, skinned and morphing meshes from COLLADA and rendering them correctly in DirectX. Full source code with example .dae files.

However due to a problem with the COLLADA exporter, morphing mesh data doesn’t get exported right and therefore cannot really be tested, the code for it is correct however as I double checked all results with the official COLLADA rendering example provided with the COLLADA DOM api. Hopefully they resolve the issues and the code becomes useful again!

To make up for this shortfall I will give a complete tutorial on morph target meshes for XNA, including skinning morph targets! Keep visiting this blog and you’ll see it shortly…

Anyways, here are the files you are interested in! The Source Code has specific projects for each chapter, with the COLLADADirectX project being an all-in-one solution to loading COLLADA meshes.

The Documentation

The Source Code

If you only care about using my COLLADALoader class and not learning COLLADA, just use the class from the COLLADADirectX project, the other projects are for specific chapters.

I think it’s fairly easy to follow, let me know what you think! =)

 

13 Responses to “COLLADA loading for DirectX”

  1. 8:43 am on October 5 2010, Andrew Olney said:

    An XNA morph tutorial would be cool. We’ve been using Horde3D for the past year and are thinking of switching to XNA, but the lack of morph support is a killer.

  2. 12:57 pm on October 5 2010, TheCansin said:

    The tutorial for it is almost complete, just making the documentation and testing it a bit as we speak… =D

  3. 12:44 am on October 10 2010, mumin16 said:

    Türkçesini yay?nlamak seni çok yormazsa, türkçesini isteriz…

  4. 7:44 pm on October 10 2010, TheCansin said:

    Türkçesini yay?nlamak seni çok yormazsa, türkçesini isteriz…

    benim türkce yeterince iyi de?il =(

  5. 8:16 pm on October 18 2010, Robert Wilson said:

    thanks for the post

  6. 12:26 pm on November 25 2010, TheCansin.com » Blog Archive » COLLADA loading for DirectX « BlueBerry said:

    [...] TheCansin.com » Blog Archive » COLLADA loading for DirectX. Previous Post« ???Direct3D?Collada??????????????: ? masafumi’s Diary Next Post [...]

  7. 2:46 am on December 27 2010, Vahid said:

    Cool thanks for sharing!

  8. 7:33 pm on February 18 2011, firstfancy said:

    I have a question.
    Every dae file has nodes “matrix” for view matrix, is that right? If a dae file do not have a matrix node or use another node name for view matrix(like collada DOM’s sample file ), how to handle this?

    And when using your sample code , nodes[i]->getDescendant(“matrix”); returns a null(I’m sure there is matrix nodes in the dae file), and the program crashed , What’s thhe problem?

  9. 2:40 am on February 20 2011, TheCansin said:

    Depends on the .dae file and what type the element is as to whether a matrix node will be under it. If you read Chapter 3 you’ll understand how to get any information you want from the file, so if the data is represented in a non-matrix form then simply get the various transformations eg.”Pre-Rotation”, “Post-Rotation” etc. and apply them in the correct order (specified by the exporter or whatever program it was exported from).
    The code wasn’t written for the Collada DOM’s samples as they aren’t unindexed and it requires strictly matrix based transformations, which is mostly what you will want/get from the Maya exporter used in combination with Refinery.
    As for the second question, which line in particular and what file was it parsing? You can find my contact information in the “About Me” section if you need individual help.
    The main point of the tutorial was understanding how to get information from a COLLADA file for the building of your own system catering to your specific needs and understanding the general form in which mesh data is organized in a COLLADA file.

  10. 3:42 pm on March 10 2011, Bryan Ischo said:

    Your tutorial is appreciated, and is helping me to understand a little bit more about the Collada DAE format.

    I think you need to qualify your description of the tutorial however; it is not a tutorial that describes how to read any Collada DAE file. The tutorial makes quite alot of assumptions about the particular structure of the Collada DAE file, and I think that in general it will only load a very small subset of possible Collada DAE files, and that it will only cover those Collada DAE files created by a few tools configured very specifically for your use case.

    I am interested in loading files exported by Google 3d warehouse, and many features of the Collada DAE files exported by Google are not handled properly by this tutorial.

    Still, useful information on the Collada format is very hard to find and your contributions are helpful and appreciated.

  11. 12:54 pm on March 12 2011, TheCansin said:

    I never claimed it to be such a tutorial, the main problem with COLLADA is the small variances in exporters and toolsets that make writing a universal solution a major pain in the ass, I don’t actually make any assumptions, I state very clearly the nature of the COLLADA files that will be dealt with(deindexed by refinery, from Maya2010 and with the certain exporter and options).
    The main point to the tutorial was understanding how to the C++ COLLADA DOM rather than the actual data obtained or input, once you understand that part you can get anything you want from any COLLADA file in any way you want.

  12. 1:59 am on July 22 2011, Louis said:

    Thanks for your efforts.

    I tried to build your “COLLADADirectX” project.
    But I failed to build.
    I installed COLLADA SDK. But some DLL is missing or LIB files/DLL files can not be compatible.
    I can not solve this problem.

    Can you provide the complete files for your project?
    1. The “include” files that you used for your project.
    , , , …
    2. The “LIB” and “DLL” files that you used for your project.
    “libcollada14dom21-d.lib”
    “libxml2_a.lib”
    “zlib.lib”
    “wsock32.lib”
    “pcre-d.lib”
    “pcrecpp-d.lib”
    “minizip-d.lib”
    “libboost_filesystem.lib”
    “libboost_system.lib”
    Anyway, I want to build your project in a easier way.

    Please, help me.
    Thanks.

  13. 7:44 am on August 2 2011, TheCansin said:

    In order to use the COLLADA SDK you need those libraries, if I recall correctly the SDK comes with those libraries. Though you’ll probably have to get boost seperately. The project is complete and tested on several computers, no files are missing or incomplete, you just need to install and set up the COLLADA SDK properly.

Leave a Reply

*