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.
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! =)
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.
The tutorial for it is almost complete, just making the documentation and testing it a bit as we speak… =D
Türkçesini yay?nlamak seni çok yormazsa, türkçesini isteriz…
benim türkce yeterince iyi de?il =(
thanks for the post
[...] TheCansin.com » Blog Archive » COLLADA loading for DirectX. Previous Post« ???Direct3D?Collada??????????????: ? masafumi’s Diary Next Post [...]
Cool thanks for sharing!
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?
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.
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.
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.
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.
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.