Recognition of finished "dontloop"-animations

Hola, I wonder if there is a reliable way avaiable to check if an animation with LoopMode "Dontloop" is finished.

Actually since jME2 I wonder why clamp or dontloop don't stop the controller as it finished its job!?

If you want to blend from the finished channel-animation, the AnimController would have to be enabled again and the new Animation would be blended from the finished animation. Ok, if using different animation-channels for diffent parts of the skeleton (once it is available) you would have to check if all channels of the animation-controller are finished before disabling the controller.

Or maybe there is a logic behind that behaviour I don't see?!?

One first step could be to mark the Channel as finished when you reached the end of the animation, so you could react on that (e.g. start the next animation…). But we really should discuss the disabling of the whole controller if not needed.

Index: src/core/com/jme3/animation/
--- src/core/com/jme3/animation/   (revision 5004)
+++ src/core/com/jme3/animation/   (working copy)
@@ -20,8 +20,10 @@
     private float blendAmount = 1f;
     private float blendRate   = 0;
+    private boolean finished = false;
-    private static float clampWrapTime(float t, float max, LoopMode loopMode){
+    private float clampWrapTime(float t, float max, LoopMode loopMode){
         if (t < 0f){
             switch (loopMode){
                 case DontLoop:
@@ -34,6 +36,7 @@
         }else if (t > max){
             switch (loopMode){
                 case DontLoop:
+                   finished = true;
                     return max;
                 case Cycle:
                     return max;
@@ -102,6 +105,7 @@
         time = 0;
         speed = 1f;
         loopMode = LoopMode.Loop;
+        finished = false;
     public void setAnim(String name){
@@ -135,4 +139,13 @@
+    /*
+     * finished a DontLoop-Animation?
+     */
+   public boolean isFinished() {
+      return finished;
+   }

Problem with disabling the control, is that you might have user bone control enabled, which means there might still be "animations" on the model that the control doesn't know about. In general I think it's best to keep it active and only disable it on user request. If you check SVN you'll notice there's already an "AnimListener" interface that allows you to receive events when an animation cycle is complete as well as some others, it has not been integrated into the controller yet, though.

Sorry for reviving the thread, but the change requested in this thread has been commited. It's now possible to detect when an animation cycle completes through the AnimEventListener. See the TestOgreAnim class for usage.

Yeah,…I already saw it! Many thanx. jME3 is becoming more and more a real beast :smiley: