Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement gltf animation loading, playback example #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vabrador
Copy link

Objective

  • Add glTF animation loading on top of Looooong's mesh skinning PR.
  • Add a practical example with an animation controller that can drive and blend multiple animations on a single scene.

Solution

  • Animation Loading.
    • Adds bevy_gltf/src/animation.rs to hold all the animation-related structs to hold the data that can be pulled from the gltf crate json data. This adds GltfAnimation and its children: Channels, Samplers, and the like.
  • Animation Info at Runtime.
    • Right after the scene is loaded in the Gltf loader, adds GltfAnimTargetInfo components to any target entities in Gltf Scenes.
    • GltfAnimTargetInfo contains a reference to the Gltf handle that spawned it, and all of the animation+channel pairs that target that entity's transform.
  • An example GltfAnimationController and update system.
    • To demonstrate how this info can actually be used, the added example gltf_skinned_mesh_using_animation_data contains an example GltfAnimationController and the necessary general infrastructure that enables a generalized update_gltf_animations system.

@Looooong's gltf_skinned_mesh example replicates the glTF SimpleSkin tutorial scene, except for the animation part. The new example replicates the same scene using the animation data in the gltf in combination with general purpose animation controller code.

bevy_gltf_skinned_mesh_using_anim_data

The reason I'm including a lot of "generalized" animation code in the example is to allow people to make full use of glTF model animations in their own Bevy projects without needing a fully general-purpose animation system to be built. I'm submitting this PR as a port from a personal project that just patches @Looooong's skinned mesh feature on top of Bevy 0.5, so even though this example doesn't make use of animation blending, the animation controller code handles animation blending (mostly) fine:

2021-09-24 19-20-25 1 - Bevy Animation Blending in Action

@Looooong
Copy link
Owner

@nickjbenson Sorry for the late reply, I didn't notice there is a PR in one of my forks until someone mentioned about it.

This is amazing! Thank you for your effort to make a generalized controller. This is something that I planned on doing after getting the original PR merged.

It seems that the skeleton animation feature might be merged after the 0.6 release. But before that, I need to modify the code a lot. Cart made a good suggestion about moving the code into bevy_pbr create because it is "core" enough. Be aware that doing so means there will be a breaking change to your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants