Bone Animation – Weighted animations

Just a quick question today…



Having just started to use the JME3 engine, couldn’t easily see if there was a way to get multiple animations running simultaneously on the same bones (i.e. applying a weight to each animation).



Wondering if I’ve just overlooked a method or demo somewhere?

TestComplexAnimation? Idk if weighting works tho

Yes it works and that test is using it

Ah, yes TestComplexAnimation. That’s got the animated metal man model going a bit crazy :slight_smile:



From the looks of the code, it’s running three animation, however they look each to be affecting a discrete / separate set of the bones.



Really what I’m wondering is whether the same bone can be affected with a weighting given to each animation to determine how much it affects the bone.

So code wise it’d be something like:



AnimControl control = model.getControl( AnimControl.class );
AnimChannel channel = control.createChannel();
channel.setAnim( "CQ Attack Thrust", 0.25f );
AnimChannel channel2 = control.createChannel();
channel2.setAnim( "CQ Arrow Forward", 0.75f );


Where each animation say affected the same hip bone and leg bones, and would affect them 25% and 75% respectively (so 25% of the first animation translation & rotation and 75% of the second translation & rotation).

Having looked through the TestComplexAnimation. and AnimChannel, can't see where / how to apply such a weighting to the animations.

OK, that one isn’t really possible but I cannot imagine even how you would use something like this.

Generally blending of this sort can cause the animation to look incorrect

Ah yes, Momoko_Fan …you’re right, it looks like I didn’t entirely think this one through.



Applying two animations on the same bone is simply going to mess up both animations.



The application I thought of was applying and upper body and lower body animation to the hip bone. Where ideally this would mean that both animations would balance out into a happy mediums for that bone, but it’d affect the child bones (which is every other bone) by messing the rotation and translations – meaning they’ll look wrong.



Thanks for the replies, though. It’s helped me realise the error of that line of thinking :slight_smile:

I could imagine some use-cases for blended animations:

  • transition in Facial Expressions
  • mix for speech animation: character says: “Loud” → mix between “O” and “U”
  • random faces (long nose: 76%, wide nose: 50%, normal nose: 10%) - save or use with vertex shader
  • animation of blobby aliens
  • animation of demons (extra look terrible animations)



    Better to have the option to blend anims, then not…

To be clear, you CAN blend bone animations in jME3.

And it works exactly the way you describe, and blending between 2 anims for a smooth transition is the common use case.

This works with a weight too, but the weight is computed by the engine over time (transition last 0.5 sec for example, the weight will be linearly interpolated from 0 to 1 in this period of time).

usage is



channel.setAnim(“animName”, blendTime);



Where blendTime is the transition duration between the previously played anim and the requested anim.



What the OP was asking for is to be able to set the weight to each anim.

something like :

channel.setAnim(“animName”, weight);

Which makes little sense IMO