|
1 | 1 | package jme3test.model.anim; |
2 | 2 |
|
3 | | -import com.jme3.animation.AnimControl; |
4 | | -import com.jme3.animation.Animation; |
5 | | -import com.jme3.animation.SpatialTrack; |
| 3 | +import com.jme3.anim.AnimClip; |
| 4 | +import com.jme3.anim.AnimComposer; |
| 5 | +import com.jme3.anim.AnimTrack; |
| 6 | +import com.jme3.anim.TransformTrack; |
6 | 7 | import com.jme3.app.SimpleApplication; |
7 | 8 | import com.jme3.light.AmbientLight; |
8 | 9 | import com.jme3.light.DirectionalLight; |
|
11 | 12 | import com.jme3.scene.Geometry; |
12 | 13 | import com.jme3.scene.Node; |
13 | 14 | import com.jme3.scene.shape.Box; |
14 | | -import java.util.HashMap; |
15 | 15 |
|
16 | 16 | public class TestSpatialAnim extends SimpleApplication { |
17 | 17 |
|
@@ -66,22 +66,20 @@ public void simpleInitApp() { |
66 | 66 | rotations[i] = Quaternion.IDENTITY; |
67 | 67 | scales[i] = Vector3f.UNIT_XYZ; |
68 | 68 | } |
69 | | - SpatialTrack spatialTrack = new SpatialTrack(times, translations, rotations, scales); |
70 | | - |
71 | | - //creating the animation |
72 | | - Animation spatialAnimation = new Animation("anim", animTime); |
73 | | - spatialAnimation.setTracks(new SpatialTrack[] { spatialTrack }); |
74 | | - |
75 | | - //create spatial animation control |
76 | | - AnimControl control = new AnimControl(); |
77 | | - HashMap<String, Animation> animations = new HashMap<String, Animation>(); |
78 | | - animations.put("anim", spatialAnimation); |
79 | | - control.setAnimations(animations); |
80 | | - model.addControl(control); |
| 69 | + TransformTrack transformTrack = new TransformTrack(geom, times, translations, rotations, scales); |
| 70 | + TransformTrack transformTrackChild = new TransformTrack(childGeom, times, translations, rotations, scales); |
| 71 | + // creating the animation |
| 72 | + AnimClip animClip = new AnimClip("anim"); |
| 73 | + animClip.setTracks(new AnimTrack[] { transformTrack, transformTrackChild }); |
| 74 | + |
| 75 | + // create spatial animation control |
| 76 | + AnimComposer animComposer = new AnimComposer(); |
| 77 | + animComposer.addAnimClip(animClip); |
81 | 78 |
|
| 79 | + model.addControl(animComposer); |
82 | 80 | rootNode.attachChild(model); |
83 | | - |
84 | | - //run animation |
85 | | - control.createChannel().setAnim("anim"); |
| 81 | + |
| 82 | + // run animation |
| 83 | + model.getControl(AnimComposer.class).setCurrentAction("anim"); |
86 | 84 | } |
87 | 85 | } |
0 commit comments