Jump to content

HELP! : Converting Region Coordinates to Local


Richard Rexie
 Share

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

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

Recommended Posts

Good morning everyone :matte-motes-smile:,


Today while scripting I've stumbled into a kind of a problem (at least for me),  about converting a region position into a local.

I have PRIM_ 1 and PRIM_2, both unlinked, about which I save both of their own region position into PRIM_2 which will be rezzed as a linked object later.


My goal would be to be able to have PRIM_2 rezzed as child prim, at the same distance, related to PRIM_1, as it was when unlinked.

What I've tried to do was the following :

 

//I save this when both of them are unlinked

vector DISTANCE = prim_1_pos - prim_2_pos;

 

//Once the PRIM_2 is rezzed as a child linked object I try to move it in its position

llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_POSITION,(llGetRootPosition()-DISTANCE)]);

 

The whole probem is that PRIM_2, now a child prim, doesnt move at the same exact position as it was when the DISTANCE was saved, but even worse, and that is what I really don't understand completely, is that if I get the PRIM_1 position with llGetRootPosition() before PRIM_2 becomes a child and after, it gives me two different region coordinates, even if PRIM_1 has not be moved at all.

I do really hope someone experienced the same thing and there is a workaround, or this beign a mistake of mine.

 

 

 

 

 

Link to comment
Share on other sites

Are you rezzing PRIM_2 from PRIM_1 ?   If that's the case, you need something like this.   If you're rezzing both of them from a rezzer, then you'll need to use a strided list of primName, primOffset and PrimRot but this should demonstrate the principle.

Just set up the rezzer and the items it's to rez, positioned how you want them relative to each other, and then read their sim positions and rotations using llOwnerSay((string)llGetPos()) and llOwnerSay((string)llGetRot()).    Enter them in the script and it should calculate stuff for you:

 

vector rezzer_pos =<122.56290, 177.22310, 1750.81200>;  // the position of the rezzer when first you set it up -- read with llOwnerSay((string)llGetPos());in another scriptrotation rezzer_rot  =<0.00000, 0.70711, 0.00000, 0.70711>; //rotation of the rezzer, ditto --  read with llOwnerSay((string)llGetRot());in another scriptvector child_pos = <122.71410, 175.05910, 1750.81200>; // the position of the rezzed object at first set uprotation child_rot= <0.00000, 1.00000, 0.00000, 0.00000>;//rotation of rezzed objectvector offset;default{    state_entry()    {        offset = child_pos-rezzer_pos;        offset = offset/rezzer_rot;    }    touch_start(integer total_number)    {        llRezAtRoot(llGetInventoryName(INVENTORY_OBJECT,0),        llGetPos()+offset*llGetRot(),        ZERO_VECTOR,        (child_rot/rezzer_rot)*llGetRot(),         99);    }}

 

Link to comment
Share on other sites

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