Jump to content

Coordinate Grid


AltarofScience

Recommended Posts

I am making a universe, and I need a map display, so players can navigate it. Technically, you can cut the size down, by displaying only portions of the map, so I think a 2d array might work.

You could have the display set to like, show a 10kby10k or 1k by 1k sector of the map. or something.

Say you are at a star system and want to see nearby star systems. you would set the display so the coords of that system are at the center, and display: currentx-1000 to currentx+1000 on the x axis and currenty-1000 to currentx+1000 on the y axis. that would only be 4million possible points. and only like, 10 or 20 star systems would actually exist there.

 

i think some people use vrml maps for this kind of thing? when i was googling i got some vrml results. i mean, technically each ordered pair would also have a z coordinate, but i might not use z if it make its too complicated for me to code.

Link to comment
Share on other sites

Google does this by only selecting subsets of the data and by storing zoom versions which are calculated periodically.

 

The rest of this post assumes your universe (like the real one) will be very sparsely populated.

 

You will need a sparse matrix setup for one thing.  You cannot create 40,000,000,000 empty data points, it just won't work.

 

You will need a table for each zoom level.  Start at the bottom.  Make a table which contains X, Y, and VALUE (or whatever, I'm just summarizing for effect).

 

Then make a table for the first "zoom out".  Write a script that translates every 10x10 grid space on your board to a single pixel.  If there is any data inside the range 0 < X < 10, 0 < Y < 10 then put a piece of data in for 1,1 in the first zoom level.  Repeat until you have the entire zoom-out map made. 

 

Now, repeat this for enough zoom levels to be usable.  You will end up with a map where each data point represents "do any of the 1,000,000 data points inside this point have any data at all?"  Once you have that, you can print it very easily (as it will fit on a monitor).

 

Now, once the user clicks on this map, figure out where he clicked (simple exercise left up to you) and where in the data he clicked, then load the next zoom level IN for where he clicked, centered around the pixel he clicked on.  The pixel he clicked on will now be blown up to a 10x10 area of the next zoom level.

 

Using the above method you'll have 1 "real" data table with X "interpreted" data tables above it representing all the possible zoom levels you support.  The users can zoom in and out and even pan through the current zoom level without sacrificing performance.

 

This is nearly exactly the way google maps works, except instead of a single VALUE point (or colored pixel) they obviously have full scale PNG images all knitted together.  That's much more difficult, but it's the same theory.  They use a lot more calculus to do this than I did.

 

-Dan

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.