XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

implement geographic coordinate system

Last post 11/14/2009 6:13 PM by jwatte. 3 replies.
  • 11/14/2009 6:42 AM

    implement geographic coordinate system

    hi.
    need some help.
    working on 2d game, something and my screen looks similar to radar screen, with simple zooming and moving the camera.
    i have a problem.
    i need to draw land masses and state borders, which i have all but written in geographic coordinate system. so basicly all I need to do is draw a line from one point to another which would give me the layout.
    The problem is how to transform this into XNA coordinate system.
    What is the best formula?
    thanx
  • 11/14/2009 10:05 AM In reply to

    Re: implement geographic coordinate system

    By "geographic coordinate system", do you mean longitude and latitude? Longitude and latitude are basically the same as X and Y (respectively), with (0, 0) located at the intersection of the equator and the prime meridian. If you mean something else, could you be a little more specific, perhaps give a sample of what your data looks like defining the landmasses/borders?
  • 11/14/2009 5:10 PM In reply to

    Re: implement geographic coordinate system

    Anyone working with maps further in the north or south will tell you that mapping longitude and latitude coordinates to a plane is not so simple.

    spherical projection mapping has always been a difficult and artifact riddled mess. The best solution is usually a cube map.

    But for the pupose of the thread what you could do at every rendering is place objects acording to their spherical positions projected onto the screen (of course skipping the back facing locations) simply rotate the objects according to their 3d location on the sphere to move the view around.
  • 11/14/2009 6:13 PM In reply to

    Re: implement geographic coordinate system

    What projection do you want to use? Generally, play areas are small enough that a Mercator style projection is good (a la UTM). If you're close enough to the Equator, you can even go to cylindrical projection, where you simply say latitude * scale == Y and longitude * scale == X.
    If you want a planar projection around point X,Y,Z (the "center" of the screen), then you create a matrix that points east/up/south at that position. Then you invert that matrix, and transform each point by that matrix. Finally, you pull out the X and Z coordinates; that's your "right" and "down" values in screen space.
    Sadly, because the Earth is compressed, the latitudes are not just a simple sin/cos formula, because 45 degrees latitude is not 45 degrees up from center of Earth; it's the point at which the Earth's normal points 45 degrees away from the equator plane. If you can live without compensating for that (it's about 1/300th in compression along the north/south axis), then you can just plug lat/lon as polar coordinates into sin and cos to get the X,Y,Z, and project them through your chosen projection.
    Jon Watte, Direct3D MVP
    Tweets, occasionally
    kW X-port 3ds Max .X exporter
    kW Animation source code
Page 1 of 1 (4 items) Previous Next