llSetPos and relative positions
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
08-09-2009 09:02
I'm trying to use llSetPos() to move some items to preset positions relative to another object. One way to do it, I think, is to have the target object say (string)llGetPos()+offset*llGetRot() and have the item that's to move hear that and move to the appropriate position. However, there's a slight complication in that I've got several unlinked objects I want to move simultaneously. I could have the target object say a list of object names and offsets, and have the moving items figure out which they are to move to, based on that. But I'm wondering if there's a way to store the appropriate offset and rotation in the items I want to move and then have them calculate where they're supposed to go based on llGetObjectDetails(id,[OBJECT_POS,OBJECT_ROT]) in the listen event. Or am I over-complicating stuff? Afterthought -- is it as simple as this? list details = llGetObjectDetails(id, [OBJECT_POS, OBJECT_ROT]); vector pos = llList2Vector(details,0); rotation rot = llList2Rot(details,1); llSetPos(pos+offset*rot); I will test this when I can get in world.
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
08-09-2009 10:22
you dont even need the rot if the inworld object will always have the same facing.
you can also skip the variables and throw them right into your calculation by replacing the variable names with what you set them equal to.
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
|
08-09-2009 11:54
Thanks so much. In this case, I do need the rotation, too, because the object that attracts the other things is likely to get moved about. I'm also storing in the scripts the moving items' rotations when they're in place, so that I can do llSetRot(stored_rot*rot); to get them all the right way round and right way up when they arrive, as you showed me how to do almost a year ago to the day back in /54/7e/286147/1.html !
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-10-2009 17:32
DO NOT PEEK INNULA! Sorry, it sounded like a fun project and I started playing with it in between itching and baths //mother integer menuChan; integer primChan = -333479; vector origPos; rotation origRot;
integer randChan() { return (integer) llFrand(-1000000) - 1000000; }
default { state_entry() { llSetObjectName("mom"); menuChan = randChan(); origRot = llGetRot(); origPos = llGetPos(); } touch_start(integer n) { llListen(menuChan, "", "", ""); llDialog(llDetectedKey(0), "choices",["record offset", "move", "origin", "reset"], menuChan); } listen(integer channel, string name, key id, string msg) { if ("origin" == msg) { llSetPrimitiveParams([PRIM_POSITION, origPos, PRIM_ROTATION, origRot]); } llRegionSay(primChan, msg + "|" + (string)llGetPos() + "|" + (string)llGetRot()); } }
//children integer primChan = -333479; key primId; rotation momRot; rotation origRot; rotation recRot; rotation momRecRot; string cmd; vector posOffset; vector momPos; vector origPos;
mom(list input) { cmd = llList2String(input, 0); momPos = (vector) llList2String(input, 1); momRot = (rotation) llList2String(input, 2); return; }
default { state_entry() { llListen(primChan, "", "", ""); llSetObjectName("child"); origRot = llGetRot(); origPos = llGetPos(); } listen(integer channel, string name, key id, string msg) { primId = id; mom(llParseString2List(msg,["|"],[])); if ("record offset" == cmd) { recRot = llGetRot(); momRecRot = momRot; posOffset = llGetPos() - momPos; } else if ("move" == cmd) { rotation rotOffset = momRot / momRecRot; llSetPrimitiveParams([PRIM_POSITION, momPos + posOffset * rotOffset, PRIM_ROTATION, recRot * rotOffset]); } else if ("origin" == cmd) { llSetPrimitiveParams([PRIM_POSITION, origPos, PRIM_ROTATION, origRot]); } else if ("reset" == cmd) { llResetScript(); } } }
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
08-10-2009 19:09
From: Jesse Barnett DO NOT PEEK INNULA! Sorry, it sounded like a fun project and I started playing with it in between itching and baths //mother integer menuChan; integer primChan = -333479; vector origPos; rotation origRot;
integer randChan() { return (integer) llFrand(-1000000) - 1000000; }
default { state_entry() { llSetObjectName("mom"); menuChan = randChan(); origRot = llGetRot(); origPos = llGetPos(); } touch_start(integer n) { llListen(menuChan, "", "", ""); llDialog(llDetectedKey(0), "choices",["record offset", "move", "origin", "reset"], menuChan); } listen(integer channel, string name, key id, string msg) { if ("origin" == msg) { llSetPrimitiveParams([PRIM_POSITION, origPos, PRIM_ROTATION, origRot]); } llRegionSay(primChan, msg + "|" + (string)llGetPos() + "|" + (string)llGetRot()); } }
//children integer primChan = -333479; key primId; rotation momRot; rotation origRot; rotation recRot; rotation momRecRot; string cmd; vector posOffset; vector momPos; vector origPos;
mom(list input) { cmd = llList2String(input, 0); momPos = (vector) llList2String(input, 1); momRot = (rotation) llList2String(input, 2); return; }
default { state_entry() { llListen(primChan, "", "", ""); llSetObjectName("child"); origRot = llGetRot(); origPos = llGetPos(); } listen(integer channel, string name, key id, string msg) { primId = id; mom(llParseString2List(msg,["|"],[])); if ("record offset" == cmd) { recRot = llGetRot(); momRecRot = momRot; posOffset = llGetPos() - momPos; } else if ("move" == cmd) { rotation rotOffset = momRot / momRecRot; llSetPrimitiveParams([PRIM_POSITION, momPos + posOffset * rotOffset, PRIM_ROTATION, recRot * rotOffset]); } else if ("origin" == cmd) { llSetPrimitiveParams([PRIM_POSITION, origPos, PRIM_ROTATION, origRot]); } else if ("reset" == cmd) { llResetScript(); } } }
i like that you used mom instead of parent lol, unless it's an acronym for something else
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-10-2009 19:16
From: Ruthven Willenov i like that you used mom instead of parent lol, unless it's an acronym for something else After the 3rd hour of trying to figure out the rotation equation for the kids I was calling it mother****** but shortened it to mom 
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
|
08-10-2009 19:37
From: Jesse Barnett After the 3rd hour of trying to figure out the rotation equation for the kids I was calling it mother****** but shortened it to mom  lmao, wasn't all that done though with builder's buddy?
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-10-2009 19:49
From: Ruthven Willenov lmao, wasn't all that done though with builder's buddy? Yep, but peeking would have been cheating. Plus, I have been trying to distract my mind from the miserable itching. Anyways, that wasn't a record. It took me a few days to figure out how Skidz got those red balls to rezz on the corners & face centers of a skidz primz. Fortunately it does not take much to amuse me when I get bored 
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
|
08-10-2009 23:01
From: Jesse Barnett Yep, but peeking would have been cheating. Plus, I have been trying to distract my mind from the miserable itching. Anyways, that wasn't a record. It took me a few days to figure out how Skidz got those red balls to rezz on the corners & face centers of a skidz primz. Fortunately it does not take much to amuse me when I get bored  llGetScale / 2 then play with the signs and combinations =)
_____________________
| | . "Cat-Like Typing Detected" | . This post may contain errors in logic, spelling, and | . grammar known to the SL populace to cause confusion | | - Please Use PHP tags when posting scripts/code, Thanks. | - Can't See PHP or URL Tags Correctly? Check Out This Link... | - 
|
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
|
08-11-2009 04:07
From: Void Singer llGetScale / 2 then play with the signs and combinations =) Like now, for some reason my brain was not working at 100% capacity and it was not painfully obvious at the time. Of course once you have finished beating yourself up and have solved it, it seems easy offset = llGetScale() * 0.5 offset offset * -1 < -offset.x,offset.y,offset.z> < -offset.x,-offset.y,offset.z> < -offset.x,offset.y,-offset.z> < offset.x,-offset.y,offset.z> < offset.x,-offset.y,-offset.z> < offset.x,offset.y,-offset.z> < -offset.x,0,0> < offset.x,0,0> < 0,-offset.y,0> < 0,offset.y,0> < 0,0,-offset.x> < 0,0,offset.x> multiplied by rot gives you the 8 corners & 6 sides.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime. From: someone I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
|