Sunday, November 25, 2007

Painting on the Second Life Map with Prims

If you look at the Second Life Map, you often can see designs and text on the various regions. In most cases, these are fairly primitive - simple block lettering or geometric shapes. The map is updated on a weekly basis by a program at LindenLab that first creates a picture of the terrain detail using terrain elevation and terrain textures and then looks at the prims that are below approximately 400 meters in altitude. In order to make it harder to put things on the map, though, this program only looks at the color data of the prims as well as reducing the entire texture to a single color value, so, for example, a 10x10 cube will only appear as a single color when it renders on the map. Putting a megaprim up with a photographic texture will only result in large monochromatic shape.

So, how do people manage to put more complicated designs onto the map? The answer is that they construct the image out individual colored prims arranged into whatever design they want to repesent. There are some very nice examples of this out there, but they tend to be the result of a lot of work by determined individuals.

After some thought, I realized that you could automate the process, and after a lot of hair-pulling, figured out how to do it. Here are some pictures of the results of that effort:

Painting with prims 1

Painting with prims 2

And, if you want to see an example of this on the map, look here (click on it to go to the SLurl map page):

Super Calamari on Dynamism region

Now, to see how these pictures were actually rezzed in-world, here's a video I made of the process:



Figuring out how this could be done turned out the be the easy part, implementing it was considerably harder. First of all, using a single prim for every color "pixel" would have used too many prims for this to be practical. Luckily, the answer came from the popular XYText script, which uses a technique of flattening prisms to create a rectangular shape with 5 upward facing surfaces, allowing 5 pixels of color to be displayed per prim.

The second challenge was how to get the color information into Second Life. The goal was to make this easy enough that anyone with an image in any of the standard file formats (GIF, JPG, PNG, BMP), could turn these into a MapPainting. Writing a Java application to take these images and turn them into textual data that LSL could work with was largely straightforward. Unfortunately, the result was still enough information to fill several notecards. The first version of the project simple wrote out a set of textfiles which the user could copy and past into a notecard within the Second Life viewer. This proved cumbersome for the testers, all of whom were fairly sophisticated SL residents. The solution was to turn the desktop application into a web application, and simply allow people to upload their image onto the NowhereVirtual.com web site. The in-world scripts connect to the web application which feeds them exactly the data they need. The result is a much simpler process, the user simply uploads an image on a web page, clicks "Rez" from an in-world menu and away you go.

The final challenge was how to rez this many prims this quickly, given that LSL automatically slows down the scripted creation of new prims to make griefer scripts less effective. We'll keep the solution to that problem a trade secret for now. ;-)

The final product, MapPainter, is available in two versions, the full version which can fill a sim, and the lite version, that will fill a 4,096 square meter parcel. You can purchase it in-world or on SLExchange and OnRez:

MapPainter at SLExchange
MapPainter at OnRez
Nowhere Virtual Ministore

For more information, visit the Nowhere Virtual website:

MapPainter Product Page at Nowhere Virtual
MapPainter Documentation Page at Nowhere Virtual


1 comments:

Nisei Oh said...

Wow! Really nice, amazing!
But is needed lot of prims and lot of land, lol.
Thanks for oyur interesting blog.
Please, dont stop post, is one of the best!!Go on posting please :_(

Thanks again!