• Winking Gwyn
  • Categories

  • Feeling generous today? Any money received will support the continued web hosting of this blog. Donate towards my web hosting bill!
  • Creative Commons License
  • Gwyneth Llewelyn is offline in Second Life.
  • Pages

  • Meta

  • Blog Rank: 32,746
02 Dec

Sitting down with flexiskirts

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 (the original . 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;

default
{
  state_entry()
  {
    // save current state
    FlexiState = llGetPrimitiveParams([PRIM_FLEXIBLE]);
  }

  changed(integer what)
  {
    // if someone is tweaking the flexi settings, you better reset!
    if (what & CHANGED_SHAPE)
      llResetScript();
  }

  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));
      }
      else
      {
        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 ;)

9 Responses to “Sitting down with flexiskirts”

  1. 1
    Marga FerrerNo Gravatar Says:

    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!

  2. 2
    ThaumataNo Gravatar Says:

    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!

  3. 3
    patou dumontNo Gravatar Says:

    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.

  4. 4
    anonNo Gravatar Says:

    Hi there….

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

  5. 5
    Gwyneth LlewelynNo Gravatar Says:

    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.

  6. 6
    guakaNo Gravatar Says:

    i read about your scipt in http://mundosl.com/

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

  7. 7
    Pompo BombacciNo Gravatar Says:

    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.

  8. 8
    Gwyneth LlewelynNo Gravatar Says:

    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.

  9. 9
    Krimson GrayNo Gravatar Says:

    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.

Leave a Reply

Login Method

OpenID

Anonymous

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This site is using OpenAvatar based on

© 2008 Gwyn’s Home | Entries (RSS) and Comments (RSS)

Powered by Wordpress, design by Web4 Sudoku, based on Pinkline by GPS Gazette