Blending animations with MeshAnimationController?

Hi everyone,

I'm new to JME, so I'm not sure how to blend two animations using MeshAnimationController.

I found a method setAnimation(animation name, blend time) however this does not seem to blend animations at all. After a look in MeshAnimationController code, I noticed it creates a new AnimationChannel and makes it impossible to blend an animation (in AnimationChannel.setAnimation, blendFrom seems null). Therefore I tried to call instead setAnimation(animationChannel, animation name, blend time) using the same AnimationChannel for every call. This gave some results, but the mesh went totally wrong ! Finally I made it work, by calling first setAnimation(animationChannel, "<bind>")   such as it resets the animation to its bind pose. However my question is : is that the normal behavior of MeshAnimationController, is that a workaround to a (known) bug, or did I just misunderstand something ?



thanks !


Try this, I think it's what you want:


@@ -181,10 +181,15 @@
             reset();
             return true;
         }
+        AnimationChannel animationChannel;
+        if (animations.size() == 0) {
+           animationChannel = new AnimationChannel(this);
+        } else {
+           animationChannel = animations.get(0);
+        }
        
-        AnimationChannel animationChannel = new AnimationChannel(this);
         animationChannel.addAllBones();
-
+       
         Animation animation = animationMap.get(name);
 
         if (animation == null)
@@ -351,6 +356,7 @@
         }
         resetToBindEveryFrame = false;
         animations.clear();
+
     }
 
     void resetToBind(){
@@ -530,4 +536,4 @@
         out.writeStringSavableMap(animationMap, "animations", null);
     }
 
-}
+}
No newline at end of file

perfect ! thanks :slight_smile:

Should this be committed?

hi lyzard,

good to see you around here. So finally you've got your help :wink:



@SomethingNew

If this helps everybody who wants to blend animations and does not disturb all the other users of the class then it should be committed :slight_smile:

hi all,

yeah Custom and it was fast  :smiley:

I don't know all the side effects of committing this. At least it does what I wanted, my ninja is much smoother like that :stuck_out_tongue: