Giter VIP home page Giter VIP logo

Comments (46)

nicocornelis avatar nicocornelis commented on May 29, 2024 4

That's right. If you want to use the model in a game engine you have to implement the non-linear editing in real-time by combining separate actions based on user input and time. If you have access to the separated actions you could sample the blended animations at their respective times and use a blended pose as the result just as the NLA editor does but in a non-deterministic fashion because for games the resulting pose is not predetermined by time value because it has to vary with user input.

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024 3

Now that SIGGRAPH is finished, for me personally this is the most important feature request / enhancement on the exporter. It has come up that many of our sample models do something undesirable β€” having separate animations for each node, rather than each action β€” perhaps a bug in COLLADA2GLTF. It would be great for the Blender Exporter to help us set the record straight on actions. πŸ™‚

from gltf-blender-exporter.

udoprog avatar udoprog commented on May 29, 2024 3

The problem is that blender allows too much flexibility for the exporter to be predictable. In blender an action can be applied to all objects. eg. you can apply the same action to different armatures as long as they have the same bone names. You can even apply it to an armature with less bones (in which case the graphs belonging to non-existent bones are just ignored) or to armatures with more bones, in which case the bones without corresponding graphs are not being driven by the animation while respecting the parent-child relationship. As such, I haven't found a direct link between an object and its actions within the blender api.

That is a great point. For my purposes it could just be an exporter option. Like "Include animations that have no users (requires single armature in scene)". I would typically only have one armature per file regardless. More advanced use-cases could have more advanced solutions (muted NLA tracks, name prefixing, ...).

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024 2

You are right, it is shadowing. Probably happened during refactoring. Fixed. Thx for fixing this.

As you know, I need to understand :-)
Why do you need to separate the animations? Is the reason you want to run animations individually and separated?

from gltf-blender-exporter.

udoprog avatar udoprog commented on May 29, 2024 2

Hey.

So would a cleaned up and rebased version of the patch provided by @nicocornelis be desirable? I can put in the work to get it done. But I'd like to make sure that the project is aligned with the approach first.

from gltf-blender-exporter.

cdata avatar cdata commented on May 29, 2024 2

I was able to incorporate an adaptation of @nicocornelis patch to get access to additional actions for a game project. I just wanted to add a voice of support that this issue should be addressed. It is very hard to use GLTF effectively in a game engine without multiple animations.

from gltf-blender-exporter.

cdata avatar cdata commented on May 29, 2024 2

@donmccurdy Yes, I will make a PR so at least there is something that sort of works in a Github repo. YMMV though. I'll ping this thread when it's up.

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024 1

Okay got it and makes sense.

We will add it, but after SIGGRAPH:
We fix all bugs before SIGGRAPH and collect/add all features after SIGGRAPH.

Thx Nico!

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024 1

Good idea, thanks @nicocornelis! This will help three.js and A-Frame users, in addition to game engines. But I agree it can wait until after SIGGRAPH. :)

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024 1

This is what we had so far, but it does not work in all cases:
io_scene_gltf2.zip

from gltf-blender-exporter.

udoprog avatar udoprog commented on May 29, 2024 1

@UX3D-nopper

But if I got you correct, it would be okay/acceptable, if just all actions of an object are exported, not taking care how they are arranged/blended/repeated/scaled in the NLA editor?

Yes, I would be OK with having anything in the NLA editor raising a warning for this particular mode of export.

The workflow described in this video would only allow one object to be animated, as all other animations do not have any users.

Having a single game entity in any given .blend file is a common pattern for me. So I would be happy with this. But I appreciate that this would result in a different mode of operations that is more specific to games. Exporting whole game scenes would be rare, since they typically contain more information than what glTF 2.0 is currently capable of. Depending on the game engine of choice.

But maybe it's possible to address this issue. I'm not sure the following is the best approach; Even though an action doesn't have users, it still appear to have groups. I believe they should correspond to the name of the bones being animated. These are unique. This is tested after forcing, saving, and restarting blender:

>>> action = bpy.data.actions['WiggleAction']
>>> groups = set(g.name for g in action.groups)
>>> groups
{'BottomBone', 'MiddleBone', 'TopBone'}

This could allow you to identify a given armature, and find it's children (the object it's attached to, if any). This is a very pedantic approach, only matching that all groups are present in an armature:

>>> armature = next(a for a in bpy.data.armatures if all(b.name in groups for b in a.bones))
>>> armature_object = next(object for object in bpy.data.objects if object.type == 'ARMATURE' and object.data == armature)
>>> armature_object.children
(bpy.data.objects['Player'],)

I hope this might prove to be helpful.

Edit:
Changed lookup for armature object since the armature name might differ from the object name.

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024 1

@inkthorne certainly Blender and glTF animations are a bit different, and maybe glTF can be extended in the future to transfer animation data without needing to be targeted at particular bones, but I don't think it's the issue here. The implementation work simply needs to be done and hasn't been done yet. There is another glTF Blender exporter that supports multiple animations quite well, if that helps any.

from gltf-blender-exporter.

inkthorne avatar inkthorne commented on May 29, 2024 1

Thanks, @donmccurdy, I wish it did.

It's cool that the Kupoman exporter gives you the 'All Eligable' option, but this only works well in specific cases, e.g. only one armature in the scene for skinned; only one object in the scene for articulated. Otherwise, each animation is duplicated (buffers & all) for every armature/object in the scene. Having my articulated windmill animations duplicated for every building, tree, fence, & light post in the scene is not ideal. :) The approach of @nicocornelis & @cdata, where an object's stashed actions are exported, sounds like the better way to go.

from gltf-blender-exporter.

udoprog avatar udoprog commented on May 29, 2024 1

The best kind of closed, thanks @donmccurdy and others making this happen! <3

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024

At the moment, it is more important that all documentations and basic tests get finished - and of course all bugs eliminated.
Close before SIGGRAPH, we will tag a stable and robust version. Right after that, we can change things on a daily and even hourly basis. I/we just do not want to create another branch at the moment, as this would increase unnecessary our work load.

Also, if all documentation is done, sooner or later everyone is welcome to do pull requests :-)

from gltf-blender-exporter.

nicocornelis avatar nicocornelis commented on May 29, 2024

Here's a quick update for the code to support this feature. Definitely not safe for SIGGRAPH :-)

Idea is to export one 'default' scene animation by checking for each object if there is an nla track. If an nla track is found it is baked to an action to be exported. If no nla track is found the currently bound action is exported if available. In the default scene animation the shapekeys are also being evaluated.

I believe when apply modifiers is selected, the armature is also being applied to the meshes so I guess the armature modifier should be muted before applying in this case...

Next, for each armature, a separate animation is exported for each action that is referenced in its nla tracks. The json name key exported for the animation is [Object.name]_[action.name]

gltf2_generate.txt

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024

Let's wait after the weekend and maybe one or two more days. If there is no major bug, we will tag the exporter as version 1.0.
Then, we can add this feature first and the other requested features without huge testing.

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

Carrying over conversation from #81 β€”

NLAs are currently not exported. We tried it, as we thought it is a quick implementation.
Using simple examples, it did work but using more complex ones did show us, that the NLA feature is too buggy.

@UX3D-nopper if export of separate actions isn't something you'll be able to implement, could you write up more detail about the bugs and/or limitations you've run into, or perhaps share a work-in-progress branch? Are these issues that the content author can work around with some effort? This information may be helpful for anyone in the community attempting to implement it as a PR later, which i'm expecting to be a frequent request.

Related, three.js's own Blender exporter has had to deal with some problems in this area as well: mrdoob/three.js#7631

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024

Already at home, but will summarize it tomorrow.

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024

But to say it in advance, it has some random behaviour. That's the reason we need to get in touch with the Blender folks.
But I think I have still the experimental code on my disk.

from gltf-blender-exporter.

udoprog avatar udoprog commented on May 29, 2024

Hey, as an aspiring game engine author trying to build glTF 2.0 support, this is probably the biggest blocker for me right now.

The file provided by @nicocornelis on Jul 14 seems to do mostly the correct thing afaict with exporting each action as a separate (named!) animation. But it has some white space issues making it hard to rebase. If this could be fixed and this patch could be put on a branch, it would be much easier to keep track of what it was based off and rebase it once the work @UX3D-nopper is doing completes.

There will always be some paradigm mismatch between an exported file format and the capabilities of Blender. Limiting your workflow based on this is in my opinion acceptable.

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024

It is not about a mismatch. It is really "random" behaviour:
You implement something in one NLA track and do it exactly the same in another NLA track, you would expect the same behaviour. But in many cases it it not.
The code above does export several simple NLA tracks. But as soon as the tracks get more sophisticated, the export gets random.
If there would be a determinisitic workaround, fine, but currently it does not seem so. That's the reason why we wait for the feedback from Blender. Otherwise we would get hundredes of issues.

As the code is open source, I recommend that you fork the current branch and implement the blocking features depending on the code snippets provided.

from gltf-blender-exporter.

udoprog avatar udoprog commented on May 29, 2024

@UX3D-nopper Hey!

I am not familiar with the issues you are facing nor this code base at the moment. I realize I didn't specify what I was referring to, so I'll do that now.

The workflow I would prefer supported - at least for game dev - is the one which is used by Unity. You force save each individual Action and they are independently imported into the engine. The NLA editor is to my knowledge not involved. Interpolation across actions are handled in the game engine. I think this is what @nicocornelis was aiming for, but I could be wrong. Would this be possible?

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024

I will have another look at it but to assign several actions to an object, the NLA track feature is used.

But if I got you correct, it would be okay/acceptable, if just all actions of an object are exported, not taking care how they are arranged/blended/repeated/scaled in the NLA editor?

@donmccurdy @nicocornelis Is this the same appraoch you are looking for?

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

You force save each individual Action and they are independently imported into the engine. The NLA editor is to my knowledge not involved. Interpolation across actions are handled in the game engine.

Yes, I believe this is what I need too. πŸ™‚ Essentially this workflow, which does not touch the NLA editor. Three.js and A-Frame can handle interpolating multiple actions as Unity does, so long as each Blender action is a separate glTF animations entry.

from gltf-blender-exporter.

McNopper avatar McNopper commented on May 29, 2024

The workflow described in this video would only allow one object to be animated, as all other animations do not have any users.

Will think about it.

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

When I mark in Blender, "Save this data-block even if it has no users", perhaps that can be used to indicate it should be exported, too?

But I am well outside of my understanding of Blender here. The authors of the three.js Blender exporter have run into related issues (mrdoob/three.js#7631 (comment), mrdoob/three.js#7666), and arrived at a compromise that focuses more on individual character export (with multiple disconnected animations) and less on cinematic export (with reused and interpolated actions). Let me see if someone else can comment.

from gltf-blender-exporter.

nicocornelis avatar nicocornelis commented on May 29, 2024

Hi all,

As udoprog has already mentioned, my intention was to export each action of an object to separate animations in the glTF file and also export the baked NLA track as the default animation. This way the file can be used to show the animations as they were intended with all interpolations pre-applied but with the added flexibility of being able to extract separate actions from the file by filtering the animation tags within the glTF file.

The problem is that blender allows too much flexibility for the exporter to be predictable. In blender an action can be applied to all objects. eg. you can apply the same action to different armatures as long as they have the same bone names. You can even apply it to an armature with less bones (in which case the graphs belonging to non-existent bones are just ignored) or to armatures with more bones, in which case the bones without corresponding graphs are not being driven by the animation while respecting the parent-child relationship. As such, I haven't found a direct link between an object and its actions within the blender api. The only way I was able to let the exporter automatically link objects to actions was to put all desired actions within the NLA track of that object. In that case the exporter makes a list of all actions that make up the NLA track and exports each action separately as well as the baked version. If you also want to export actions that are not part of the NLA track you could still add those actions as another muted NLA track so that the exporter would still detect it.

That was basically my intention when I wrote the above script, bugs and all :)

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

...my intention was to export each action of an object to separate animations in the glTF file and also export the baked NLA track as the default animation.

Sounds right. If there is a problem in Blender preventing the NLA track export for now, hopefully that will not block us from getting the actions as separate animations in the meantime. πŸ™‚

from gltf-blender-exporter.

UX3D-nopper avatar UX3D-nopper commented on May 29, 2024

Yes please, go ahead. Please make it optional/experimental and try to separate it from current code as far as possible,

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

@nicocornelis any chance you would have the time to update your changes onto the latest version of the exporter and open a PR? I tried to figure this out myself, but couldn’t get very far. Not sure if @udoprog ran into the same trouble. πŸ™‚

from gltf-blender-exporter.

tkazik avatar tkazik commented on May 29, 2024

Hi folks,

I am sorry to interrupt your discussion but I think you might be able to help me out. I am still fairly new to gltf and also blender: My goal is to achieve an animated aircraft model that can be controlled (e.g. gear or flaps) by the user in cesium. I know how to make a single time-based animation but I am missing the part on how to have multiple animation in the model that can be controlled based on user input. Is the exporter able to handle that? If yes, can you give me a hint on how to proceed?

Than you very much!

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

I know how to make a single time-based animation but I am missing the part on how to have multiple animation in the model that can be controlled based on user input.

@tkazik Sorry, that's exactly the feature that is missing from the exporter. Updates will appear on this bug as we make progress! There is another glTF blender exporter that theoretically supports multiple animations, but there seem to be problems there as well β€” I haven't gotten it to work.

from gltf-blender-exporter.

tkazik avatar tkazik commented on May 29, 2024

Alright, thx for the quick reply! I will be following both exporters and am looking forward to see them work with animations. Btw, do you also experience some issues if both exporters are installed? I only happen to see one interface if I hit export as gltf, regardless which exporter I choose.

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

@tkazik Hm you're correct; I can't use one without disabling the other. Perhaps a Blender limitation.

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

@cdata Good to hear! Any chance you could open a PR with your adaptation of the patch?

from gltf-blender-exporter.

cdata avatar cdata commented on May 29, 2024

PR up, please note the details and caveat in the description!

from gltf-blender-exporter.

Nehon avatar Nehon commented on May 29, 2024

Is there any news on this issue?
I tested the PR #111 but I couldn't manage to have it to work properly.

from gltf-blender-exporter.

MrJustreborn avatar MrJustreborn commented on May 29, 2024

Maybe take a look at the better-collada-exporter - it can export all animations:
https://github.com/godotengine/collada-exporter/blob/master/io_scene_dae/export_dae.py#L1758

from gltf-blender-exporter.

cdata avatar cdata commented on May 29, 2024

@Nehon can you describe the problem you ran into using #111? FWIW I have been able to use it successfully in a project.

from gltf-blender-exporter.

Nehon avatar Nehon commented on May 29, 2024

Yes, sorry for the vague explanation.
I have a model with several actions attached to the armature. I add each the actions in a separate NLA track in the NLA editor (except for the one that is active in the Action editor). When I export, the active one from the action editor works fine, the other one are there named as expected (-) but it seems only a subset of bones are animated (like the root bone and sometime some extremity bones).
It's hard to describe, I'll try to shoot a gif.
The model I use is this one https://sketchfab.com/models/112ae8160af54eeea6b2483b903634f4

from gltf-blender-exporter.

cdata avatar cdata commented on May 29, 2024

Ah yeah. What I did in #111 was enable exporting the main action and all stashed actions associated with an armature. Actions arranged on the NLA editor are different and the PR doesn't do anything with those.

from gltf-blender-exporter.

Nehon avatar Nehon commented on May 29, 2024

Haa!.Makes sense, I'll try it thanks.

from gltf-blender-exporter.

inkthorne avatar inkthorne commented on May 29, 2024

@donmccurdy I'm wondering if part of the issue here might be the glTF spec? glTF binds animation channels to nodes by index. The direction of this dependency creates difficulties for exporting actions/animations not explicitly referenced by an object, and makes for extra steps when trying to reuse animations on different targets.

Tools like Blender and game engines like UE4 allow for easy animation re-targeting due to animations being largely target agnostic. Actions in Blender only know about the properties they manipulate (location, rotation, scale) and optionally the bones (by name), not the actual object/armature they act on. Instead, it's the objects/armatures that are assigned an action.

It seems like a lot of the complications of exporting these animations might go away if a glTF animation doesn't always need to know the specific indices of the nodes it drives.

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

@dustronauts could you give #166 a try? I believe it resolves this reasonably well, although there are a few bugs left to iron out. I haven’t had time to finish that up these last few weeks.

from gltf-blender-exporter.

donmccurdy avatar donmccurdy commented on May 29, 2024

Resolved by #166.

from gltf-blender-exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.