@kbar @m_adam Thanks for the help lads, the markers were already added thanks to Kent suggestion in his previous reply.
Now the only things left are a little "GlTF-fighting", and some more polishing, packaging and testing before updating the plugin with a - hopefully - nice animation support !
I'll let you know when that's done (probably not before 2020 though ).
Hi Lads !
FYI, the solution of playing each animation one after the other gave satisfying results
A tricky part though was to take into account joints animated in one animation, but not in others, hence keeping keyframed values where unnecessary.
The naive but effective solution to this problem was to force joints to their rest position in the animations in which they are not keyframed.
Another "trick" was to offset the animation tracks by a small margin. If an animation ends at 5000ms for instance, we make the other one start at 5001ms. This allows for the "forced" keyframes to interpolate correctly and not mess up the whole animation (strange things started happening when setting multiple keyframes at the exact same time frame, probably an undefined behavior...).
For the "reference wolf", here is what the result looks like with an exaggerated margin between the animations is set to 1s (in practice, turning this value to something very small makes the transition immediate):
Anyway, thanks @kbar and @m_adam for your suggestions, this case is solved !
@m_adam Hi, and thanks for your feedback and suggestions.
The Take System sounds like requiring too much user interaction after the import, and I think we won't therefore consider it/
The motion system and "global" Python Tag seem like coherent alternatives to loading every animation one after the other.
Now, the last step is to choose one of those systems...
I think we'll first implement the back to back loading of animations as suggested by @kbar, as this seems like the most lightweight and straightforward solution for a quick iteration.
@kbar Hi Kent, and thanks for your comment and constructive feedback !
It's good to know that Motion Clips are hidden from the APIs, thanks for the confirmation on that subject.
Your back-to-back suggestion definitely makes sense.
Although it adds a little burden from the user perspective, it might still be the best approach to keep things "understandable", and has the advantage of not being too complex to implement, hence reducing the possible mistakes on our end
I'd definitely be curious about other suggestions/ideas too !
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
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).
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 ...
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 !
Loïc from Sketchfab.
We are currently working on a plugin to import glTF models from our platform into Cinema4D (using Python on C4D R20 Windows at the moment) and there are some details that we are still missing.
For the following points, we are not sure if it's even possible in Cinema4D or with the current python API, but if it's the case, we are interested by any reference or example you might have:
There is a TangentTag available but I didn't find any example or detail about how the data is structured, and also if this tag's purpose is actually to store tangent space data for normal mapping.
Also, I get an error popup mentionning "Tag 5617 not in sync" when I add it to an object.
(I read a bit about ddu and ddv properties in BaseShader but it doesn't seem to be the way to go)
A PointObject class is available but the API doesn't allow any instanciation of such object. Some existing scripts seem to create point cloud from Polygon objects but it's not clear if it's actually possible and also if it's the right way to go.
Some of our models are using several layers of UVs data for a given material, where for example the Diffuse texture uses UV0 and AO uses UV1 (which covers the whole scene with a single texture). Is it actually possible in Cinema4D ?
I was thinking about using layered materials to achieve this but even if it gives the right result, it would need material duplication and it's not really something we want to do.
Anything about any of these topics will be a great help, thanks a lot for your time.