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.

Tuesday, February 6, 2007

Nifty Find

Sometimes I'll just look around on the map to see what interesting-sounding sims are nearby. While doing benchmarks for the First Look viewer, I saw some interesting — but unfortunately inaccessible — sims with names like TextureTest, Bug Island, Island for Misfit Toys and Danger! Danger!

Looking to the west of First Look Isle, I saw a block of six sims with German names, one of which looked like it had a fort on a promontory of land.

I had to check it out — and I'm glad I did! Sitting atop a large hill, surrounded by a lush trees, was a haunting ruined castle, like one of King Ludwig the Mad's notorious projects fallen into disrepair.



As I walked upon the broken stones, avoiding the sporadic rubble, I espied some familiar objects. Glowing hands atop pedestals. A parrot. An eye-chart. In a courtyard at the bottom of the castle, a sign read Willkommen in der Orientierungs Burg, which even my pathetically rusty German could recognize: Welcome to Orientation Castle.


I've heard mention of a new Orientation Island; I wonder if this is what they will look like. It's certainly a lot more compact than the existing ones, taking up maybe a sixth of the sim. And the beach ball has been replaced with a well, into which (I think) the notecard says you're supposed to drop a large rock. There is a "physical" rock on a nearby staircase landing, but it's locked; I can't move it.

I've been looking around for a similarly upgraded Help Island, but so far haven't found one. There is a cluster of German-language, standard Orientation Islands just to the south of Frisch, though. I wonder how many other languages have their own Orientation Islands?

In sadder news, the Dynamic Reflections option has been removed from the Client->Rendering menu of the most recent First Look build. :( I can still enable it through the Client->Debug Settings dialog, but it crashes the viewer on my Windows machine immediately. (It still works on my Linux box, but that's not as powerful.)

It looks like most of the rendering improvements will be put into the official viewer soon! :) Get ready for smoother motion!

Friday, February 2, 2007

Oh. My. God.

I tried out the First Look viewer yesterday. I'd put it off, because in the comments about it in the official SL blog, I've read all sorts of wailing and gnashing of teeth about how unstable it is, but I was bored and wanted to see these "render pipeline improvements" for myself.

It was quite a bit faster (I haven't got exact numbers, but everything was much smoother), until I started playing around with the debug options and found the one to turn on reflections.

It's not just an image map of the sky sphere overlaid on the texture of shiny objects, the way the current "Shininess" texture setting works — my guess is that every so often (especially when you change position), the viewer renders a 360-degree panoramic image of your point of view, and then overlays that image onto shiny objects.

It's not perfect (for example, in order to see yourself in shiny objects, your point of view has to actually be in front of your avatar; and if you're in mouselook mode, you're either invisible or headless depending on whether or not you've got "Show Avatar in Mouselook" checked in your Graphics Preferences.

But still, it's phenomenal, and the frame rate with reflections turned on seems pretty comparable to the existing (non-First Look) viewer. And it didn't crash once while I was using it, though I noticed flexi prims aren't nearly as flexible as they are in the existing viewer, and HUDs tend to flicker madly from time to time.

While walking around and looking at reflective things, I took a trip to the Design Center in Idea City. It has some nifty tutorials on shadows (using a different technique than baking them right into your textures), and a nice display on microprims.

One thing that I hadn't managed to figure out with microprims was to make a complete sphere smaller than 0.01 in all dimensions. In my jewelry, I'd been faking it by stretching a sphere and then dimpling away all but the very tip, and using that as a mostly hemispherical bit, but it was far from perfect. The Design Center display gave some really good advice: use Hollow, and then apply a transparent texture to the outer skin of the sphere.

This was great, but the shadows are reversed in the hollow -- at noon, for example, the top of the microsphere would be shadowed while the bottom would be lit.

I found that by setting the twist on the sphere to -180 for both the begin and end, it will turn the shadows "right side up" and look much better.

And, oh, how tiny you can get them! In the image below, the moon on the left is 0.01 in all directions, the smallest SL will let you make it. To its right is another one, hollowed, twisted and textured, with the hollow set at 10 — a millimeter in diameter. And to its right, the dark grey dot, is one with the hollow set to 1, a tenth of a millimeter wide. It's almost too small; nobody would ever look closely enough to actually see it.



Now to make some jewelry with tiny little spherical gems!