Difference between revisions of "Talk:Viewer coordinate frames"

From Second Life Wiki
Jump to navigation Jump to search
(New page: 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 coordinat...)
 
Line 1: Line 1:
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.
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:
It is anti-intuitive (you subtract the root position from the prim position), but like this:  
<lsl>
<lsl>
key keyObj = llGetLinkKey(i);
key keyObj = llGetLinkKey(i);
Line 10: Line 10:
llSetLinkPrimitiveParams(i,[PRIM_POSITION,localp]); //expects local coordinate
llSetLinkPrimitiveParams(i,[PRIM_POSITION,localp]); //expects local coordinate
</lsl>
</lsl>
-- {{User|Wood Wheels}}
:Yes you can do that, (I used the same method when writing [[llSitTarget#GetSitTarget|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. -- [[User:Strife Onizuka|Strife Onizuka]] 16:24, 11 December 2007 (PST)

Revision as of 17:24, 11 December 2007

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: <lsl> 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 </lsl> -- 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)