Understanding channels and AnimationTrack

Hello,



I am trying to switch my deprecated code (PositionTrack, RotationTrack, etc) to AnimationTrack. Using the examples in the wiki I got something running but I have a bug that I can’t figure out as I don’t have a good grasp on the idea. I was wondering if anyone could explain it to me. I already looked at: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:beginner:hello_animation?s[]=animation but I don’t understand the concept of controller and channel quite well.



I am trying to read a trace file where every time I find the word “coast” the car moves at a linear speed (e.g. coast car1 pos(5,0,0) dur(10secs)), therefore I wrote the following function:



[java]

public void coastCar(String id, float trigger_time, float x, float y, float z, float duration) {

// current event’s drive called

final Spatial spatialToMove = rootNode.getChild(id);



AnimationFactory factory = new AnimationFactory(duration, “coast”);



factory.addTimeTranslation(duration, new Vector3f(x, y, z));



AnimControl control = new AnimControl();

control.addAnim(factory.buildAnimation());

spatialToMove.addControl(control);



AnimChannel channel = spatialToMove.getControl(AnimControl.class).createChannel(); // I had to add this as I was getting a NULL ptr in AnimationTrack.java





control.addAnim(factory.buildAnimation());



cinematic.addCinematicEvent(trigger_time, new AnimationTrack2(spatialToMove, “coast”, channel)); // same thing I had to overload AnimatTrack to force it to get channel

[/java]



So this code runs however if I had two consecutive events at two different times ex:

time 0.0: car drive to point (10,0,0) dur(10secs)

time 10.0: car drive to point(0,0,0) dur(10secs)



what happens is that the car drives to (10,0,0) then at time 10 the animation as if resettings makes the car drive from point 0,0,0 to 10,0,0 again.



I need to understand what I am doing wrong with the channels.



thanks

anyone??