|
Csteph Submariner
Registered User
Join date: 24 Apr 2007
Posts: 60
|
08-16-2007 06:23
Hi I have an object which rezzes another object when touched. What I am having trouble with is setting the position of the new object so that it is offset from the original along the original's local axes. The original is at an arbitrary rotation and I can match the rotation fine in the new object, but the position offsets seem to only be along world axes.
Is there any way to do this?
tia
|
|
Day Oh
Registered User
Join date: 3 Feb 2007
Posts: 1,257
|
08-16-2007 06:40
There are a couple ways to do things like that. One way is using llRot2Fwd, llRot2Left, and llRot2Up. These functions give you unit vectors for the object's local axes. Example: llGetPos() + (10.0 * llRot2Fwd(llGetRot())) is 10 meters in the direction of the object's local X axis. Second way is multiplying your relative position by a rotation. Example: llGetPos() + (<10.0, 0.0, 0.0> * llEuler2Rot(DEG_TO_RAD * <0.0, 0.0, 45.0>  ) is 10 meters diagonally up the object's XY plane.
|
|
Csteph Submariner
Registered User
Join date: 24 Apr 2007
Posts: 60
|
08-16-2007 06:49
Perfect, thanks
|
|
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
|
having a similar problem....
09-13-2007 13:09
but trying to solve it this way takes me what looks like 90° off the orientation where i want to be...
lBuzz = llParseString2List(msg,([";"]),([]));
vector vMyoffset=llGetPos(); vector vBasoff = (vector)llList2String(lBuzz,3);
float offsetx = vMyoffset.x-vBasoff.x; float offsety = vMyoffset.y-vBasoff.y; llSetAlpha(0.0,ALL_SIDES);
vWarpDest = (vector) llList2String(lBuzz,0); rWarpRot = (rotation) llList2String(lBuzz,1); sWarpArr =llList2String(lBuzz,2);
warpPos(vWarpDest); llSetRot (rWarpRot);
vector newx=llRot2Fwd(rWarpRot)*offsetx; vector newy=llRot2Left(rWarpRot)*offsety; vector adj=newx+newy;
llSetPos(llGetPos()+adj);
so i show up at center destination then watch it place me about 90 degrees from where it should be... what have i done wrong this time?
|
|
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
|
09-13-2007 15:08
ok i know what my problem is... comparing the llGetPos's for original offset... if starting off it's not on world coordinates, phooey then.
the question now becomes:
how can i get the offset by local x,y instead of world?
or actually:
how can i get my location respect to something in terms of a rot2fwd, rot2left from it?
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
09-13-2007 15:12
Can you describe the contents of your list, and what you expect them to do? And the values that you put in them for the test thats failing?
|
|
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
|
09-13-2007 15:22
the ontents from my list are the parameters for getting to a position and rotating to a heading...
they are working fine, and so is setting my position at the end.
what is happening is i'm passing faulty data into the offset, as i'm getting offset in terms of world x and y....
what i need to do is get the rot2fwd and rot2left something would have to move to get to me, bsically... took me till now to understand. my 90° rotation is beacuse my vWarpRot at destination was facing south, 90°off of east.
what's coming through in the list, that's being taken as vBaseoff, is the central position of the base i'm starting from, that has various beams arranged around it. i'm trying to get beam A to arrive at pad point A at the base on the other side of the trip.
so comparing world position is (obviously) wrong. how do i get what i'm looking for? ther's no llGetRot2Axis of a position... that's kind of the function i'm trying to obtain... any suggestions?
nope, nothing yet...
|
|
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
|
09-13-2007 16:39
Right. ok, saw that i ca't get the position, so i decided to adjust the rot for Rot2Whatever... like so:
lBuzz = llParseString2List(msg,([";"]),([]));
vector vMyoffset=llGetPos(); vector vBasoff = (vector)llList2String(lBuzz,3); float offsetx = vMyoffset.x-vBasoff.x;
float offsety = vMyoffset.y-vBasoff.y; particles(); llSetAlpha(0.0,ALL_SIDES); vWarpDest = (vector) llList2String(lBuzz,0);
rWarpRot = (rotation) llList2String(lBuzz,1); sWarpArr =llList2String(lBuzz,2); ////////////// this is where it happens:
rotation funky = llEuler2Rot(llRot2Euler(ZERO_ROTATION) -llRot2Euler(llGetRot()));
vector newx=llRot2Fwd(rWarpRot*funky)*offsetx;
vector newy=llRot2Left(rWarpRot*funky)*offsety;
vector adj=newx+newy;
//////////// and that does it!! the difference in start rot from rotation east adjusted out //////////// by the variable "funky". there's probably a less cludgy way of doing it but //////////// I finally got where i could fix it!!
vector finalpos=vWarpDest+adj;
warpPos(finalpos); llSetRot (rWarpRot);
happy happy
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
09-13-2007 17:27
aren't rotations fun?
|
|
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
|
argh.. torii!! help again!
01-07-2008 17:57
*sigh* fabulous... been reding a lot on david wilcox' site, decided i wanted my TP beam to be a torus instead of a sphere.... ... and all the rotations (and rot2fwd etc) went to poop. any arrival point off of east or west orientation throws me off the plane of the arrival pad and of course one of the two is mirrored. been trying all day to normalize my torus rot... and foaming at the mouth. (axes: x is reversed z; z is reversed x; y is simply reversed.. what is that, <0,270,90>? forgot atm) and found an added quirk, probably an SL glitch... whenever i changed stuff in computation of arrival rot, or relative position to center (the rot2fwd etc)... my sittarget got messed up, neccessitating continual re-adjustment. this stuff is all in a part of script that happens on recieving listen cue, sittarget is in default state entry.... weird. besides a tip on how to crunch the new beam that does not share the rezzer's rotation, any idea what's going on with the 'effective' sittarget rotation changing? thanks, all... /////////// ///SCC Teleport Beam // Warppos, texture anim and particle functions excluded ////////////
default
{ on_rez(integer start_param) { COMCHAN = start_param; llSetPrimitiveParams ( [PRIM_PHANTOM,TRUE,PRIM_TEMP_ON_REZ,TRUE]); llListen(COMCHAN, "", NULL_KEY, ""); //llLoopSound("",0.1); }
state_entry() { llSitTarget(offset,rot); llSetCameraEyeOffset(<-1, 0, -3.5>); llSetCameraAtOffset(<0, 0, 0.3>); initAnim(); ////////////////////////////// //// tried setting 270 instead of -90, no joy... works facing east, inverts //// everything going west and getts not only rot but rot2fwd way //// off for any other orientation... //////////////////// gollygosh = llEuler2Rot(<0,-90*DEG_TO_RAD,180*DEG_TO_RAD>); rot=llEuler2Rot(llRot2Euler(llGetRot())+(DEG_TO_RAD*<0,0,0>));
llListen(COMCHAN, "", NULL_KEY, "");
avatar = llAvatarOnSitTarget();
ANIMATION = llGetInventoryName(INVENTORY_ANIMATION, 0);
} listen(integer channel, string sName, key kID, string msg) { if (channel == COMCHAN) {
if(msg=="die") { llDie();
} if(msg!="die"&&avatar==NULL_KEY) { llDie(); } else //llPlaySound("",0.5); particles(); llSetAlpha(0.0,ALL_SIDES);
lBuzz = llParseString2List(msg,([";"]),([])); vWarpDest = (vector) llList2String(lBuzz,0); rWarpRot = (rotation) llList2String(lBuzz,1); sWarpArr =llList2String(lBuzz,2);
vector vMyoffset=llGetPos(); vector vBasoff = (vector)llList2String(lBuzz,3); float offsetx = vMyoffset.x-vBasoff.x; float offsety = vMyoffset.y-vBasoff.y; ////////////////////////////// ////What do i do here, or in setting the rotaion gollyogosh? //////////////////// rotation rMyRot = llGetRot()/gollygosh; rotation funky = llEuler2Rot(llRot2Euler(ZERO_ROTATION) -llRot2Euler(llGetRot())); vector newx=ZERO_VECTOR-(llRot2Up(rWarpRot*funky)*offsetx); vector newy=ZERO_VECTOR-(llRot2Left(rWarpRot*funky)*offsety); vector adj=newx+newy;
/////////////// if(sWarpArr != "TPC-NU") { finalpos=vWarpDest; } //////////////// if (sWarpArr == "TPC-NU") {
finalpos=vWarpDest+adj; } ////////////////// llSleep(0.2); ////////////////////////////// ////What do i do here, or in setting the rotaion gollyogosh? //////////////////// warpPos(finalpos); rotation squiggy=gollygosh*rWarpRot; llSetRot (squiggy); //llPlaySound("",0.5); llSleep(1.5);
if(avatar != NULL_KEY) { llSleep(0.3); llStopAnimation(ANIMATION);
llSleep(0.7);
llUnSit(avatar); llSleep(2.5); llDie(); }
if(avatar==NULL_KEY) { llSleep(3.0); llDie(); }
} } changed(integer change) { if(change == CHANGED_LINK) { if(avatar != NULL_KEY) { ANIMATION = llGetInventoryName(INVENTORY_ANIMATION, 0); llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION); llStopAnimation("sit_generic"); llStopAnimation("sit"); llStartAnimation(ANIMATION); } } } }
|