Package org.pollux3d.motion

Source Code of org.pollux3d.motion.ShipMotionTrack

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);
   
  }
}
TOP

Related Classes of org.pollux3d.motion.ShipMotionTrack

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.