Difference between revisions of "Talk:Viewer coordinate frames"
Jump to navigation
Jump to search
m (Replaced <lsl> with <syntaxhighlight>) |
|||
Line 2: | Line 2: | ||
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: | ||
< | <syntaxhighlight lang="lsl2">key keyObj = llGetLinkKey(i); | ||
list a = llGetObjectDetails(keyObj,([OBJECT_POS])); // returns region coordinate | list a = llGetObjectDetails(keyObj,([OBJECT_POS])); // returns region coordinate | ||
vector localp = llList2Vector(a,0) - llGetRootPosition(); | vector localp = llList2Vector(a,0) - llGetRootPosition(); | ||
// and later you can use this to set another prim to that location using: | // and later you can use this to set another prim to that location using: | ||
llSetLinkPrimitiveParams(i,[PRIM_POSITION,localp]); //expects local coordinate</ | llSetLinkPrimitiveParams(i,[PRIM_POSITION,localp]); //expects local coordinate</syntaxhighlight> | ||
-- {{User|Wood Wheels}} | -- {{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) | :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) |
Latest revision as of 13:11, 25 January 2024
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)