Hi,
We have made some progress to get our plugin working for C4D R20/R21, allowing import and export functionalities to Sketchfab (if you are curious, here is the latest version of the plugin, please note that you'll need an account on Sketchfab in order to download/upload files from/to the platform).
We are now working on implementing support for the import of animated skinned objects, and... well... problems arise
How the import works
Basically, we allow users to gain access to our library of downloadable models. The plugin allows to browse for models in a way similar to the website, and once authentificated, to import models through the GlTF format.
In the latest release, we manage to correctly import the majority of the available files, although some of the materials can look different (due to the PBR material system we use on Sketchfab, and that is well translated in GlTF but not natively supported in Cinema4D).
The problem
This model makes for a perfect typical example: Wolf with Animations by user 3DHaupt (available under CC Attribution-NonCommercial-ShareAlike).
As you can see on the 3D viewer or on the picture below, the wolf character has multiple animation "tracks" attached to it: Run, Walk, Idle...
As you can see on the screenshot below, importing the model works fine: we managed to import the joints and create the skeleton hierarchy, as well as skin the mesh with c4d.modules.character.CAWeightTag and OSkin objects (created under each skinned mesh).
Importing only ONE animation from GlTF also works fine by parsing the keyframes and adding them to the F-curves of newly generated CTracks. So far, so good, we have a running wolf !
However, not being very familiar with Cinema4D ourselves (as users as well as using the API), we don't (yet) know how to import MORE THAN ONE animation in Python, in a way that makes sense to C4D users ...
Things we tried / think about
- We've explored using the Take system (for each different animation, create one Take, add it under the Main take, set it as the current take, and then parse in the keyframes/curves).
But the final result seems to just be a mess of all the different keyframes combined, and except if we did something wrong, this system does not seem to be appropriate for what we are looking to achieve...
- The motion clip system seems to be the standard and more appropriate for this "character" use case (generate one clip for each different animation, and let the user combine, separate or merge them as pleased), but we can't find any way to implement this through the Python API...
- Another idea is to emulate the tutorials we find about Mixamo import (for instance here), and basically import the same geometry multiple times, but the workflow does not seem intuitive and feels like overkill given that we already have all the animation data in one file. Plus the motion clip system is still a mystery.
- Finally, a last thing that people seem to do is to import each animation in a different C4D document, but once again, this seems far from the ideal workflow.
Help ?
Keeping in mind that we are far from being C4D experts, we are looking for any hint to implement the correct workflow to import multiple animations.
Should we use the Take System, Motion Clips, CMotion ?
And if so, how can we use them in Python ?
Any help, code example, documentation, advice, or even further question concerning the issues we face would be, of course, warmly welcomed. Thanks in advance !
Cheers,
Loïc from Sketchfab.