Migrate TestSpatialAnim to the new Anim class

Remove all deprecated class and migrate to the new animation system.
master
Jérôme 5 years ago committed by Stephen Gold
parent fafe8a74fe
commit bd4691e06b
  1. 32
      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
AnimClip animClip = new AnimClip("anim");
animClip.setTracks(new AnimTrack[] { transformTrack, transformTrackChild });
//creating the animation // create spatial animation control
Animation spatialAnimation = new Animation("anim", animTime); AnimComposer animComposer = new AnimComposer();
spatialAnimation.setTracks(new SpatialTrack[] { spatialTrack }); animComposer.addAnimClip(animClip);
//create spatial animation control
AnimControl control = new AnimControl();
HashMap<String, Animation> animations = new HashMap<String, Animation>();
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