Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

More Rotation Madness + rotation helper for newbies

Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
08-28-2007 09:15
Newbies like me, who had a devil of a time understanding the way to write eulers, many forum explanations and wiki exposition notwithstanding. Took me a day and a half just to understand how the cardinal point are in Euler notation.... this silly gizmo could help as a learning tool, as moving visual examples often speak louder than words.

That said, and assured with llSay debugging that my scripts (Cheshyr Pontchartrain - style TP) are passing the right values, my rotation on arrival is still wrong, and apparently random!

First, I'll share my rotation cheat cheet, Object available free and open at Turmus (220.532, 64.006, 352.543) [mature sim] - second post will be my problem.

CODE

//Global Rotation Helper: touch it and it swings through cardinal and semicardinal points,
//listing Degrees, Euler expression and Rotation Quaternion of each in Settext, and Saying
//the Euler and the Quat. I put it in a prim pointed toward the front x, like compass needle.

//Variables
/////////////

//States
////////////

default
{
state_entry()
{
llSetText( "compass directions rotation helper, touch to use!!"+"\n"+"Free to copy, open source!",<1,1,1>,1.0);
}

touch_start(integer t)

{ llWhisper(0,"Cycling Through Rotations....");

llSleep(2);


llSetRot(llEuler2Rot(<0,0,0>)); //point to cardinal point. figuring those in PI was easy

llSetText( "East= zero degrees z rotation = llEuler2Rot(<0,0,0>)="+"\n"+ "rotation:"+(string)llGetRot(),<1,1,1>,1.0); //show the various types together.. helps fathom the relation

llWhisper(0,"East= llEuler2Rot(<0,0,0>)="+"\n"+ "rotation:"+(string)llGetRot());

llSleep(2); //Give time for lag and reading before passing on

//Rest is the same repeated for all 8 points


llSetRot(llEuler2Rot(<0,0,PI/2>));
llSetText( "North= 90 degrees z rotation = llEuler2Rot(<0,0,PI/2>)="+"\n"+ "rotation:"+(string)llGetRot(),<1,1,1>,1.0);
llWhisper(0,"North= llEuler2Rot(<0,0,PI/2>)="+"\n"+ "rotation:"+(string)llGetRot());
llSleep(2);

llSetRot(llEuler2Rot(<0,0,PI>));
llSetText("West= 180 degrees z rotation = llEuler2Rot(<0,0,PI>)="+"\n"+ "rotation:"+(string)llGetRot(),<1,1,1>,1.0);
llWhisper(0,"West= llEuler2Rot(<0,0,PI>)="+"\n"+ "rotation:"+(string)llGetRot());
llSleep(2);

llSetRot(llEuler2Rot(<0,0,PI+PI/2>));
llSetText( "South= 270 degrees z rotation = llEuler2Rot(<0,0,PI+PI/2>)="+"\n"+ "rotation:"+(string)llGetRot(),<1,1,1>,1.0);
llWhisper(0,"South= llEuler2Rot(<0,0,PI+PI/2>)="+"\n"+ "rotation:"+(string)llGetRot());
llSleep(2);

llSetRot(llEuler2Rot(<0,0,PI+PI/2+PI/4>));
llSetText( "S.East= 315 degrees z rotation = llEuler2Rot(<0,0,PI+PI/2+PI/4>)="+"\n"+ "rotation:"+(string)llGetRot(),<1,1,1>,1.0);
llWhisper(0,"S.East= llEuler2Rot(<0,0,PI+PI/2+PI/4>)="+"\n"+ "rotation:"+(string)llGetRot());
llSleep(2);

llSetRot(llEuler2Rot(<0,0,PI/4>));
llSetText( "N.East= 45 degrees z rotation = llEuler2Rot(<0,0,PI/4>)="+"\n"+ "rotation:"+(string)llGetRot(),<1,1,1>,1.0);
llWhisper(0,"N.East= llEuler2Rot(<0,0,PI/4>)="+"\n"+ "rotation:"+(string)llGetRot());
llSleep(2);

llSetRot(llEuler2Rot(<0,0,PI/2+PI/4>));
llSetText( "N.West= 135 degrees z rotation = llEuler2Rot(<0,0,PI/2+PI/4>)="+"\n"+ "rotation:"+(string)llGetRot(),<1,1,1>,1.0);
llWhisper(0,"N.West= llEuler2Rot(<0,0,PI/2+PI/4>)="+"\n"+ "rotation:"+(string)llGetRot());
llSleep(2);

llSetRot(llEuler2Rot(<0,0,PI+PI/4>));
llSetText( "S.West= 225 degrees z rotation = llEuler2Rot(<0,0,PI+PI/4>)="+"\n"+ "rotation:"+(string)llGetRot(),<1,1,1>,1.0);
llWhisper(0,"S.West= llEuler2Rot(<0,0,PI+PI/4>)="+"\n"+ "rotation:"+(string)llGetRot());
llSleep(2);

llSetText( "compass directions rotation helper, touch to use!!"+"\n"+"Free to copy, open source!",<1,1,1>,1.0);

}

}
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
Part 2 - Pimp my parsing!
08-28-2007 09:24
So my problem arises when a a menu tells a control script to get back an index for a direction from a notecard string (NE, S, etc...); then...

if(string = "N";)
{
rot=llEuler2Rot(<0,0,PI/2>;);
}

for instance and llWhispers on beam channel this info to the TP beam, along with destination. The beam warpPos's to destination fine, and then turns me to the wrong rot before taking it's leave.

llSaying both the euler, pre-transmission rot and post transmission rot all return the right value!!

Now i got logged out for inactivity.. going back in to get actual code snippets.. anyway i'm going:

rot>string>say>parse2list>string>typecast2rot

to get the final rot in the beam... i believe lol. BRB with the real thing.
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
the code bits in question
08-28-2007 09:40
alright this bit:


[CODESNIPPET]

rotation vWarpRot;

if(srot=="E";)
{ vWarpRot = llEuler2Rot(<0,0,0>;);}

if(srot=="W";)
{ vWarpRot = llEuler2Rot(<0,0,PI>;);}

if(srot=="N";)
{ vWarpRot = llEuler2Rot(<0,0,PI/2>;);}

if(srot=="S";)
{ vWarpRot = llEuler2Rot(<0,0,PI+PI/2>;);}

if(srot=="NE";)
{ vWarpRot = llEuler2Rot(<0,0,PI/4>;);}

if(srot=="SE";)
{ vWarpRot = llEuler2Rot(<0,0,PI+PI/2+PI/4>;);}

if(srot=="NW";)
{ vWarpRot = llEuler2Rot(<0,0,PI/2+PI/4>;);}

if(srot=="SW";)
{ vWarpRot = llEuler2Rot(<0,0,PI+PI/4>;);}

[/CODESNIPPET]



gets put in a list, indexed by the llDialog button numbers (made them notecard line count parallels) and gets said like this:


[CODESNIPPET]

string dMess = llList2String (lPointlist,((integer) message - 1))+";"+llList2String(lRotlist, ((integer) message - 1))+";"+llList2String(lCoord, 4);

// llSay(0,dMess); //debug, all values return correct!!!

llWhisper(COMCHAN,dMess);
particles();
llPlaySound("kMySound",1);

[/CODESNIPPET]

Which the beam parses to list with ";" dividers thusly:


[CODESNIPPET]


listen(integer channel, string sName, key kID, string msg)
{
if (channel == COMCHAN)
{
if(msg=="die";)
{
llDie();
}
else
lBuzz = llParseString2List(msg,([";"]),([]));

//llSay(0,msg);
llPlaySound("kMySound",0.5);
llSleep(0.2);
particles();
llSleep(0.3);
llSetAlpha(0.0,ALL_SIDES);
llSleep(0.1);
vWarpDest = (vector) llList2String(lBuzz,0);

rWarpRot = (rotation) llList2String(lBuzz,1);

// llSay(0,(string)rWarpRot); //Debug, gives correct quat!!!!!

warpPos(vWarpDest);

llSetRot (rWarpRot);



llUnSit(kID);
llSleep(0.5);

llDie();
}
}




[/CODESNIPPET]



So I'm probably blind to something obviously wrong, but all the way up to making it a quat for use seems ok?!?

Help?!

[edit - the gadget itself is in Turmus]

The place to see my malfunctioning tp is the same as for the globalrothelper... there are a few versions there, the "original prototype" in the middle of floor is the one i'm testing the rotation with. try destination #4, which is the TP in front of it, and should end up facing west. currently inverts 180°
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
truly stumped..
08-28-2007 12:46
tried everything from making it SetLocalRot (even though the beam should be root with me sitting on it), no difference. put llSay after setting rot as well, still tells me everything is fine, it's telling me the data it just used, and the data's right, but what it did was wrong.

tried setting rot by setting it to <0,0,0,1>*desiredRot, llSay gives me right answer again (smart fellow!) but then pulls it off wrong as usual.

truly desperate at this point. my simple direction pointer works, the application doesn't and i see no difference in the data!

this is a basic thing, setting to a fixed rotation. what is going wrong?

i'm ready to break down and just say WTF?! anyone? i'm in world for next 4 hours at least.. *sigh*

[23:09 cet -edit]

i observe that my rotation gets correctly executed.. rode the beam in every cam situation imaginable.

when i unsit from / llDie the beam (tried both).. THAT'S where my rotation gets inverted.

if i don't ride the beam at all, ignore via dialog and then stand i don't get the same pirouette.

why is this happening and what can i do??
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
08-28-2007 15:36
Thanks for the code. And don't think only newbies need help with this. It can be confusing to even the most advanced and old AVs. :)
_____________________
Cristalle Karami
Lady of the House
Join date: 4 Dec 2006
Posts: 6,222
08-28-2007 16:24
The first thing I can think of being wrong is an animation overrider. Those things sometimes tend to make poseballs throw you off into orbit. Not cool! Try testing it without an ao, if you are wearing one.
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
*sigh* nope...
08-28-2007 16:31
went so far as to do it naked and bald.. thank goodness we get no traffic ;-)

still makes me pirouette a quasi-random amount on unsit/die.

and now i'm sure the rotations are working, it's slow enough to see it face me forward then give me a twist as it exits stage null.

if any experts want to come se it in action, i'm getting dressed now ;-)
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-28-2007 19:14
Try throwing another sleep in before the llUnSit. It is strange in SL but after WarpPos it can act like you have some "velocity" (or "virtual momentum" might be a better term) and if you unsit without a llSleep you either go flying off or end up underground at the sim corner sometimes. It is possible it might be screwing up the llSetRot.


warpPos(vWarpDest);

llSleep(0.5);

llSetRot (rWarpRot);

//llSleep(0.5); //maybe another one here??

llUnSit(kID);
llSleep(0.5);

llDie();
_____________________
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
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
08-28-2007 19:21
This is just a wild guess, but does the beam have an llSitTarget set, and if so, might the sit target rotation account for the discrepancy?
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
08-29-2007 04:19
SitTarget : check.

but the rotation is null (using a nice standing anim). it is z-offset a bit, but my "beams" are lined up to not intersect the av with anything. i am not popping out violently, solved that in the first few atempts ;-)

animation considerations:

tried eliminating animation entirely, only stoping sits, tried not even stopping sits and going plywood box-style... the end twisting still happens...

so in the end that extra sleep sounds the most reasonable explanation, as the avvie does the little turn in the same CW sense that it makes the rotate in.

thnk you all for your suggestions!!

once more into the breach...
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
the mystery continues...
08-29-2007 05:00
no joy... moved the sleep from after unsit to before, same stuff happens.

even eliminating sittarget completely doesn't do it.

points:

1: erasing the beam while sitting on it leaves me standing in the right position, + or - what i assume to be the ~6 degrees of seperation form perfection i've read about in here.

2: standing from the beam does about the same thing

+edit+ leaving no unsit or die commands, and staying on the beam beyond it's temp prim life, then standing with stand button, i get the twist effect. Animation experts?

3: my twist funny is happening with llUnSit in script, and with llDie in script (trying both alternately), even after sleeping half a sec after rotate.

Tried eliminating unsit and die, and sure enough i'm in right position. if i stand from that , with stand button, i'm fine.

what is this that's happening? it's burning my little brain out trying to figure it!
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-29-2007 16:29
From: Chrysala Desideri
what is this that's happening? it's burning my little brain out trying to figure it!


I hate when that happens! 3 days of looking at a code to finally look one more time and see a simple solution. 3 days where you finally drag yourself away from the computer to catch some ZZZZZZZ's only to jump back up and try "one last thing".

I'll get a chance later to maybe try your code in beta and see if I can come up with something.
_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-29-2007 19:00
I don't have the full script but I would try working backwards from the actual warp. I made this little snippet and the rotation formula itself works fine and it will bring me through the cardinal points as I rename the object. (I cheated and made the object name the cardinal point and the description the target):

string cardinal;
float carrot;
vector targetPos;


reset()
{
vector target;
targetPos = (vector) llGetObjectDesc();
target = (targetPos- llGetPos()) * (ZERO_ROTATION / llGetRot());
llSitTarget(target, ZERO_ROTATION);
llSetSitText("Teleport";);
}
default
{
state_entry()
{
reset();
}

on_rez(integer startup_param)
{
reset();
}

changed(integer change)
{
cardinal = llGetObjectName();
if (cardinal == "N";)carrot = PI/2;
if (cardinal == "NE";)carrot = PI/4;
if (cardinal == "E";)carrot = 0;
if (cardinal == "SE";)carrot = PI+PI/2+PI/4;
if (cardinal == "S";)carrot = PI+PI/2;
if (cardinal == "SW";)carrot = PI+PI/4;
if (cardinal == "W";)carrot = PI;
if (cardinal == "NW";)carrot = PI/2+PI/4;
llUnSit(llAvatarOnSitTarget());
llSetRot(llEuler2Rot(<0,0,carrot>;));
reset();
}
}
_____________________
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
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
08-29-2007 19:46
WooT! Glad to see you figured out the problem Chrysala!!!
_____________________
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
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
Mystery Solved - more or less
08-29-2007 22:22
The problem is solved, but some doubts as to the precise mechanism involved remains with me..

The problem was sloppy coding, pure and simple. I was unsitting a non attributed key variable, a holdover from retouching the script 1000 times.

One i changed it to the varibale holding the sitter's key, all was peachy keen with pose, rotation, with and without AO atachments on.. sweet.

What I don't get is why when i removed the unsit call entirely and just let it die, that i got that spin thing. Maybe I don't understnd the differences in what happens in stand vs. unsit vs. object llDieing vs. deleting object manually.

stand button and manual delete left me getting up fine. letting it die without an unsit turned me, as did unsitting a null key (silly me).

thanks everyone for the help... got me looking at the right things!
Galena Qi
Registered User
Join date: 9 Sep 2006
Posts: 249
09-17-2007 17:49
Chrysala;

Is your rotation demo tool still available? I went to the SLURL you gave at the front of this message (nice place!) but didn't see anything labeled that way. It would be a great help to a project I'm working on.
Chrysala Desideri
Scarlet Scriptrix
Join date: 4 Mar 2007
Posts: 65
09-19-2007 15:04
lol yes still available, but have moved things around and routed TP's of recent, so not as easy to find.

it will always be same sim, parcel (maybe, building is on multi parcels) and floor. ATM outside the office by the zen garden, may move around, but always on level -4. i have to do somehing about how i numbered the place too lol.

going to do an even better tool too, as i've run up against some other problems i'm sure are common in moving objects seperately... just as soon as i've fully understood them myself!

93/93...

P.S. not really labeled as such, it's just sitting there with it's hovertext on... looks like a compass needle flattened. just right click and take copy.. there's 2, 1 gives cardinal rots, the other displays it's rotation (you have to rotate it editing) in eul deg and quat. one green, one red, don't remember offhand which is which.