Jump to content

Where did this sit adjustment come from?


animats
 Share

You are about to reply to a thread that has been inactive for 1767 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

UpdateSitTarget(){
    SitPos=DefPos+AnimPos+AviPos;
    SitRot=llEuler2Rot(DefRot+AnimRot+AviRot);
    llSitTarget(SitPos,SitRot);
    if(agent){
        vector size = llGetAgentSize(agent);
        if(size){
            rotation localrot = ZERO_ROTATION;
            vector localpos = ZERO_VECTOR;
            if(llGetLinkNumber() > 1){
                localrot = llGetLocalRot();
                localpos = llGetLocalPos();
            }
            integer linkNum = llGetNumberOfPrims();
            do{
                if(agent == llGetLinkKey( linkNum )){
                    float fAdjust = ((((0.008906*size.z) + -0.049831)*size.z) + 0.088967)*size.z;
                    llSetLinkPrimitiveParamsFast(linkNum,
                    [PRIM_POS_LOCAL, (SitPos+<0.0, 0.0, 0.4>-(llRot2Up(SitRot)*fAdjust))*localrot+localpos,PRIM_ROT_LOCAL, SitRot * localrot]);
                    jump end;
                }
            }while( --linkNum );
        }
        else{
            llUnSit(agent);
        }
    }
    @end;
}

This is a piece of code from a chair's sit script. After an avatar sits, an adjustment is performed based on the avatar's height to put the feet on the ground. The adjustment applied is

float fAdjust = ((((0.008906*size.z) + -0.049831)*size.z) + 0.088967)*size.z;

which is a cubic curve driven by size.z. It's basically 9% of size.z plus some additional terms. This suggests that someone collected data on avatars and fit a curve to the data. Anyone know where those numbers came from, and if that formula is any good?

Edited by animats
Link to comment
Share on other sites

I don't have time now to go back through notes that I took several years ago, but you can start down your own trail by looking at the discussion on llGetAgentSize in the LSL wiki at http://wiki.secondlife.com/wiki/Talk:LlGetAgentSize .  IIRC, that's where I started when I was curious about the same thing.  I just don't recall right now where the trail went from there.

  • Like 1
Link to comment
Share on other sites

5 hours ago, Mollymews said:

Strife Onizuka.  a LSL legend from back in the day

it can be seen here in his UpdateSitTarget function:  http://wiki.secondlife.com/wiki/LlSitTarget

 

In fact, Strife was summarizing and simplifying a whole long effort by a bunch of scripters to reverse-engineer where the avatar ended up for any given sit target. But Strife's original simplification wasn't a cubic equation at all. If I recall correctly, it was @Talarus Luan who arrived at that more precise estimate. Reading the history on that wiki page, you can see some of the later calculations unfold; from that discussion it appears to start with a number from Escort Defarge, but at least as I recall, it went back further, originating with Lex Neva -- as so many things did back then -- and LearJeff Innis who pulled together a tidy "Easy Sit Target Positioner" script. (I even did a little curve-fitting myself at one point.)

  • Thanks 2
Link to comment
Share on other sites

7 minutes ago, Qie Niangao said:

i see that reference in the code now that you point it out

Lex Neva woo!

edit add: i sorta remembered Lex  Neva winning an award when LL used to do that.  So I looked it up: http://wiki.secondlife.com/wiki/Linden_Lab_Innovation_Awards

edit more: With all the cuddles that the latest Linden team want to give out these days then they may be could look at giving out Hippos again. 

I nominate Rolig Loon and Whirly Fizzle and Lindal Kidd for services to the Forums, for patient perseverance  answering the same questions over and over with kindnesss and tolerance :)

 

 

Edited by Mollymews
  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1767 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...