RT_CLAMP and stuck animation

I've successfully imported an animated ms3d file into .jme format using ModelLoader.



Now I'm writing a little application that's kind of an animation viewer, and I can't get "one-off" animations like "jump" to work right.



What I'm trying to do:


  • when the user presses a key, change from whatever animation is playing and run through the jump anim frames then stop at the end. When the user presses another anim's key, switch to that other anim.



    What's happening:


  • all of my cycled animations, using setRepeatType(Controller.RT_WRAP) work fine and look great and I can switch between them with the touch of a button. The one-off anims are set with Controller.RT_CLAMP, which, if I understand it correctly, freeze the animation on the last frame, which it does, but then it will not play other animations when a key is pressed.



    Problem: At the end of an anim set to RepeatType RT_CLAMP, the model is frozen and refuses to play other animations. The console output for those button presses still works.



    Here's what my simpleUpdate function looks like:


protected void simpleUpdate(){
       
       if(key.isKeyDown(KeyInput.KEY_1)){
          modelJointController.setSpeed(1f);
          modelJointController.setRepeatType(Controller.RT_WRAP);
          modelJointController.setTimes(40, 80);
          System.out.println("Idle");
       }
       
       if(key.isKeyDown(KeyInput.KEY_2)){
          modelJointController.setSpeed(2f);
          modelJointController.setRepeatType(Controller.RT_WRAP);
          modelJointController.setTimes(80, 120);
          System.out.println("Walking");
       }
       
       if(key.isKeyDown(KeyInput.KEY_3)){
          modelJointController.setSpeed(1f);
          modelJointController.setRepeatType(Controller.RT_CLAMP);
          modelJointController.setTimes(1, 20);
          System.out.println("Jump");
       }

}



Also, whats the best way to go from a wrapping animation to a one-off animation and back to the wrapping one? .getCurrentTime() doesn't return frames but some float value - how can I convert that into frames so I know when my model has hit, say, frame 80?

Thanks!

- John

For anyone else that has the RT_CLAMP problem, calling


modelJointController.setActive(true);



and then doing a new .setTimes(); solves the problem