GUI Map Generator

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:

[u]Terrain Credit[/u]

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.

This is how the map in BattleBoats! works. :slight_smile:

Oh, cool! How many frames does it have to generate, and do you compress it?

The map is 512x512 (based on terrain size). Uncompressed, it needs 91,396 frames (I exclude water), after compressing using a similar scheme to what you use, it is reduced to 2,886 frames. When minimized to the corner, it switches to a smaller version made of 618 frames.

So you’re compressing down 2,886 / 91,396 = 98.9%. Nice. That seems similar to what I would get if I made a map of terrain like that without topography shading.
So I guess that works; it’s okay to have a few thousand frames hanging around. But it’s still pretty unsettling.
One possible solution to everything might be to add a few new properties and methods to imageLabels and imageButtons, or create a new object entirely, such that pixels of the image are editable.

Yeah, something along the lines of a canvas element has been on my wish list for a long time, but the idea has not been warmly received by the Roblox developers.

I will receive it warmly.

I may use this for my game and then just take a screenshot of it and upload as decal instead of using lots of frames.

Awesome, I’m glad it’s useful. I would go with that approach, too. I would recommend turning off compression, then. It will be laggy when it does generate, but it will generate way faster, and you’ll be able to grab the screenshot quickly.

Sure will! Thanks!