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.

Thursday, March 8, 2007

Easily Amused

I like to stay logged into SL while I'm at work. (Addicted? Me?) With friends in different time zones, it's nice to have the option of hearing the IM chime if they want to talk to me. But of course while I'm working in RL, my avatar just sits there doing nothing.

So I made a stone pillar with the "birth-of-venus" animation in it, made a set of skins with the same texture as the pillar, and park myself on it in the Rockcliffe University arts center when I know I'm going to be away for a while. Of course I still breathe and blink, and my name still shows up above my head, so it's obvious that I'm an avatar and not a true work of art like you can find at Second Louvre — but it's a more amusing (and decorative) way to go AFK than just standing there slumped forward.

On a completely unrelated topic, while the main grid was having asset-related issues yesterday, I logged in to the test grid and explored the sewers and tunnels of Nexus Prime. I don't know whether or not it's under active development as a game-within-Second-Life, but what I found there reminded me quite a bit of Deus Ex (which is still my favorite computer game, even all these years after its release). But with so many twisty dark passages, all alike, I'm sure I haven't seen the whole thing. Even the "always turn right" method doesn't work when you've got passages going up and down as well.

Tuesday, March 6, 2007

Were they snakes, they would have bitten me.

I actually looked at the Tools menu today, and saw two items which had previously escaped my notice:


I save my changes frequently while I'm working, not only because I'm paranoid, but because all too often I'll have been tweaking something only to find out that I've been half-disconnected and all my changes have been lost. So I'll take a copy of what I'm working on, after deleting the old version from my inventory so that I don't have dozens of duplicate entries in the Objects folder.

With "Save Object Back to My Inventory", it updates the copy in the inventory so that it's identical to the in-world instance that you're working on. So much easier!

But the really beautiful one is "Save Object Back to Object Contents". Whenever I've been working on something contained in another object's inventory, I've had to drag it into my main inventory, delete the copy out of the containing object, and then drag the contained object from my main inventory to the containing object's Content tab. But this tool updates the version in the containing object's content; no need to delete anything or use main inventory as an intermediary.

I feel like a dork for never having noticed these options before.

Also, I love Class 5 sims and First Look:


48 users in the sim, and the sim wasn't lagged at all! LL claims a Class 5 sim will support up to 60 avatars before things start to bog down. They must put the hamsters on serious steroids to get that kind of performance.

And thanks to First Look, I was still pulling a respectable 18fps even when 35 of those users were directly in my field of vision. I hear rumors that, despite what the official blog says about no new viewer download, some of the First Look enhancements will be released into the main viewer tomorrow.

Saturday, March 3, 2007

We're gonna have a party, yeah...

Tomorrow (Sunday), to celebrate the opening of our new sim, Rockcliffe University is throwing a party. Live music! Classes! A DJ! Dancing! Uh... more classes!

Stop by if you feel like it, check out the place, listen to some music, say hello if you'd like.

11:00 AM - Live music: Mel Cheeky
12:00 Noon - Live music: Flaming Moe
1:00 PM - Live Music: kaklick martin
2:00 PM - DJ Doubledown Tantino
Classes will probably be running throughout the day, but I haven't seen a schedule yet.

Wednesday, February 28, 2007

Pros and Cons

The brouhaha developing over the integrated voice chat is really interesting to me. I missed all the previous "ZOMG THIS IS THE END OF SL" changes — land fee changes, free accounts, and so forth — so this is my first experience with the wide spectrum of reactions.

Unlike some of the posters, I can see both sides of the argument. Speaking as an SL "educator", I think this will be a wonderful tool for teaching classes. I hate having to cut-and-paste due to the time constraints of disseminating large amounts of information in a fairly short time. If the students had to wait for me to type everything — and go back and correct typos, because I obsess about that — my hour-long classes would take at least a couple of hours each. Being able to actually speak it — and to let students actually ask their questions at speaking speed, instead of having to wait (sometimes interminably) for them to finish typing them, would be wonderful.

On the other hand, as I have a friend with profound hearing loss, and another with a bad speech impediment, I can understand the horror that some might feel at this development. My friend who stutters loves online forums because he can communicate as freely as everyone else; if he played Second Life, I can just imagine how this would affect him. And then of course there are the gender changers; this will pretty much spell the end of their SL identities.

I'm personally ambivalent about it; I really look forward to using it as a tool in teaching, but it'll make me feel really self-conscious because I hate the way I sound in recordings. (Why does it sound so different from the way I sound to myself when I'm speaking?) And I get stage-fright on conference calls. But maybe speaking more in SL will help me get over that. So I don't know. I'll have to wait and see.


And at the risk of sounding crabby, I'm getting really tired of the SL blog commenters who always complain about Linden Lab addressing anything but the commenters' pet-peeve bugs. "How can you waste time on X when you haven't fixed Y?" It's like saying "Why are you doctors and scientists trying to cure diabetes, blindness and Alzheimers when you haven't cured cancer yet?"

Monday, February 19, 2007

A Week's Work

Wow, has it already been a week since the last time I posted?

The head of Rockcliffe University, where I teach building (and am writing a scripting course, which hopefully will debut before the end of the month), went and bought an entire sim. Which means all new classrooms!

One thing which I thought the old space lacked was actual lecture halls. So I decided to build one . Once I got through the inevitable round of "could you change this and this and this?" (never build things "on spec" if you're trying to realize your own vision!), I ended up with this layout:



Sure, it'll get the job done, but it's not all that exciting visually. So I took a couple of days, and wrote the set of scripts I've been planning to write for ages.

One script, which I dropped into every prim in the build (except the chairs), just sat there until I uttered a command. Once I did, each prim announced all of its parameters: location, size, rotation, type, hollow, cuts, and so forth. I copied all that information out of my chat history and pasted it into a text file on my computer.

Then I ran that text file through a PHP script which I wrote to convert each prim's data into a POV-Ray object. POV-Ray is a freeware 3D renderer, which does shadows and other things very nicely. The great thing about it is that its scene description language uses plain text statements which describe graphics primitives very similar to what's used in Second Life: boxes, cylinders, spheres, tori, and so on! So my PHP script converted the build into a POV-Ray scene file, which (when rendered out) looked like this:


Not terribly exciting when everything's grey, so I started adding textures to everything. It's not really easy to add image textures to different surfaces of POV-Ray objects, like it is with Second Life prims, but POV-Ray has some very versatile texturing capabilities in its own right. After another day or so of writing texture statements, it rendered out like this:


I then rendered out orthographic views of pretty much every surface, which gave me image maps I could then upload and apply to the build in Second Life. This was what took the longest, as I had to calculate the repeats and offsets for pretty much every face. But in the end, I think it was worth it, as here's what the final result looks like in Second Life:



The chairs are kind of lame, unfortunately. I had made much better textures for them, with rounded backs and seats which appear to curve down in front, but they'll have to wait until the alpha-texture sorting bug is fixed before they make their appearance.

But regardless of textures, the chairs themselves are very low-prim; each bank of four chairs consists of seven prims, whereas the five-chair banks are only eight prims each. Through the judicious use of alpha textures, I was able to make them look more complex than they actually are. They don't stand up to close scrutiny, but they manage to seat 52 people at a cost of only 88 prims (the entire build is 186 prims).

And here's a view looking from the side of the stage out towards the back of the hall:


Oh, foo, I just noticed I forgot to make the doors more interesting, with a crash bar and a narrow pane of safety glass and one of those things up in the corner to make it close slowly.

And no emergency exits! I hope there aren't any fire code inspectors in Second Life!

Monday, February 12, 2007

Textures and Generators

In one of recent posts, Ged Larsen talks about wrapping a texture around a skirt built by his fantastic LoopRez script. He sums up his experiment by saying:

I don't think this script could ever be useful as a releasable tool, though. Essentially, I think for every project, the script would have to be re-coded, which would probably not be worth it.
Of course, to me that sounded like a challenge! I've been meaning to get back to my own necklace generator and finish up the features I want to have in it, so I pulled it out and started to work.

But the first thing I needed to do was make mine faster. Because calculating equal placement on the circumference of an ellipse is extremely complex math, which to be honest I don't understand well enough to translate into LSL. So I did it the ugly, lazy way.

In essence, I started from a particular point on the ellipse and gradually increased the angle, bit by bit, until the position represented by that angle was at the distance I wanted it to be, within a certain amount of tolerance. The lower the tolerance, the longer the process took. For tiny prim jewelry, that required a really low tolerance.

So I ripped out all that code and replaced it with something much faster, based on a binary search algorithm. Basically, it takes two angles: at first, the back of the necklace and the front of the necklace. Then it picks an angle halfway between the two. If the angle is too large, it then recalculates between the starting point and the halfway point and tests again. If the angle is too small, it recalculates between the ending point and the halfway point, repeating until it's gotten within a certain amount of tolerance from the position we actually want. Then it moves on to the next piece, using the previous piece's location as the starting point to calculate from, and so on until it reaches the front of the necklace. (The other side is just a mirror image of the first, which is trivial to calculate.)

It sounds like more work, but even with a narrow tolerance, it's at least four times faster than the old version with a wide tolerance.

As to the image wrapping: while I can place the image on the prims in the proper location, it doesn't quite look right with the usual tapered cylinders that dresses are made out of; the narrow tops have too much image on them, and the wide bottoms too little. That problem will take a little thinking about. Perhaps it won't be as noticeable with a fabric pattern as it is with a snapshot.

Ged asks to see what progress I've made on it; here's a snapshot showing two different "waist sizes", with the same texture wrapped around the "skirt":


(The image I used was a snapshot of me with my friend Rhetorica and some of her schoolmates.) The problem I mentioned above is more visible on the smaller "skirt", up at the top. There's no "poof" to them because I haven't put in code to do so yet.

The process required that I create a skirt panel and drop in a script, then put the panel into my generator's inventory. Then, for each panel, the generator calculated the placement, texture offset and texture repeat values. It then rezzed out all the panels, and then sent the texture information to the script in each one.

It still has quite a ways to go, and I think I'm going to fork off a skirt generator from my necklace generator, just to make the latter faster yet (the fewer calculations it has to do, the better for speed's sake).

Wednesday, February 7, 2007

Conundrum!

I noticed the other day that some of my scripts were able to execute on no-script land.

Through the process of elimination, I was able to narrow it down to exactly what combination of factors permitted this to occur, and now I can reproduce it at will — for example, I modified the "Sexy Walk" attachment so it now continues to function in no-script territory; no more monkey walk for me!

My first thought was, "I should probably report this as a bug."

My second thought was, "But I could make a mint selling AOs that keep working!"

My third thought was, "I wonder if this is an exploit. Do they still offer a bounty on exploits? And if I don't report it, but sell objects which make use of it, would I get banned?"

Further research is needed.