[SOLVED] Jme3 Beginner: Using Cinematics to accelerate/decelerate

So I’m using Cinematics as a way to animate by reading from a trace file. Moving a spatial called “myObject” from point A to point B with a given duration is straightforward:



[java]cinematic.addCinematicEvent(0, new PositionTrack(myObject, new Vector3f(10, 0, 10), 0));[/java]



The question is how would I implement acceleration and deceleration states to that spatial movement. If the speed is not constant, the duration is not constant.





I have something like this for now:

[java]float speed_loop = speed;

float acceleration_factor = 0.0002f;

float max_speed = 6;



while(speed_loop <= max_speed)

{

cinematic.addCinematicEvent(moveEventsList.get(j).tpf, new PositionTrack(spatialToMove, new Vector3f(moveEventsList.get(j).x,

moveEventsList.get(j).y, moveEventsList.get(j).z), getDuration(speed_loop, currentLocation.distance(newLocation) ) ));

speed_loop += acceleration_factor;

//System.out.println(“SSSSSSSSSSSSSSS SPEED SSSSSSSSSSS”+ speed_loop);

}[/java]



However this makes the spatial move at a speed of 6 regardless and does not show the incremental acceleration like desired.



any ideas?

What does “speed” say it is at →



[java]float speed_loop = speed[/java]



If it’s at the maximum, that’s where I’d look. Also, what does tracing reveal?

Madjack, it’s equal to speed read from trace file (say 5m/s). and I add the acceleration factor to it. However, when it enters the while loop instead of running “x” amounts of Cinematic events it only runs one with the max_speed taken as speed_loop.

To be honest I’ve never used Cinematics, but it sounds illogical the value of “speed_loop” to change before or during the cinematic.addCinematicEvent(…) method.



At this point I’d suggest you double-check your getDuration(…) method and see if that doesn’t break your speed_loop, or simply void it. If that were to be true then the duration would be wrong, i.e. it would loop the correct number of times but you wouldn’t see anything except for the first iteration. Hopefully that makes sense to you.



As I said, I never used that, but that’s where I’d check next.

I checked getDuration() it’s working fine. It’s being called several times and as expected the duration is decreasing. However, the issue is like you said that apparently you cannot change the time during or just before a cinematic event (unless it occurs at a different trigger time). At this point I don’t know how to implement accelerate as this was my only guess.



Anyone can help?

I eventually created my own accelerateTrack as an abtract Cinematic event as recommended by @nehon. It works like a charm!



Thanks!