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


Saturday, September 29, 2007

TerrainTool and more on Sculptie Sim Models

Sculptie Terrain Model 4

In my last post from way back in June, I mentioned that I was writing a program to help produced sculpties from sim RAW terrain files. I've been delinquent in following up on that, and to that end, have finally uploaded a copy of the TerrainTool program that will let you do this. You can find it here:

http://www.nowhere-sl.com/terraintool/

This was part of an effort to make a more full-featured terrain visualization tool in Java, which perhaps at some point will happen. In any case, it's quite useful for producing sculptie textures that can be uploaded into Second Life and used to make scale models of sim terrain.

One thing that can be useful when making these types of models, is to texture them with the actual image from the grid map. Here's a short script that will let you get that for the region you're in:


string getSimMapURL() {
string regionName = llGetRegionName();
vector rc = llGetRegionCorner();
integer regionX = (integer)(rc.x / 256);
integer regionY = (integer)(rc.y / 256);

llSay(0, "Region \"" + regionName +
"\" at: " + (string)regionX +
", " + (string)regionY);

integer mapY = 1279 - regionY;

string mapApiRestEndpoint =
"http://secondlife.com/apps/mapapi/grid/map_image/";
string mapImgUrl = mapApiRestEndpoint +
(string)regionX + "-" +
(string)mapY + "-1-0.jpg";

llSay(0, "Map Image URL: " + mapImgUrl);

return mapImgUrl;
}

default {

state_entry()
{
llSetText("Click me to get the Map URL for the current region",
<1,0,0>, 1.0);
}

touch_start(integer total_number)
{
getSimMapURL();
}
}


Simply drop that script into a prim, click on it, and you'll get an image URL like this:

http://secondlife.com/apps/mapapi/grid/map_image/926-344-1-0.jpg

Following that URL will take you to the actual image from the grid map, which should look something like this:



Simply save that image and upload it as a texture into SL, and you can apply it to your scupltie sim model.

Saturday, June 16, 2007

Making Region Sim Models Using Sculpties

Check out these pictures of the scale model of the Nowhere sim that I made using sculpties. Turns out it's not too difficult to create a sculptie texture using the region RAW file and Photoshop. I'll post detailed instructions for doing this by hand as well as a tool for automatically generating these soon.

Sculptie Terrain Model 4

Sculptie Terrain Model 3

Sculptie Terrain Model 2

Sculptie Terrain Model 1

Tuesday, June 12, 2007

Open-Sourcing my Update Server scripts

I posted the code for the update server I use to update the teleport pads on Nowhere on the Second Life Wiki. I use AubreTec Teleport Pads for teleporting between locations in the sim, and I've been quite happy with them. The problem is that the pads are configured with two notecards, one of which contains the locations and the other than contains authorized users. Whenever I add a friend to the list of authorized users or add a new teleport pad, I need to visit each pad and copy new notecards in, which gets pretty tedious. Since necessity is the mother of invention, I wrote up an update server which distributes these new notecards automatically. I later started using this system for updating Freeview screens and anything else that gets configured this way. You can find the code on the Second Life Wiki at the following link:

Intra-Region Update Server

Hope you find it useful!

Thursday, May 17, 2007

Emma vs. the Subway


Emma vs. the Subway
Originally uploaded by Emma Nowhere.
I meant to post this earlier... I took this picture at Downtown on the day it opened to the public. I can't say enough how beautifully crafted this place is, or to do justice to the emotions it provokes in those who visit it. I really wish I'd saved this picture to disk as a high resolution file rather than as a 512x512 texture, but I still love it. I really wasn't sure what would happen when the car hit...

Monday, May 14, 2007

Twittering from SL

I've read a number of blog posts by Ordinal Malaprop, Kisa Naumova and others about using Twitter from SL. Very cool stuff! The great thing about Twitter, from a scripting standpoint, is that if you just want to do updates from within Second Life, you can do it with just a few lines of LSL code and post directly to the Twitter servers. Here's a simple example that I hope you'll find useful:


//put your Twitter username and password here
string twitter_user = "";
string twitter_pass = "";

updateTwitter(string update) {
if ((twitter_user != "") && (twitter_pass != "")) {
string url = "http://" + twitter_user +
":" + twitter_pass +
"@twitter.com/statuses/update.xml";
llHTTPRequest(url, [HTTP_METHOD, "POST",
HTTP_MIMETYPE,
"application/x-www-form-urlencoded"],
"status=" + llEscapeURL(update));
}
}

default {

state_entry() {
}

touch_start(integer num_detected) {
updateTwitter("Hello from LSL");
}

http_response(key request_id,
integer status,
list metadata,
string body) {
//always returns a 415 error
//unless it fails, in which case
//a 500 error is returned
}

}

Construction Time Again

Just a quick update - I'm starting planning on the companion sim to Nowhere. Looking at coastlines in Google Images for inspiration and I've been privileged enough to visit and live in few interesting tropical locales in RL. Thematically it will be very similar to Nowhere, with my signature landscaping techniques, such as gently sloping coastlines, private bays, and natural mountains. I'll post more details as the plan gels.

I'm also hoping to make some progress on finishing the Lost Hatch (aka Dharma Initiative Swan Station) skybox build that I started on so long ago.

hatch work-in-progress 6

Lost Hatch Test Textures 1

The layout has been done for months, except for a few details, it just needs to be textured, which is unfortunately outside of my skill set.

In my quest to better learn texturing, I did read the excellent book 3D Game Textures: Create Professional Game Art Using Photoshop by Luke Ahearn. While it will take more than even a wonderful'y written book such as this to impart graphic design skills on someone like me, it at least helped to explain to me how places such as Downtown can look so amazing. I recommend it to anyone who's trying their hand at building anything in Second Life since good texturing is so often what makes the difference between good and great in anything in-world. One point that the book makes, but which is even more important in SL, is the size of textures. If you're using textures that are greater than 512x512, and you've got several of them in a build, you ARE going to be making life difficult for people who don't have higher-end graphics cards who will experience render lag, which they'll probably incorrectly attribute to your sim or SL. Many SL users aren't PC gamers with the latest and greatest hardware, so pay attention to texture size and please use smaller textures when possible.