Difference between revisions of "GetRootLocalPos"
Jump to navigation
Jump to search
m (Created page with 'While writing another function, I got thinking about the whole attachment local root rotation problem (you need to know the local rotation of the root prim in an attachment so yo...') |
(No difference)
|
Revision as of 01:35, 6 May 2010
While writing another function, I got thinking about the whole attachment local root rotation problem (you need to know the local rotation of the root prim in an attachment so you can use PRIM_ROT). I came to the conclusion with all the new(ish) functions, it is now possible to actually work this out.
- You know the position and rotation of the avatar, thanks to llGetObjectDetails.
- You know the attach point (llGetAttached)
- You know the combined rotation and position (llGetRootRotation & llGetRootPosition)
It should just be a matter of subtracting the one from the other and canceling out the attach point offsets.
Something like this should work... <lsl>list offsets = [ 0, <0.5, 0.5, 0.5, 0.5>, <0.0, 0.0, 0.70710678118654752440084436210485, 0.70710678118654752440084436210485>, 0, 0, 0, 0, 0, 0, <-0.5, -0.5, 0.5, 0.5> ];
vector GetRootLocalPos() {
integer point = llGetAttached(); if(point) { list avatar = llGetObjectDetails( llGetOwner(), [OBJECT_POS, OBJECT_ROT]); return ((llList2Vector(avatar, 0) - llGetRootPosition()) / llList2Rot(avatar, 1)) / llList2Rot(offsets, point); } return llGetRootPosition();
}
vector GetRootLocalRot() {
integer point = llGetAttached(); rotation root = llGetRootRotation(); if(point) return ((root / llList2Rot(llGetObjectDetails( llGetOwner(), [OBJECT_ROT]), 0)) / llList2Rot(offsets, point); return root;