Jme3 Beginner: Accelerate and Decelerate a spatial

Greetings,



I move my spatial using



[java]public void moveSpatial(float tpf, String type, String id, float speed, float x, float y, float z) {



end = new Vector3f (x,y,z);

start = cube.getLocalTranslation();



scale += tpf/10; //this will make it take 10 seconds to reach the end, from the the start

Vector3f newLocation = FastMath.interpolateLinear(scale, start, end);



cube.setLocalTranslation(newLocation); /// cube is my spatial



if(scale >= 1) //then you reached the end/destination

{

isMoving = false;

}

}[/java]



How would I change that to accelerate/decelerate???

What about making your 10 an instance variable, then change it with an accelerate or decelerate method?

Squeegeeman thanks for the response.



The issue is that my speed is not constant :S it accelerates and decelerates. I also tried using Cinematics, and same thing if I create a move event:



[java] cinematic.addCinematicEvent(0, new PositionTrack(teapot, new Vector3f(10, 0, 10), <strong>DURATION</strong>));[/java]



So it’s always in duration. It’s not easy to get the duration (or I would say not feasible) if the speed is not constant.

anyone can help me with this?