chinedufn / skeletal-animation-system

A standalone, stateless, dual quaternion based skeletal animation system built with interactive applications in mind
https://chinedufn.github.io/skeletal-animation-system/
250 stars 24 forks source link

Support for dynamic mesh to bone binding? #1

Closed kevzettler closed 7 years ago

kevzettler commented 7 years ago

@chinedufn I'm really excited about your work here. I've been hacking on a WebGL game for some time and I'm not happy with any of the full featured engines I have tried. The Blender -> WebGL pipeline is unstable, borderline unusable in other engines. I think skeletal animation is a critical missing piece of the stack-gl ecosystem.

Can I manually create a mesh elsewhere, or import a separate mesh and bind it to a bone? Is that possible with this library? Like if I have a equipment like swords that I need to attach to a character. The workflow would be:

  1. create armature and animations in blender with 'place holder meshes'
  2. export to collada and import to WebGL environment
  3. animate the armature in WebGL
  4. create another mesh and bind to existing armature

    Let me know if that example makes sense.

chinedufn commented 7 years ago

@kevzettler First off.. apologies on my end. This skeletal animation work is pretty new and we haven't yet gotten around to examples / posts about how to do some of the common things that one would want to do. Also I'm pumped that you're excited. Feel free to keep those issues and PRs coming so that we can tighten up that pipeline!


So I'm assuming (correct me if I'm wrong) that you have a non-skeletally animated mesh that you want to make follow a bone.

i.e...: a weapon that you want in a character's right hand.


So, given the above, you'd do something like this:

  1. Blend your keyframe poses using skeletal-animation-system
  2. skeletal-animation-system gives you a location and rotation for all of your joints that you blended
  3. Use that blended bone data to animate your character as normal
  4. Also use that same blended bone data to draw your static, non-animated mesh. Just grab the translation and rotation for the bone that you care about and use that to determine where to position your static mesh. In our weapon example that would be your right hand bone's data.

So in essence, skeletal-animation-system only cares about your armature and it's animations so it doesn't specifically know about this use case, but it does give you what you need in order to "do it yourself." Of course over time there should be a separate module that abstracts this grab-the-bone-data-that-you-need-to-position-your-static-mesh process, but for now you can grab it by hand using the returned skeletal-animation-system blended array of bone data.

Again, apologies for the lack of a succinct place to point you to. We'll surely have to make progress over time on this front.


Let me know if that makes sense

chinedufn commented 7 years ago

Oh and additionally... this is something that I'm soon to need to do in my game so I'll be making a light abstraction layer around this process soon. Feel free to do it on your own in the meantime though. Also feel free to point out anywhere that I was confusing / unclear.

chinedufn commented 7 years ago

Published a tutorial on this https://github.com/chinedufn/webgl-wield-item-tutorial