package org.pollux3d.motion;
import com.jme3.cinematic.events.MotionTrack;
import com.jme3.math.Quaternion;
import com.jme3.scene.Spatial;
public class ShipMotionTrack extends MotionTrack {
ShipMotionPath shipMotionPath;
public ShipMotionTrack(Spatial spatial, ShipMotionPath path){
super(spatial, path);
shipMotionPath = path;
}
public void onUpdate(float tpf) {
super.onUpdate(tpf);
float lr = shipMotionPath.getRotation(this.currentWayPoint);
float cr = shipMotionPath.getRotation(this.currentWayPoint+1);
float rotation = lr + ((cr - lr) * currentValue);
Quaternion r = new Quaternion().fromAngles(0, 0, rotation);
spatial.rotate(r);
}
}