Sunday, February 11, 2007

Varying skirt pleat lengths (and colors) -- skirt scripting language?

Voila, the ugliest skirt in existence!

One of the things about LoopRez is that it generates skirts where all the panels are essentially the same -- same color, same length -- just varying in position and rotation in space. Varying the length can give a much more interesting effect. One of my favorites is Natalia Zelmanov's formal gown.

When LoopRez was modified to have a "BACKANGLE" setting, where the back panels can have a different amount of flare angle compared to the front of the skirt, I started thinking that it ought to be possible to do more with varying each panel.

I experimented with a rather extreme case of varying textures across the panels, by tiling a texture completely around the skirt. This worked, but had to be hand-coded, adjusting the script for the specific skirt size and texture. This wouldn't be terribly accessible to the general public.

So, what about varying lengths (and colors) across skirt pleats, but making it more usable to the general public? I've been thinking about this for a while now, and even mentioned it a little while back. Well, in the past few days, I wrote my first notecard reader (for product updates, actually), but realized that a notecard might be a way for a skirt designer to tell LoopRez what they wanted in varying lengths.

Here's what I've come up with -- the LoopRez Skirt Programmer
  • there are 360 degrees in a circle: moving counter-clockwise looking down on a skirt,
    • 0 degrees is the front of your skirt;
    • 90 degrees is your left side;
    • 180 degrees is the back;
    • 270 degrees is the right side; and
    • 360 degrees is the front again
  • prim sizes are described (in the Edit Menu and in scripts) as three numbers <x,y,z>, a vector. Generally, the Z size is the length of a skirt, depending on how you rotated your prim
  • I create a notecard, and consisting of some lines that describe the lengths at various "degree positions" on a skirt. Here's an example:
    0~<0.2, 0.2, 0.2>
    30~<0.2, 0.2, 0.3>
    60~<0.2, 0.2, 1.0>
    300~<0.2, 0.2, 1.0>
    330~<0.2, 0.2, 0.3>
    360~<0.2, 0.2, 0.2>
    The first line tells my script that you want to vary the size. Notice that X and Y are always 0.2 -- those sizes don't vary. Notice that Z, however, varies from short (0.2 m) at the front of the skirt, a little longer (0.3 m) at 30 degrees, and full length (1.0 m) for all the degree range from 60 degrees to 300 degrees, then symmetrically back to 0.3 and 0.2 meters as you come around the front-right of the skirt again.
This is what it looks like.

IMPORTANT: there's been some confusion about when to use the SkirtProgrammer. Essentially, what you need to do is ALL the things to generate a skirt, and THEN run the /1 PROGRAM command. The Skirt Programmer works on a skirt that has already been rezzed, but NOT yet completed with the /1 DONE command.

Start with a default 30 panel LoopRez skirt:

After dropping the above notecard (named "skirt open front") onto the LoopRez central little Metal Ball, and typing "/1 PROGRAM skirt open front", the panel sizes get adjusted to look like this (no adjustments needed for position or rotation, so it took just a few seconds to go from the first picture to this one):

Well, it turns out that like sizes, colors are also described in SL by 3 value vectors, <RED, GREEN, BLUE>, with values ranging from 0 to 1 for each color. So, it wasn't hard to write the script to vary colors as well. I don't remember exactly what the Notecard contained, but it was probably something like:

In other words, pure bright red at 0 degrees (the front), varying to no color (black) at 180 degrees (the back), and then back to bright red at 360 degrees (the front) again. Here's how it looks:
Notice that the short panels stick out a bit. Bah... I think that has to do with the flexi settings -- a short panel doesn't have as much "gravity" pulling it down. So, perhaps some small amount of manual tweaking might actually be helpful.

Ever wonder how to generate a rainbow in RGB space? No? Well I did, and I found one way here:
It ends up being a progression of 6 segments, varying the amount of red, green, and blue. So, why not try to write a Skirt Progammer notecard ("skirt rainbow") that varies RGB in this progression? It looked like this (I added in comments for description):
0~<1,0,0> // pure red
60~<1,1,0> // red + green
120~<0,1,0> // pure green
180~<0,1,1> // green + blue
240~<0,0,1> // pure blue
300~<1,0,1> // red + blue
360~<1,0,0> // back to pure red
There are 6 segments in the progression, so I divided the 360 degrees of a circle, to get 60 degree increments around the skirt. After typing "/1 PROGRAM skirt rainbow", the result makes me think of 60's tie-dye hippiedom:

To adjust 30 panels manually to get a smooth rainbow gradient would have been rather tedious. To run it with the Script Programmer took a few seconds. Fun!

Granted, the skirt is ugly enough to make a real SL fashion designer want to claw their eyes out, but hey, I just make the tools -- it's up to them to make beautiful things with them.

Comments? What do you think?