Migrate TestSpatialAnim to the new Anim class

Remove all deprecated class and migrate to the new animation system.
v3.3
Jérôme 5 years ago committed by Stephen Gold
parent 21cbdb5da3
commit 68c6f71c73
  1. 36
      jme3-examples/src/main/java/jme3test/model/anim/TestSpatialAnim.java

@ -1,8 +1,9 @@
package jme3test.model.anim; package jme3test.model.anim;
import com.jme3.animation.AnimControl; import com.jme3.anim.AnimClip;
import com.jme3.animation.Animation; import com.jme3.anim.AnimComposer;
import com.jme3.animation.SpatialTrack; import com.jme3.anim.AnimTrack;
import com.jme3.anim.TransformTrack;
import com.jme3.app.SimpleApplication; import com.jme3.app.SimpleApplication;
import com.jme3.light.AmbientLight; import com.jme3.light.AmbientLight;
import com.jme3.light.DirectionalLight; import com.jme3.light.DirectionalLight;
@ -11,7 +12,6 @@ import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry; import com.jme3.scene.Geometry;
import com.jme3.scene.Node; import com.jme3.scene.Node;
import com.jme3.scene.shape.Box; import com.jme3.scene.shape.Box;
import java.util.HashMap;
public class TestSpatialAnim extends SimpleApplication { public class TestSpatialAnim extends SimpleApplication {
@ -66,22 +66,20 @@ public class TestSpatialAnim extends SimpleApplication {
rotations[i] = Quaternion.IDENTITY; rotations[i] = Quaternion.IDENTITY;
scales[i] = Vector3f.UNIT_XYZ; scales[i] = Vector3f.UNIT_XYZ;
} }
SpatialTrack spatialTrack = new SpatialTrack(times, translations, rotations, scales); TransformTrack transformTrack = new TransformTrack(geom, times, translations, rotations, scales);
TransformTrack transformTrackChild = new TransformTrack(childGeom, times, translations, rotations, scales);
//creating the animation // creating the animation
Animation spatialAnimation = new Animation("anim", animTime); AnimClip animClip = new AnimClip("anim");
spatialAnimation.setTracks(new SpatialTrack[] { spatialTrack }); animClip.setTracks(new AnimTrack[] { transformTrack, transformTrackChild });
//create spatial animation control // create spatial animation control
AnimControl control = new AnimControl(); AnimComposer animComposer = new AnimComposer();
HashMap<String, Animation> animations = new HashMap<String, Animation>(); animComposer.addAnimClip(animClip);
animations.put("anim", spatialAnimation);
control.setAnimations(animations);
model.addControl(control);
model.addControl(animComposer);
rootNode.attachChild(model); rootNode.attachChild(model);
//run animation // run animation
control.createChannel().setAnim("anim"); model.getControl(AnimComposer.class).setCurrentAction("anim");
} }
} }

Loading…
Cancel
Save