Quote:
Originally Posted by xtremedeniz
Hello,
Your code is perfect. I want to make a car simulation. I should give altitude of the ground not a fixed altitude. How can read current altitude of earth if i know lat/lon coordinates.
BR
Denis
|
Thanks.
There are two ways you can do this, both of which are unpretty.
The first method is to create a 1st person driving simulation.
In this case, unless they've fixed up the API in the latest release (which I haven't tested or played with yet) I think you're going to have a few problems outside of determining altitude.
I tried doing something similar to what you're looking at when I first wrote this code. So what I wanted to do was create a first person mode (like a flight simulator or pilot's view) but the problem is that they wrote the API with the intent of it being used for top-down Earth views. Because of this, you have a couple of problems:
1. There is no smooth way to transition the camera from point a to b in this situation. The movement of your transition is set by your camera transport speed. If you set it to teleport, you instantly jump to the new location, which is kind of disorienting if you're trying to simulate a smooth, 1st person view.
If you set the transport speed to anything higher than teleport, you get this annoying hop effect when traversing short distances. This is an artifact from when you transport from somewhere like California to somewhere like Egypt. In this case the camera pulls back from the Earth nice and smooth to give you a big wide shot as you fly over the surface of the globe and then closes back in to your destination. Looks really cool over a long distance; looks like hell over a short hop.
2. GE dictates that you control camera placement through several factors, only a couple of which are latitude and longitude. You also have to worry about azimuth (or heading), tilt, and distance. One of the factors that's going to cause you grief is Distance. The camera always automatically struggles to maintain its current distance from the focal point.
This works okay when looking straight down at the focal point, but when you tilt out fully, you'll notice a really stupid bug.
0 tilt means you're looking directly down at the Earth. Max tilt puts you horizontal to the ground looking out, but if the altitude of your focal point ever changes, your camera will adjust to maintain its current distance.
The worst part about this is that the Altitude track for the camera is judged to be extending out from the back of the camera, meaning that if your focal point raises in altitude and your camera is at full tilt, your camera will actually move backwards rather than lift higher off the ground (this is a bug in their API). It's easier if you look at the picture I've attached, which explains this better.
In the first series the camera is at 0 tilt. The focal point raises in altitude, so the camera automagically adjusts its distance to compensate. Not bad.
In the second series, the camera is at full tilt. the focal point raises in altitude, and the camera stupidly thinks that it can still maintain it's distance setting by moving backwards. Lame.
All of this means that not only are you going to have to know the elevation of each point on the map that you drive to (because this is a factor and it will be possible for you to disappear into the ground or become airborne), you will also have to decrease your distance setting from the focal point in proportion to any altitude gain and increase the distance setting from the focal point in proportion to and altitude drop (On the fly).
The other method is to just do the standard top down view and hug the ground rather than fly through the air (while leaving the camera stationary to avoid hopping).
Again, you're going to need to monitor your altitude so that you don't go disappearing into mountains or flying Thelma and Louise style off cliffs. I've never tried to do this, but you might look at the IPointOnTerrainGE Interface to start with. Look at the ProjectedOntoGlobe function, as it seems to be the most promising.
http://earth.google.com/comapi/inter...TerrainGE.html