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.
This commit is contained in:
parent
11d3bc67f8
commit
1433f98ad3
@ -32,8 +32,9 @@
|
|||||||
|
|
||||||
package jme3test.model.anim;
|
package jme3test.model.anim;
|
||||||
|
|
||||||
import com.jme3.animation.AnimChannel;
|
import com.jme3.anim.AnimClip;
|
||||||
import com.jme3.animation.AnimControl;
|
import com.jme3.anim.AnimComposer;
|
||||||
|
import com.jme3.anim.util.AnimMigrationUtils;
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
import com.jme3.asset.BlenderKey;
|
import com.jme3.asset.BlenderKey;
|
||||||
import com.jme3.light.DirectionalLight;
|
import com.jme3.light.DirectionalLight;
|
||||||
@ -45,9 +46,6 @@ import com.jme3.scene.Spatial;
|
|||||||
|
|
||||||
public class TestBlenderAnim extends SimpleApplication {
|
public class TestBlenderAnim extends SimpleApplication {
|
||||||
|
|
||||||
private AnimChannel channel;
|
|
||||||
private AnimControl control;
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
TestBlenderAnim app = new TestBlenderAnim();
|
TestBlenderAnim app = new TestBlenderAnim();
|
||||||
app.start();
|
app.start();
|
||||||
@ -70,18 +68,22 @@ public class TestBlenderAnim extends SimpleApplication {
|
|||||||
rootNode.attachChild(scene);
|
rootNode.attachChild(scene);
|
||||||
|
|
||||||
Spatial model = this.findNode(rootNode, "BaseMesh_01");
|
Spatial model = this.findNode(rootNode, "BaseMesh_01");
|
||||||
|
AnimMigrationUtils.migrate(model);
|
||||||
model.center();
|
model.center();
|
||||||
|
|
||||||
control = model.getControl(AnimControl.class);
|
AnimComposer animComposer = model.getControl(AnimComposer.class);
|
||||||
channel = control.createChannel();
|
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
|
||||||
channel.setAnim("run_01");
|
animComposer.setCurrentAction(animClip.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method finds a node of a given name.
|
* 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
|
* @return the found node or null
|
||||||
*/
|
*/
|
||||||
private Spatial findNode(Node rootNode, String name) {
|
private Spatial findNode(Node rootNode, String name) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user