Sitting down with flexiskirts [UPDATED]

This looks badEvery girl who tried a flexiskirt once (how can you resist not buying them…?) knows about the problem: they look fantastic when standing up, but completely nasty when sitting down.

The image here shows what happens. Flexiskirts, unlike mesh-based skirts (also known as ugly Linden skirts) simply don’t follow your avatar’s skeleton, but gravity. There is nothing you can do about it: the skirt will always be “inside” the chair where you sit on.

Or is there a solution?…

Linden Lab sometimes comes up with clever things. In fact, flexible prims (“flexies”) was one of the most clever things ever done. We can’t live without them any more, and “Linden skirts” are completely out of fashion these days, so what can we do about it?

Well, a little-known trick is that flexies are not only affected by gravity, avatar movement, and wind. Unlike Linden skirts (which are, of course, not scriptable…) they can also be affected by a mysterious “force” as well — one that you can define either on the prims itself, or use scripting.

So here is the idea behind this concept: detect when the avatar is sitting down, and apply a force to the flexiprims so that they point forward (in the XY plane where your avatar is sitting). That way, they won’t “go through the chair”! You can adjust this force to make it look more or less natural; the prims are still flexi, so they’ll still move around with wind (if the force is not too strong), and they’ll continue to be affected by gravity a tiny bit, so they’ll bend from the point of origin (usually your waist), ie. they won’t look like solid planks 🙂

A few extra tricks are needed. First, it’s a pain to use a script on each and every flexiprim on a skirt (you’re definitely going to miss a few). Thankfully, LL is listening to us, and they gave us a new LSL function: llSetLinkPrimitiveParams(). With that, you can change all prims on the same linkset with just one function call in a single script! It’s very, very useful.

Is that all? No! 🙂 Sadly, we need some math to figure out how to apply the force. You see, forces are vectors, and the first thing you need it to figure out which way your avatar is facing when sitting down, and make sure that you apply the force in the right direction! Since I’m not good at maths, I’m cheating a lot — the force in this case is just on the XY plane (so I ignore the Z bit) and that should be good enough for most cases. Feel free to add more complex math on the comments 😉

This particular script is not automated, ie. you need to touch your skirt to change it from a walking to a sitting position. But this can be automated! Since it requires a timer that checks if you’re sitting down or walking around, that creates a bit of lag, though, so I’ve avoided it.

Here goes the script:

// Gwyneth Llewelyn's Flexi Vector Changer,
//  ... or: how to get flexiskirts to work properly when sitting down!
// Works by touching and flipping through the two status: staning up/sitting down
//  To-do: interface with an AO so that it works automagically
list FlexiState;
integer isSit;
// save current state
FlexiState = llGetPrimitiveParams([PRIM_FLEXIBLE]);
changed(integer what)
// if someone is tweaking the flexi settings, you better reset!
if (what & CHANGED_SHAPE)
touch_start(integer total_number)
if (llDetectedKey(0) == llGetOwner())
if (!isSit)
isSit = TRUE;
llOwnerSay("Skirt in sit mode");
// ok, we know the rotation. Now we need to figure out the bloody angle in the XY plane!
rotation avatarRotation = llGetRot();
vector PointForward = <1.0, 0.0, 0.0>;      // get a unit vector!
PointForward *= avatarRotation;  // do vector rotation
PointForward.z = 0.0; // clean Z as well, you never know; now this vector should be on the XY plane
// amplify magnitude!
PointForward.x *= 10.0;
PointForward.y *= 10.0;
llSetLinkPrimitiveParams(LINK_SET, [PRIM_FLEXIBLE] + llListReplaceList(FlexiState, [PointForward], 6, 6));
isSit = FALSE;
llOwnerSay("Skirt in walk mode");
llSetLinkPrimitiveParams(LINK_SET, [PRIM_FLEXIBLE] + FlexiState);

And the result does certainly look much nicer!
This looks much nicer
Now, how to use it. You need a modifiable skirt, and one that only has flexiprims — just drop the script inside it while you’re standing (it’s very important to do that when standing). A few designers, however, mix flexies and regular prims on the same skirt (and these days, modifiable objects are harder to get). Please note that if just a single prim is not a flexie, this script will not work. Trust me: I’ve broken a few skirts that way 😉

If you know of a skirt designer that just sells non-modifiable skirts, or ones that combine flexiprims with regular ones, well, give them a copy of the script and make sure they start using it on all their work 😉

[UPDATE] For some silly reason, a lot of skirt designers use an invisible ball on the centre of the skirt, which is allegedly there to “make adjustments easier”. Often this invisible ball is also the root prim (the one that shows yellow when right-clicking on the skirt on the ground and selecting Edit).

This is what you have to do to use this script on these types of skirts:

  1. Drop the skirt on the ground.
  2. Right-click and select Edit
  3. Check the box that says “Edit linked parts”
  4. Right-click now on the root prim (the one in yellow)
  5. If it’s a sphere, change it to a cube
  6. Now go to the “Features” tab and activate the Flexible settings on the checkbox
  7. For best results, the parameters should be exactly like the ones on the other skirt elements (I usually select one of them, take note of all the parameters ona  piece of paper, select the root prim again, and copy them)
  8. Throw the script above inside the root prim
  9. Take the skirt back into inventory
  10. Now wear it!

Complex? A bit! So make sure you have a copyable version of your favourite skirt, I broke quite a lot of them until I figured out all the steps… but it works nicely!

Print Friendly, PDF & Email

About Gwyneth Llewelyn

I'm just a virtual girl in a virtual world...

  • Marga Ferrer

    Oh Gwy! Thanks a lot! 🙂

    What a precious script!
    I deal with that problem as like as all of us, for sure!

    But in my case, it really bores me when I play piano. I love to play piano, but the skirts… when i’m sitting down… oh my goodness!

    Now, I have to look for modifiable skirts! Or do like you suggest – convince the designers to make modifiables ones!

  • this is great. I’m going to have to play with skirts I have to see what I can do to them. 🙂 Thanks for sharing this!

  • hello there. i loved this tip ! can i translate it and post on my blog ? of course I’ll give you the credits. 🙂 thank you.

  • anon

    Hi there….

    I tried the script… it seems all the flex settings need to be identical for this to work, correct?

  • patou, of course, feel free to translate it, I’d be very glad of it!

    @4 Yes, in theory, it assumes that all flex settings are the same. In most cases, that’s what the designers usually do. On others, not only the flex settings are different, but some elements (like buttons or a belt) are not set as flexible, so this script will fail.

  • guaka

    i read about your scipt in

    works PERFECT!!!!!!!!!!ty

  • Great script!
    One prob…So how can it be applied to a linkset of flexy prims when they are usually linked to a small sphere up on top tho ?

    Most flexy skirts done in sl are like that.

  • Aaah yes, Pompo 🙂 There is only one way out: unlink the small sphere, delete it, and readjust the skirt. The small sphere is only there for “convenience”, ie. it’s far easier to adjust the flexiskirt if you have a “reference” to align it properly.

  • Krimson Gray

    I know this is ages later, but in response to post 7.

    “One prob…So how can it be applied to a linkset of flexy prims when they are usually linked to a small sphere up on top tho ?”

    If the skirt is mod, then edit the root prim (the sphere), change the type to a box then enable flexi on it as well. Voila, entire skirt is flexi.

  • Thanks, Krimson, I’ve added your explanation to the main article 🙂

  • Mairead

    I tried this script in a mod skirt, using the convert ball to flexi box at root method. It fails compiling at the “;” in line

    if (what & CHANGED_SHAPE)

    Any ideas why?

  • Mairead

    🙂 Fixed it.. for you cut n’ paste peeps out there … delete “amp;” in that line. The blog program is converting the “&” to the ascii’d version of “&”.

  • One simple thing that helps a lot – at least for us neoVictorians who wear long skirts – is for the creator to include a Linden skirt that can be worn under the flexi skirt. The result undoubtedly won’t look as nice as a skirt made by your process, but it does save one from sudden embarrasment.