From 1b1bad7da55f2e59b8c9c08bdf3f9fc1ccb2bea0 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Sat, 24 Dec 2011 14:18:41 +0000 Subject: [PATCH] Fixed MotionTrack setEnabled method git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8954 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../jme3/cinematic/events/MotionTrack.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/engine/src/core/com/jme3/cinematic/events/MotionTrack.java b/engine/src/core/com/jme3/cinematic/events/MotionTrack.java index 6ffd7bac4..1ec0f3ad0 100644 --- a/engine/src/core/com/jme3/cinematic/events/MotionTrack.java +++ b/engine/src/core/com/jme3/cinematic/events/MotionTrack.java @@ -69,13 +69,11 @@ public class MotionTrack extends AbstractCinematicEvent implements Control { protected Direction directionType = Direction.None; protected MotionPath path; private boolean isControl = true; - /** * the distance traveled by the spatial on the path */ protected float traveledDistance = 0; - /** * Enum for the different type of target direction behavior */ @@ -184,17 +182,17 @@ public class MotionTrack extends AbstractCinematicEvent implements Control { @Override public void setTime(float time) { - super.setTime(time); - + super.setTime(time); + //computing traveled distance according to new time traveledDistance = time * (path.getLength() / initialDuration); - + TempVars vars = TempVars.get(); Vector3f temp = vars.vect1; //getting waypoint index and current value from new traveled distance Vector2f v = path.getWayPointIndexForDistance(traveledDistance); //setting values - currentWayPoint = (int)v.x; + currentWayPoint = (int) v.x; setCurrentValue(v.y); //interpolating new position path.getSpline().interpolate(getCurrentValue(), getCurrentWayPoint(), temp); @@ -202,8 +200,6 @@ public class MotionTrack extends AbstractCinematicEvent implements Control { spatial.setLocalTranslation(temp); vars.release(); } - - public void onUpdate(float tpf) { traveledDistance = path.interpolatePath(time, this); @@ -220,7 +216,7 @@ public class MotionTrack extends AbstractCinematicEvent implements Control { } else { stop(); } - } + } } @Override @@ -434,7 +430,11 @@ public class MotionTrack extends AbstractCinematicEvent implements Control { } public void setEnabled(boolean enabled) { - play(); + if (enabled) { + play(); + } else { + pause(); + } } public boolean isEnabled() { @@ -451,7 +451,7 @@ public class MotionTrack extends AbstractCinematicEvent implements Control { public Spatial getSpatial() { return spatial; } - + /** * return the distance traveled by the spatial on the path * @return @@ -459,6 +459,4 @@ public class MotionTrack extends AbstractCinematicEvent implements Control { public float getTraveledDistance() { return traveledDistance; } - - }