Negative speed now plays an animation backwards

shader-nodes-enhancement
Nehon 7 years ago
parent 7ded33051c
commit a463f5515a
  1. 5
      jme3-core/src/main/java/com/jme3/anim/tween/action/Action.java
  2. 10
      jme3-examples/src/main/java/jme3test/model/anim/TestAnimMigration.java

@ -22,7 +22,10 @@ public abstract class Action implements Tween {
@Override @Override
public boolean interpolate(double t) { public boolean interpolate(double t) {
return subInterpolate(t * speed); t = t * speed;
// make sure negative time is in [0, length] range
t = (t % length + length) % length;
return subInterpolate(t);
} }
public abstract boolean subInterpolate(double t); public abstract boolean subInterpolate(double t);

@ -165,20 +165,14 @@ public class TestAnimMigration extends SimpleApplication {
composer.actionSequence("Sequence", composer.actionSequence("Sequence",
composer.makeAction("Walk"), composer.makeAction("Walk"),
composer.makeAction("Run"), composer.makeAction("Run"),
composer.makeAction("Jumping")).setSpeed(4); composer.makeAction("Jumping")).setSpeed(2);
action = composer.actionBlended("Blend", new LinearBlendSpace(1, 4), action = composer.actionBlended("Blend", new LinearBlendSpace(1, 4),
"Walk", "Run"); "Walk", "Run");
action.getBlendSpace().setValue(1); action.getBlendSpace().setValue(1);
composer.action("Walk").setSpeed(2); composer.action("Walk").setSpeed(-1);
// composer.actionSequence("Sequence",
// composer.tweenFromClip("Walk"),
// composer.tweenFromClip("Dodge"),
// composer.tweenFromClip("push"));
anims.addFirst("Sequence"); anims.addFirst("Sequence");
anims.addFirst("Blend"); anims.addFirst("Blend");

Loading…
Cancel
Save