bunkerbewohner / colladaxna Goto Github PK
View Code? Open in Web Editor NEWCollada Importer for XNA (Work in Progress)
Home Page: https://github.com/Bunkerbewohner/ColladaXna/wiki
License: MIT License
Collada Importer for XNA (Work in Progress)
Home Page: https://github.com/Bunkerbewohner/ColladaXna/wiki
License: MIT License
Even though the underlying ColladaModel class imports not only diffuse texture maps, but also specular maps, environment maps, normal maps and opacity maps, only simple diffuse texture maps are converted to the XNA content model within the pipeline extension right now.
Therefore conversion of these texture maps to the XNA content model has to be implemented (I personally don't know how to do that right now).
This library was created to import single animated 3D models from COLLADA files. However, the COLLADA file format is much more powerful than that. You can actually store multiple complete 3D scenes with lights, cameras and abitrary entities.
Maybe in future a seperate library could be created that allows importing entire scenes from COLLADA to XNA. The advantage of this would be that you wouldn't necessarily have to create a Level Editor. You could simply use your favourite 3D Content Creation Tool, such as 3ds Max or Blender, to design your 3D scenes and levels.
Even though using the Importer is as simple as selecting it from a ComboBox in Visual Studio, some documentation is still needed for developers who might want to improve or extend the library, or simply want to understand how it works.
Also I should probably add more comments to the code.
Animations are already correctly imported. However, right now animation clips are not. Animation clips are simply tuples of name, start- and end-time of logically separate animations. I.e. while most of the time there will be one long animation in the COLLADA document, it will consist of different parts. For example the first 30 frames could be a walking animation, the next 30 a jump, and so on.
Animation clips allow accessing these parts by their names rather than by frame numbers. Therefore it would be nice to import these clips. Unfortunately I haven't seen an exporter that actually exports animation clips yet. But I can just refer to the COLLADA specification to implement it anyway. In the worst case you can add animation clips via notepad very easily.
I think you forgot to state what license the code is under.
As it stands, it is unlicensed, which means that it can not be technically used, redistributed, or modified.
If you have not chosen a license, may I suggest Apache 2, or MIT X11?
A few files have a "Copyright MIcrosoft, all rights reserved" which looks like they came from some sort of sample or template. It might be worth replacing those with code that is licensed appropriately, or finding if Microsoft released updated versions with a new license.
The XNA content model and Model class do not cover the whole COLLADA specification. For example COLLADA files also can define lights and cameras, which are obviously not part of a Model but of a complete scene.
Maybe a Scene content class could be created which contains these information and also references Models as its elements. So when you load the Scene object via the ContentManager you get use the information to render the whole scene with an existing engine (such as SunBurn).
But maybe this is simply not needed and it is enough to just import single Model entities.
Currently only triangulated meshes are supported, since XNA only supports triangles natively. Content creation tools often use more complex polygons, though. Even though many programs support triangulation for COLLADA export, it would be desirable not having to rely on this.
For this reason an integrated triangulation algorithm could be implemented to handle more complex polygons in COLLADA documents for import into XNA.
COLLADA also supports other geometry representations such as NURBs, which could be triangulated automatically.
The default Autodesk COLLADA exporter used in 3ds Max 2012 does not export skeletons as expected. Unlike OpenCOLLADA no tag is created to reference the root joint. My current implementation relies on this reference though.
Therefore animated models exported 3ds Max 2012 (for which OpenCOLLADA is not yet available) are not loaded properly. To fix this, a function can be created that simply searches for the first occuring scene graph node of type "JOINT".
COLLADA supports custom effects (e.g. HLSL shaders) with arbitrary parameter bindings. These are already loaded, but not yet converted to the XNA ContentModel. For this there might be a content processor needed which creates the corresponding Effect instances.
Right now only up to four joints influencing a single vertex are imported. This was done because this way the index and weight channels could be imported as Vector4 elements. However, this restriction is not necessary.
Support for an arbitrary number of joints must be implemented (which is easily done).
COLLADA allows defining physical properties of scenes. These could be imported and attached to the XNA model to make it easy using models loaded from COLLADA files with physics engines.
Hi
In the Titles file function:
static bool DoesAnimationAffectJoints(Dictionary<string, Joint> joints, XmlNode xmlAnimation)
Lines:
XmlNode xmlChannel = xmlAnimation.SelectSingleNode("//channel");
----- 8<----------------
string target = xmlChannel.Attributes["target"].Value;
Seems always to ALWAYS inspect the first animations channels target, instead of the parameters one..
It started to work more nicely with following line:
XmlNode xmlChannel = xmlAnimation.SelectSingleNode("animation/channel");
Does this make any sense... ?
I found this when Animators Max spitted out some animated joints without any frames.
Best,
Niittis
ps. Thanks for nice piece of Code.
Even though the underlying ColladaModel class already loads skinned mesh animations, the animation data still has to be converted to the XNA content model (based on NodeContent).
The implementation has to be tested thoroughly. Easiest way: Simply trying to load and display many different COLLADA models and see if any bugs pop up.
Hello Mathias,
I'd like to appreciate your outstanding work on XNA collada importer project in the first place.
But in the second place I'd like to ask if there is an WP7 version of this project.
I would suppose because it's an Importer (not even processor) it should work with any type of XNA project, but I'm getting this error after trying to import dae file (following your guide posted here: https://github.com/Bunkerbewohner/ColladaXna/wiki/Quickstart):
"Building content threw NullReferenceException: Object reference not set to an instance of an object.
at ColladaXna.Base.Import.SkeletonImporter.GetNodeName(XmlNode xmlNode)
at ColladaXna.Base.Import.SkeletonImporter.ReadJoints(Joint parent, IEnumerable`1 xmlNodes, ColladaModel model)
at ColladaXna.Base.Import.SkeletonImporter.Import(XmlNode xmlRoot, ColladaModel model)
at ColladaXna.Base.ColladaModel.Load(String filename)
at ColladaXna.Base.ColladaModel..ctor(String filename) ..."
So i tried to build WP7 version of this library, but also with no success - some parts of code is not supported on WP7 platform (eg. XmlNode type and so on).
So is there any way to use your awesome library on WP7 platform?
Thank you very much
Best Regards
Jakob
Right now only one texture coordinate channel is imported. Multiple texture coordinate vertex channels are not handled correctly. This is not a bug, it just wasn't implemented yet.
Currently the library uses the DOM based XmlDocument class for parsing COLLADA documents which offers easy access to the XML data. However, since COLLADA models can be several MB large this method can be very memory consuming. An alternative SAX implementation would probably not only save memory, but also would be faster.
Even though the ColladaModel class loads Collada scene graphs correctly (to a reasonable extent), the Content Importer pipeline extension still needs to convert this information to the XNA content model (NodeContent class).
Right now Meshes are just added flat to the root NodeContent not properly representing the scene node structure and, more importantly, their transformations.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.