Talk:Viewer coordinate frames

From Second Life Wiki
Jump to navigation Jump to search

How to calculate the local coordinate of a linked prim from a script in the root is not documented in the wiki. The problem being that the linked prim position is given in region coordinates and setting the location of a linked prim needs to be in local coordinates.

It is anti-intuitive (you subtract the root position from the prim position), but like this:

key keyObj = llGetLinkKey(i);
list a = llGetObjectDetails(keyObj,([OBJECT_POS])); // returns region coordinate
vector localp = llList2Vector(a,0) - llGetRootPosition();

// and later you can use this to set another prim to that location using:
llSetLinkPrimitiveParams(i,[PRIM_POSITION,localp]); //expects local coordinate

-- Wood Wheels

Yes you can do that, (I used the same method when writing GetSitTarget) but you don't actually get the exact position, only an approximation good to about 5 decimal places, it has to do with how floats work. -- Strife Onizuka 16:24, 11 December 2007 (PST)