Migrate TestBlenderAnim to the new anim system

Migrate to the new animation system, migration of old Spatial object containing animation and adding method to list all animation name in AnimComposer.
master
Jérôme 5 years ago committed by Stephen Gold
parent 11d3bc67f8
commit 1433f98ad3
  1. 24
      jme3-examples/src/main/java/jme3test/model/anim/TestBlenderAnim.java

@ -32,8 +32,9 @@
package jme3test.model.anim;
import com.jme3.animation.AnimChannel;
import com.jme3.animation.AnimControl;
import com.jme3.anim.AnimClip;
import com.jme3.anim.AnimComposer;
import com.jme3.anim.util.AnimMigrationUtils;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.BlenderKey;
import com.jme3.light.DirectionalLight;
@ -45,9 +46,6 @@ import com.jme3.scene.Spatial;
public class TestBlenderAnim extends SimpleApplication {
private AnimChannel channel;
private AnimControl control;
public static void main(String[] args) {
TestBlenderAnim app = new TestBlenderAnim();
app.start();
@ -70,18 +68,22 @@ public class TestBlenderAnim extends SimpleApplication {
rootNode.attachChild(scene);
Spatial model = this.findNode(rootNode, "BaseMesh_01");
AnimMigrationUtils.migrate(model);
model.center();
control = model.getControl(AnimControl.class);
channel = control.createChannel();
channel.setAnim("run_01");
AnimComposer animComposer = model.getControl(AnimComposer.class);
animComposer.getAnimClips().forEach(animClip -> System.out.println("AnimClip name: " + animClip.getName()));
AnimClip animClip = animComposer.getAnimClip("run_01"); // run_sideway_left, aim, run_sideway_right, base_stand, run_01, base, jump
animComposer.setCurrentAction(animClip.getName());
}
/**
* This method finds a node of a given name.
* @param rootNode the root node to search
* @param name the name of the searched node
*
* @param rootNode
* the root node to search
* @param name
* the name of the searched node
* @return the found node or null
*/
private Spatial findNode(Node rootNode, String name) {

Loading…
Cancel
Save