Jump to content

Moving Child Prims on Attachments Relative to Root


Innula Zenovka
 Share

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

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

Recommended Posts

I was trying to help someone with this in-world, using llSetLinkPrimitiveParamsFast, and, since I know it's been discussed several times in the past here (or in previous versions of this forum), I tried to find a thread to which to direct him, and I couldn't.

Can anyone suggest a thread I might bookmark for future reference?

Link to comment
Share on other sites

What we were trying to do was figure out the equivalent of this

integer toggle;vector offset =<0.0,0.0,0.25>;default{    state_entry()    {       // llSay(0, "Hello, Avatar!");    }    touch_start(integer total_number)    {       rotation r = llList2Rot(llGetPrimitiveParams([PRIM_ROT_LOCAL]),0);       toggle =!toggle;       if(toggle){           llSetPos(llGetLocalPos()+offset*r);        }        else{            llSetPos(llGetLocalPos()-offset*r);        }    }}

 only called from a single script in the attachment's root rather than by scripts in the children, and without hard-coding the start pos and end pos.

That is, we wanted to move the child prim along its own local z axis.

 

Link to comment
Share on other sites

without condensing...

integer  vIntLnk = 2;                //-- child prim link numbervector   vPosOfs = <0.0, 0.0, 0.25>; //--local offset to use //-- Gets on PRIM_POS are always region relative //-- (child pos - root pos) / root rot == relative to root.vector   vPosLcl = (llList2Vector( llGetLinkPrimitiveParams( vIntLnk, [PRIM_POS] ), 0 ) - llGetLocalPos()) / llGetLocalRot();rotation vRotLcl = llList2Rot( llGetPrimitiveParams( vIntLnk, [PRIM_ROT_LOCAL] ), 0 );//-- Sets on PRIM_POS are local to the next highest frame of reference //-- that means child relative to root, and root relative to region.llSetLinkPrimitiveParamsFast( vIntLnk, [PRIM_POS, vPosLcl + vPosOfs * vRotLcl] );//-- local pos + (local offset * local rot) == local relative change in position

 condensed:

integer  vIntLnk = 2;                //-- child prim link numbervector   vPosOfs = <0.0, 0.0, 0.25>; //--local offset to usellSetLinkPrimitiveParamsFast( vIntLnk, [PRIM_POS, ((llList2Vector( llGetLinkPrimitiveParams( vIntLnk, [PRIM_POS] ), 0 ) -  llGetLocalPos()) / llGetLocalRot()) + (vPosOfs * llList2Rot( llGetPrimitiveParams( vIntLnk, [PRIM_ROT_LOCAL] ), 0 ));

 

Link to comment
Share on other sites

While this is working fine for me in world, as soon as I attach it, the object stops working alltogether.  I am wondering if one of the functions is not available via attachment or some other caveat that is stopping this from running while in attachment form.

 

-Jake Oxidor, the person Inulla was trying to help.

Link to comment
Share on other sites

It's not that, Void.  When it's on the ground, llGetLocalPos returns the position relative to the region if called in the root prim, I discover from the wiki, but when it's attached, it returns the position relative to the attachment point.

So it's failing when attached because it's trying to move the child prim vast distances (I've just verified this with a couple of llOwnerSays).   And I can't figure out how to calculate the properly corrected offset.

Link to comment
Share on other sites

Ok, I have it finally working, Void had a few errors in it but I fixed them, still can't get it to work as an attachment though, which is kind-of a huge piece of what I am trying to do.  So yea, if anyone knows the issue which is not allowing this snippet to work on attachments and can fix it....it would be much appreciated.

Link to comment
Share on other sites

Thanks.  I thought llGetPos and llGetRot report the avatar values.  Maybe they do, but that doesn't matter for the purposes of the calculation?  My geometry is not worth a great deal, I'm afraid.    But yes, I've just tried

vector   vPosOfs = <0.0, 0.0, -0.25>; default{    state_entry()    {       // llSay(0, "Hello, Avatar!");    }    touch_start(integer total_number)    {        vPosOfs.z*=-1.0;       integer  vIntLnk = 2;                //-- child prim link number //--local offset to use //-- Gets on PRIM_POS are always region relative //-- (child pos - root pos) / root rot == relative to root.vector   vPosLcl = (llList2Vector( llGetLinkPrimitiveParams( vIntLnk, [PRIM_POSITION] ), 0 ) - llGetPos()) / llGetRot();vector v = llList2Vector( llGetLinkPrimitiveParams( vIntLnk, [PRIM_POSITION] ), 0 );rotation vRotLcl = llList2Rot( llGetLinkPrimitiveParams( vIntLnk, [PRIM_ROT_LOCAL] ), 0 );//-- Sets on PRIM_POS are local to the next highest frame of reference //-- that means child relative to root, and root relative to region.llSetLinkPrimitiveParamsFast( vIntLnk, [PRIM_POSITION, vPosLcl + vPosOfs * vRotLcl] );//-- local pos + (local offset * local rot) == local relative change in position    }}

 and it works at any angle, attached or unattached.

Thanks again for your help, Void.

Link to comment
Share on other sites


Innula Zenovka wrote:

Thanks.  I thought llGetPos and llGetRot report the avatar values.  Maybe they do, but that doesn't matter for the purposes of the calculation?  My geometry is not worth a great deal, I'm afraid.

the simplest way to do it is if all calculations are done in the same frame... but the get and sets for position and rotation have always been rather funky.... converting to one frame of reference from another requires the starting values to all be in the same frame... don't ask me how I forgot that llGPP returns a region position for child prims, I was thinking it returned the attachment position. but returning region frame for both lets you convert correctly to local, which is what the set requires.

Link to comment
Share on other sites

For attchaments, you need to subtract the root rotation. If unattached, you must subtract the local rotation.  I use this in my prim animators:

 

 

 

rotation calcChildRot(rotation rdeltaRot){ if (llGetAttached()) return rdeltaRot/llGetLocalRot(); else return rdeltaRot/llGetRootRotation();}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4680 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...