Wednesday, July 25, 2007

Why was I not told this?

You can put a script into a prim without having it automatically start running, by holding down the CTRL key as you drag it from your inventory.

Monday, July 23, 2007

Yet More Schedule Stuff

In between working on classes (I'm up to five now; the latest one will debut Thursday evening, and will cover dialogs, link messages, HTTP and XML-RPC communication), I've been back at work on more schedule stuff.

My latest device is a HUD for students, showing the next five classes scheduled to be taught at Rockcliffe:


Unfortunately, for the text to be readable, it does have to take up a hefty amount of screen space, so the Rockcliffe logo serves as a minimize/restore button:


Features include:

  • "Class Info" buttons cause it to tell its owner more information about the selected class (full class name, date and time, teacher's name, location, duration, etc.)
  • "Teleport!" buttons bring up the Map screen, with the classroom location selected
  • The green "?" button delivers a notecard with usage information
  • The "Preferences" button brings up a dialog with several options:
    • Alarms On - causes the HUD to play a sound and pop up a dialog indicating that one or more classes will be starting in ten to fifteen minutes (and identifying which classes)
    • Alarms Off - suppresses the class notification
    • TP to RUSLC - brings up the Map screen, with Rockcliffe's reception area selected
    • RU Website - Loads the Rockcliffe University Web site into the user's browser
    • Schedule - Loads the Rockcliffe class schedule into the user's browser
But the stuff that was the most fun to do is all behind the scenes:
  • Checks the schedule about once every five minutes
  • If a new version is released, the HUD is automatically updated the next time the user visits the Rockcliffe sim
  • All the hardcoded URLs (the location the script the HUD communicates with to download the schedule, the Rockcliffe Web site, and the schedule Web page) can be changed by the server-side script without requiring a full update, in case of a site move, page relocation, etc.
  • When downloading the schedule, it passes version information to the server-side script, so that new features may be implemented without breaking older versions of the HUD
One of these days, I will actually finish building my house and make more jewelry...

Monday, June 25, 2007

Fun fun fun!

In between business trips and sickness, I've had precious little SL time lately. And what time I've had has been spent on Rockcliffe University.

First, I've been developing and teaching classes in scripting (three have been completed, and I'm nearly done with the fourth). It's shocking how much time it takes to come up with one class; even though I've already got the first twelve classes outlined, there's lecture text to write (and proofread, and verify to make sure every sentence is accurate), examples to script and test, "Powerpoint" slides to create. And then go through the lecture a couple of times and try to anticipate students' questions, then rework the text to preemptively answer them...

But since I can't really play in Second Life while I'm on a trip (I tried once, and my laptop overheated and killed the master boot record of the hard drive, so I won't be doing that again!), I've been working on the class scheduling application, which has been a lot of fun to do.



We're getting a dedicated server set up, which will run a whole bunch of off-the-shelf software (Moodle, forums, etc.), but I developed a customized scheduling database in MySQL, with a PHP frontend. This will display the upcoming schedule in several formats (the simple list as shown here, a calendar view, an RSS feed, etc.), and permits the teachers to post and modify their own classes. But where it really shines is in its communication with Second Life.



First, it automatically updates an in-world schedule board. Classes will disappear from the board fifteen minutes after they've started, and as new classes are added to the database, they appear on the schedule board. Unless explicitly overridden, each class displays in an alternating color to make it easier to read the board. After a week or so of testing, I'll be able to replace the current version in the reception area with the new auto-update board. Another improvement is in primmage: the new board has 33% more characters (80x24, as opposed to 72x20), while still reducing the number of prims by about 20%.

Another component which I'm working on now is a smaller board which displays the names of the classes currently in progress, with a "Teleport!" button to take a student directly to the classroom. Other components will include classroom detectors which send the list of students to the database, to keep track of attendance; and tip jars which record the amounts given during a specific class (for sharing the tips between the university and the individual teachers).

All this is accomplished with the HTTP and XML-RPC functions of the Linden Scripting Language (which will be the subject of one of the classes in my scripting course).

Maybe one of these days, I'll have enough free time to actually build a house on the land I'm renting!

Wednesday, June 13, 2007

Hate Voice?

Switch to Linux!

Not only is there no Linux voice-enabled client, but the Lindens steadfastly ignore anyone who comments on the official blog to ask about when we'll get one.

Thursday, May 24, 2007

...Sculpted jewelry!

A really simple set to start out with, while I design more complex things.


The necklace and the earrings, following my tradition, are scripted so the gem and metal colors can be independently changed. The sculpted heart has my usual nine colors: amethyst, blue topaz, citrine, diamond, emerald, garnet, ruby, sapphire and topaz.


And I finally have a better store location, on Flotsam Beach. Part of what makes it better is that I can actually make landmarks and SLURLs which teleport directly there. Also it's bigger, it's not stuck in the back corner of a mall with little foot traffic, and it's in a beautiful new themed sim (an Atlantic beach resort).

I have to design up a nice floor plan, but until that's done I've just stuck vendor boxes on the walls.

Thursday, May 10, 2007

More sculpted gemstones

...and I get back to my Linux machine to discover that they still don't have voice chat in Linux!

Oh well, at least I can play with the sculpted prims on a decent machine for now. I know gemstones are a trivial example of what's possible with sculpted prims, but I'm excited by the thought of more interesting varieties of stones to make jewelry with.

Last night I started all my computers (even the ancient ones) working on churning out textures. This is going to take a looong time - my fastest computer is managing about one texture every hour and forty minutes, and I've got a total of 765 textures to go through (85 gem shapes, and 9 colors for each). So far I've managed to do 62 of them; at this rate, I might have the complete collection finished by the time sculpted prims debut on the main grid. What I've got so far (click to enlarge):


Those are at the default prim size; obviously they can get much smaller. I'll need to redo the sculpting textures, though - if you bring it all the way to its boundaries, a sculpted prim is about twice the size of an unsculpted one. These are all spaced one meter apart; even though they're set to 0.5m in each direction, you can see that they're almost touching each other.

Sculpted prims can't be cut, twisted, dimpled, skewed or otherwise tortured - so the only way to make something smaller is to change the sculpting texture. For example, rather than making the color range 0-255 in each channel, you can cut the size in half by making the range 64-191. Of course, reducing the color range also means reducing the accuracy of your model. There's also a bug at the moment, where color values that get too close to each other turn the sculptures into plain spheres if you get the camera close to them.

It's odd, but I think the back sides are even prettier than the fronts (click to enlarge):

Sunday, May 6, 2007

Sculpted Prims... with POV-Ray?

Wouldn't you know, they debuted sculpted prims and the Linux voice client on the beta grid while I'm stuck on a business trip with an ancient Dell laptop that barely runs SL, and no 3D software installed? So I downloaded a copy of POV-Ray and set to work on the sculpted prims.

Now, POV-Ray is nowhere near the best choice for this sort of thing. It's just a renderer - you have to do all your modeling in another application, or by describing in plain text the mathematical shapes which make up the model. There's really no good way to accurately turn a CSG model into a texture suitable for sculpted prims. But I like a challenge, so I faked it as best I could.

First I made a texture which, when applied to a model, would give it a color based on its position along each of the three axes. The red component went from 0 where X was -0.5, through 255 where X was +0.5. Green went from 0 to 255 along the Z axis, again bounded from -0.5 to +0.5 (Y and Z are swapped in POV-Ray from the way they are in Second Life). And blue went from 0-255 along the Y axis.

But then the problem was: how to convert this into a texture which could be applied to a sculpted prim in Second Life?

Because the sculpted prim is mapped like a sphere, the first thing which occurred to me was to put a "spherical" camera in the center of the model, set the model to show up in reflections but be invisible to camera, and then surround the model with a 100% reflective sphere. This is far from perfect - as I discovered, most "undercuts" in the model don't work properly. But as long as the model is mostly convex, it works pretty well. For example, here's a simple bottle I made:



It's just a 2D Bézier spline rotated around an axis. Here's the POV-Ray code for it:


#declare t_sculpty = texture {
pigment {
average
pigment_map {
[1 gradient x color_map {[0 rgb 0][1 rgb <1,0,0>]}]
[1 gradient y color_map {[0 rgb 0][1 rgb <0,0,1>]}]
[1 gradient z color_map {[0 rgb 0][1 rgb <0,1,0>]}]
}
translate -0.5
}
finish { ambient 3 diffuse 0 }
}

lathe { bezier_spline 24,
<0.000,0.005>, <0.000,0.005>, <0.102,0.005>, <0.102,0.005>,
<0.102,0.005>, <0.102,0.102>, <0.060,0.154>, <0.214,0.212>,
<0.214,0.212>, <0.370,0.270>, <0.450,0.307>, <0.450,0.410>,
<0.450,0.410>, <0.450,0.511>, <0.450,0.957>, <0.450,0.974>,
<0.450,0.974>, <0.450,0.990>, <0.371,0.997>, <0.352,0.990>,
<0.352,0.990>, <0.332,0.985>, <0.175,0.975>, <0.000,0.975>
sturm
translate y*-0.5
scale <1,-1,1>
texture { t_sculpty }
}

sphere { 0, 1.001 inverse
finish { ambient 0 diffuse 0 reflection 1 }
}

camera { spherical location 0 look_at z*-1 }

(I got the points for the spline by drawing a curve in The GIMP, then hovering the mouse over all the control points and handles in sequence.) If you render that out to a 64x64 image (using the highest antialiasing you can!), you get this:


If you then bring that image into Second Life and use it for the sculpted prim, it'll be a really fat bottle. (The closer you can get the model to the boundaries of ±0.5 meters, the better the model will ultimately look.) So I made the bottle as fat as possible in POV-Ray, and then scaled down the prim's X and Y size in Second Life.

So that was amusing, but not very challenging - time to try something else! Admittedly, I'm not a great POV-Ray modeler; fortunately, one of my Gmail accounts had a nifty model I'd gotten from another POV-Ray user, and after a little bit of work, I got bits of it into Second Life:


It's untextured yet, but I think it's still pretty recognizable. Only the primary and secondary hulls are sculpted; the engine nacelles, pylons, "deflector dish" and top/bottom "sensor domes" are regular prims.


Because the sculpted prims use a grid of 32x32 points, some of the fine details get lost. You can see the details at the front of the secondary hull aren't very crisp; neither is the shuttlecraft bay at the back:


Still, it's an awesome addition to the SL modeler's arsenal (and this is only version one of the sculpted prims; Qarl Linden is busy at work on version two). But it looks like I need to try fighting my way through Blender's bizarre interface again if I want to do this right, as I doubt there'll be an exporter for Animation:Master anytime soon...

Addendum: And now a heart-shaped gemstone, textured appropriately!

Friday, April 20, 2007

Better Mousetrap

The schedule board at Rockcliffe University, while it looked nice, I'm told it was quite horrible to actually use. It required all sorts of strange configuration via notecards, making the weekly schedule change a nightmare.

I thought there had to be a better way. So I made a similar board - by tapering a box and then mashing it flat, three different letters could be put on a single prim. But instead of arcane configuration, I set it up so you could simply drop a notecard on it, and the text of the notecard would be displayed on the schedule board. Not too bad!

But it was kind of hard to read, and I thought it might be nice if you could change the colors for each line (or groups of lines by day), and added in a #color command which wouldn't be printed, but would set every subsequent line to the specified color, until it was overridden by another #color command. (Shown to the right; click image for a larger view. Classes which had already taken place appear in dim characters.)

And yet I still wasn't satisfied. I was already planning a Web-based schedule database, so the teachers could go in and schedule their classes, which would then appear on the Web site's calendar - so why not also automatically update the board whenever the schedule changed, or a class was over?

This required delving into the XML-RPC functions - which was an interesting learning experience in its own right. But while I was doing that, someone on the Scripters of Second Life group mentioned offhandedly that you could get five letters onto a prim. Well, that sounded like a fun challenge - not to mention cutting the number of prims by 40% - so I set about trying to do so.

Here's a graphic showing the stages of making a 5-letter text segment:


First, we start with a prism. This is the fourth icon on the "Create" pane, between the pyramid and the cylinder. I've colored the front faces red and black just for reference.

Second, set the Taper X and Taper Y both to zero, to get rid of the point on the top and make the edges straight.

Third, set the Path Cut to B=0.2, E=0.8. This cuts a wedge out of the front of the prism, giving us the faces which I've colored green and white. Those particular values leave the red and black faces each taking up one-fifth of the prim's width.

Fourth, set the Hollow to 65. This cuts into the green and white faces, showing us the interior between them (colored blue.

Fifth, set the X size all the way down to 0.010, which flattens out the prim as much as possible.

And sixth, scale the prim so that it gives us a good height-to-width ratio for text. I scaled it to <0.010,0.964,0.250> so that the letter faces were the same size as the ones on my previous version.

Next came setting the texture offsets. If you just tried to put a texture on the faces, they'd look okay on the second and fourth faces, but stretched out somewhat on the first and fifth faces, and REALLY stretched (and backwards!) on the middle face.

So if we were just going to apply a texture with a single letter to each, we'd have to change the texture repeats and offsets. From left to right:

  1. Repeat 2.5 horizontal, 1 vertical; offset -0.25 horizontal, 0 vertical.
  2. Leave at the defaults (repeat 1 horizontal, 1 vertical; offset 0 horizontal, 0 vertical).
  3. Repeat 15.4 horizontal (flipped), 1 vertical; offset -0.2 horizontal, 0 vertical.
  4. Leave at the defaults.
  5. Repeat 2.5 horizontal, 1 vertical; offset 0.25 horizontal, 0 vertical.
With those settings, you would just need to swap the textures for each face in order to display a different letter. (I did it somewhat differently, though - I made a texture with the lower 128 ASCII characters arranged in a grid, which requires a bit more computation every time the letters change.)

I'm still writing the database portion of the system, but to test the XML-RPC communication, I wrote a quick script on my Web site to contact the board in-world, display the version and time, and then include the output of the Linux fortune program, adding #color commands as appropriate:


Now I just need to add in sequence numbers so that if the Web server doesn't receive a response to its communication, it can resend it, and the schedule board won't duplicate the information if it already received it but its response was lost. And then finish writing the database front-end, of course. But still, not bad for a couple days' work!

Wednesday, April 4, 2007

Fantastic Inspiration

In Spaceport Bravo is the most amazing build I've seen in Second Life so far: a detailed reproduction of the Apollo Lunar Excursion Module. I thought I was obsessive about detail, but the scope of this build just awed me.

Lora Chadbourne, the creator of "Snowflake" (as she calls it) tells me it comprises 2370 prims and took her a month to build. And it shows, from the bracing on the inside of the hatch right down to the prim bolt heads.

A view of the exterior, compared with a picture I took of the real thing at the Kennedy Space Center:


Looking in through the front hatch:


And the control panels at which the astronauts stood (again compared with the real thing):

Utterly amazing, humbling and inspiring.

Monday, April 2, 2007

In the Webcomics

Sore Thumbs seems to have some familiarity with Second Life.