How to make an object run along a fixed path of movement

400 views
Skip to first unread message

oolongtea

unread,
Dec 4, 2009, 9:27:05 PM12/4/09
to KML Developer Support - Google Earth Plug-in
Hello everyone, I am a novice, inadvertently see the Google Earth Plug-
in. feeling so cool, I make an attempt to do something. In the
official Web site, I see an example of Google Earth Plug-in Driving
Simulator.I intend to learn the code, but found it complex and, ah,
would like to ask you master if there has an example more simple
without google map section, which is to set yourself a few path
points, and then let a car along a set path of movement within google
earth plug-in?
Message has been deleted
Message has been deleted

Nymor

unread,
Dec 5, 2009, 5:46:41 AM12/5/09
to KML Developer Support - Google Earth Plug-in
Hi,

There are quite a few examples around if you dig - all of which use
the same principle as Roman's Driving Simulator.

The core method is a combination of 2 things:-

1. An Event Listener bound to the Frameend (in most cases named the
TickListener) &
2. A TICK event that fires the actual movement of the View (and Model
if applicable).

The TICK event moves the View and when the Frameend event is fired
(when the View has changed) it fires the TICK event again .... move,
TICK, move, TICK, move, TICK etc etc.

I use this quite a few times and the simpliest example I have online
is something I use to capture the GroundAltitudes of points along a
path - so not quite what yu want - but shows the principle.

http://www.thekmz.co.uk/GEPlugin/wip/test/PathElevation/Path_Elevatio...

In this test page I just move along a path recording the altitude at
each point. The Path is stored as an Array and I start at Point[0] and
with each TICK I increment the array index by 1 - so I go from Point
[0] to Point [1} to Point[2} etc.

It's pretty basic but shows the TICKListener and TICK event without
too much else - no speed control and no moving to a coord in between
the path points.

A more complicated example involves moving along a Path and having the
view set at points between those defined in the Path array - as well
as controlling the speed at which it moves and the heading so that the
simulator is smooth.

http://www.thekmz.co.uk/GEPlugin/pathtour/v3/path_tour_v3.htm

In this example I have a Car move around the Silverstone F1 circuit.
The principle is the same but the TICK event in this case is a little
bit more complicated as it needs to work out where to move to as
opposed to just going to the next Path point as in the first example.
(There is also a small GMap in there but you can just ignore the few
lines of code that do that - they're very basic).

It doesn't take long before it gets complicated using this method but
hopefully these 2 examples will help a bit - others may post
additional examples as well and all combined should get you on your
way.

Regards
Nymor

As an aside the first example currently has the Las Vegas marathon
course as it Path as I was using that the get the ground elevation for
that course. The Las Vegas marathon is being run this weekend and can
be freely viewed at http://www.racemyrace.com/race.php?rid=45 - this
application also uses the TICK method but the code is minified for
size purposes so is difficult to read but is the same principle as the
others - but I think it shows quite well what can be achieved

oolongtea

unread,
Dec 5, 2009, 9:52:22 AM12/5/09
to KML Developer Support - Google Earth Plug-in


Thank you so much, Master Nymor.
I really appreciated it for you helping a rookie like me.
I'll try my best to learn the core method.
(A little problem,I cannot get access to the first website you
supplied.)

Nymor

unread,
Dec 5, 2009, 10:09:06 AM12/5/09
to KML Developer Support - Google Earth Plug-in
Seems to have clipped the address somehow?

Should be...
http://www.thekmz.co.uk/GEPlugin/wip/test/PathElevation/Path_Elevation.htm

Nymor

Nymor

unread,
Dec 5, 2009, 10:22:33 AM12/5/09
to KML Developer Support - Google Earth Plug-in
... oh and here's another example from the Demo Gallery..
http://earth-api-samples.googlecode.com/svn/trunk/examples/event-frameend.html

While it doesn't fly a Path as such - it moves from one location to
another - it does show the use an EventListener using Frameend well
(and simply) - along with the TICK event (in this case called
TickAnimation) - the same combination used in my examples and probably
easier to follow to get the basic idea.


Regards
Nymor

shsavage

unread,
Dec 5, 2009, 11:45:14 AM12/5/09
to KML Developer Support - Google Earth Plug-in
Here's another example, with a kml model following a track, and links
to street views...

http://gaialab.asu.edu/Metro

-Steve
Reply all
Reply to author
Forward
0 new messages