I don’t know if anyone has experimented with this before, but in the last two days I’ve come up with a GUI map generator that I think is pretty neat. You give it a couple of parameters, and it generates a grid of downward facing rays over your map. The color of the pixel on the map is the color of the part that the pixel’s associated ray hits.
Here’s a familiar game that I did some testing with:
By using rays, it can also determine the elevation of the point on the part it hits, so you can get a topography map:
I think that these blue artifacts are here because the polygons of the terrain don’t all come together perfectly. There are cracks in between them that causes raycasting to miss the terrain.
As you may have figured out, to make each pixel of the map, it creates an individual Frame object. That’s a problem, I know, especially if you want a decent resolution, which the first example is 800 x 800, or 640,000 individual frames. That’s probably not something you want at all.
To help with this, I also came up with a compression algorithm to combine adjacent frames of the same color into a single frame of as large of a size as possible. This is actually what I’m most proud of. For Miked’s map, compression was able to reduce the number of frames by upwards of 95%, depending on the resolution you set, which I think is pretty rad. The downside is that I’m probably not nearly as brilliant of a programmer as most of you are, so the compression code isn’t very efficient. It takes a loong time. I have some data I recorded for this that you can see in the script, but it’s definitely not code that you want a client to run. Or a server, for that matter.
So the practical application of this would be that you generate the map on your own, save it, and then use the pregenerated map in your game. However, for maps of nice resolutions, like my 800 x 800 example, 95% compression with 640k frames is still 32,000 frames, which is still a bit ridiculous. So it may be even more practical to save the map as a screenshot rather than actually saving the map Frame itself. Which, if we’re doing screenshots now, the question comes to mind, “Why not just make our maps by screenshoting our games from above?” Well, I don’t know.
Anyway, please check it out and tell me your thoughts! [u]Here’s the model.[/u] Let me know if you’ve got any ideas on how to optimize the compression process or make it generally better.