How to slow down simulation that uses tick&frameend?

39 views
Skip to first unread message

Bartek Kujda

unread,
Sep 2, 2011, 11:38:02 AM9/2/11
to google-earth-...@googlegroups.com
Hi,

I'm developing simple app that simulates path of an airplane. I am using tick&frameend method described in demo gallery. Sim is smooth but very fast, data recorded during 3minutes flight are displayed in just couple of seconds. Is there an easy way to slow down simulation? I looked at examples provided by Nymor in this thread:click, but code associated with F1 car simulator is too complex for me, can't figure out how to use TICK_SIM_MS variable and TourSimulator.prototype.tick_ function (included in path_tour.js).

Any help and advice would be appreciated!

Bartek.

Nymor

unread,
Sep 3, 2011, 8:56:34 AM9/3/11
to KML Developer Support - Google Earth Plug-in
Hi,

The F1 car simulator is quite complex because it adjusts some
variables every TICK so the car travels at realtime speeds but I have
other apps that don't do this but instead allow the user to adjust the
playback speed themselves. The trick in all of them though is how you
advance the location from one TICK to the next.

For smooth animation you can't play with the TICK frequency itself -
you just let that TICK away - but the trick is in determining where
you move to on each TICK - the closer the next location is to where
you are now the slower the animation will appear. If you just move
from one path coordinate to the next then you don't really have any
control on the speed - what you need to do is to say, for example, on
my next TICK I want to move 10m (call it tick_distance) and then
calculate the lat,lng of that point along your path and move to it ...
and keep repeating that process. Then to slow down you lower that
tick_distance and to speed up you increase it. I adjust my
tick_distance by a variable I call speed_factor which is the value the
user can increase/decrease.

So each TICK I first work out how far I wish to move (tick_distance *
speed_factor ... 10 * 0.3 = 3m for example) and then calculate the
lat,lng on the path that is 3m from where I am now and move to it etc.

By doing it this way you never actually move to any of the real coords
on your path but to incremental points along it that you calculate as
you go along.

To control the speed and still keep a smooth animation you'll have to
do some addition calculations within the TICK but they don't need to
be as complex as my F1 example.

Hope that helps
Nymor


On Sep 2, 4:38 pm, Bartek Kujda wrote:
> Hi,
>
> I'm developing simple app that simulates path of an airplane. I am using
> tick&frameend method described in demo gallery. Sim is smooth but very fast,
> data recorded during 3minutes flight are displayed in just couple of
> seconds. Is there an easy way to slow down simulation? I looked at examples
> provided by Nymor in this thread:click<https://groups.google.com/group/google-earth-browser-plugin/browse_th...>,
Reply all
Reply to author
Forward
0 new messages