|
@@ -59,15 +59,15 @@ public class MotionPath implements Savable {
|
|
|
private Node debugNode;
|
|
private Node debugNode;
|
|
|
private AssetManager assetManager;
|
|
private AssetManager assetManager;
|
|
|
private List<MotionPathListener> listeners;
|
|
private List<MotionPathListener> listeners;
|
|
|
- private Spline spline = new Spline();
|
|
|
|
|
- private float eps = 0.0001f;
|
|
|
|
|
|
|
+ private Spline spline = new Spline();
|
|
|
|
|
+ int prevWayPoint = 0;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* Create a motion Path
|
|
* Create a motion Path
|
|
|
*/
|
|
*/
|
|
|
public MotionPath() {
|
|
public MotionPath() {
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* interpolate the path giving the time since the beginnin and the motionControl
|
|
* interpolate the path giving the time since the beginnin and the motionControl
|
|
|
* this methods sets the new localTranslation to the spatial of the motionTrack control.
|
|
* this methods sets the new localTranslation to the spatial of the motionTrack control.
|
|
@@ -89,19 +89,29 @@ public class MotionPath implements Savable {
|
|
|
//setting values
|
|
//setting values
|
|
|
control.setCurrentWayPoint((int) v.x);
|
|
control.setCurrentWayPoint((int) v.x);
|
|
|
control.setCurrentValue(v.y);
|
|
control.setCurrentValue(v.y);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
//interpolating new position
|
|
//interpolating new position
|
|
|
getSpline().interpolate(control.getCurrentValue(), control.getCurrentWayPoint(), temp);
|
|
getSpline().interpolate(control.getCurrentValue(), control.getCurrentWayPoint(), temp);
|
|
|
if (control.needsDirection()) {
|
|
if (control.needsDirection()) {
|
|
|
tmpVector.set(temp);
|
|
tmpVector.set(temp);
|
|
|
control.setDirection(tmpVector.subtractLocal(control.getSpatial().getLocalTranslation()).normalizeLocal());
|
|
control.setDirection(tmpVector.subtractLocal(control.getSpatial().getLocalTranslation()).normalizeLocal());
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ checkWayPoint(control);
|
|
|
|
|
+
|
|
|
control.getSpatial().setLocalTranslation(temp);
|
|
control.getSpatial().setLocalTranslation(temp);
|
|
|
vars.release();
|
|
vars.release();
|
|
|
return traveledDistance;
|
|
return traveledDistance;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public void checkWayPoint(MotionTrack control) {
|
|
|
|
|
+ if (control.getCurrentWayPoint() != prevWayPoint) {
|
|
|
|
|
+ if (control.getCurrentValue() >= 0f && control.getCurrentValue() < 0.01) {
|
|
|
|
|
+ triggerWayPointReach(control.getCurrentWayPoint(), control);
|
|
|
|
|
+ prevWayPoint = control.getCurrentWayPoint();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void attachDebugNode(Node root) {
|
|
private void attachDebugNode(Node root) {
|
|
|
if (debugNode == null) {
|
|
if (debugNode == null) {
|
|
|
debugNode = new Node();
|
|
debugNode = new Node();
|