I've got millions of user-generated Cal3D assets that I'd love to be able to integrate into Unity. However, there doesn't seem to be any easy-to-find path for importing Cal3D (even by importing and exporting in popular 3D packages). Has anyone attempted to do this before, or does anyone have any suggestions about the right path to take? Is it possible to write a custom importer for Unity to import Cal3D files?
You can write an importer for any format, as long as you have the specs for it (or feel like reverse-engineering it). You "just" have to parse the data and build a mesh from it that Unity can use, which is easier said than done of course....
Ok i think i can finally publish my Cal3D importer. Note that that there seems to be actually newer versions of the specification. However the specification does not really state a particular version. This importer was created based on the file version “700”. Though it seems that version “900” mesh files load just fine. Though i’ve seen another specification that has some additional data which would break loading.
Anyways here’s a github repository. The only important files are:
The Cal3DTools contain methods to just load the data into a class structure. The Import window is an actual editor script for Unity where you can simply “import” a Cal3D configuration file.
This is an example of the imported Paladin example file:
The repository also contains a helper script to display a gameobject hierarchy connected through lines. This is useful to visualize the bone structure of a model.
This importer is far from being perfect and also isn’t really robust against any kind of errors. It expects the file versions to be 700. Though it does not cancel loading when you provide a higher version, it just prints a warning in the console and tries to load it anyways. Of course this could lead to unpredictable behaviour, so make sure you save you project ^^.
I’ve noticed that even the paladin sample loads fine, the other two example files i got (cally and skeleton) have inconsistent winding ordering of the triangles of it’s various mesh parts. So those either need a two sided shader or some manual “fixing” of some sort. Maybe it would be great to have some config options in the future but for now that’s all i can give you ^^.
After all i released it with an MIT license so feel free to modify it to your needs (note i won’t accept pull requests as i like to provide my stuff as it is ^^).
I have an In-Game Cal3d importer i am working on. So far i can load skeleton, meshes and skeletal animations. It needs to be seriously improved more.
I am using an XML Parer i found on the forums but i’ll post all code here. perhaps we can make it work better.
[3053-cal3dscripts.zip|3053]