Jump to content
Sign in to follow this  
Richard Rexie

HELP! : Converting Region Coordinates to Local

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.

 

 

 

 

 

Share this post


Link to post
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);    }}

 

Share this post


Link to post
Share on other sites

Thats perfect! :matte-motes-wink:

So i suppose the problem was related to using the llSetLinkPrimitiveParamsFast() command to move the child object.

But thanks you a lot! You made my day :matte-motes-big-grin-wink:

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...