Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

teleport hack

Cro Sola
Registered User
Join date: 19 Jul 2006
Posts: 34
08-10-2006 03:33
ok i know a little of how it works but im still not sure of how some parts of it work

CODE

default
{
state_entry()
{
llSitTarget(<0,0,1>,<0,0,0,1>); // Set the target one meter above the center of the prim
llSetSitText("Pose!");
}

touch_start(integer total_number)
{
llSay(0, "Touched.");
}
}


this is a basic sit script what i want to know is the second part of the llsitTarget as in the part <0,0,0,1>; what is this part for and what do the numbers mean i have read that its got ot do with rotation but i dont get it please help.

ok the next part of the problem is do i need to add any extra code to get this teleport hack to work.
Aodhan McDunnough
Gearhead
Join date: 29 Mar 2006
Posts: 1,518
08-10-2006 03:37
It works this way: You "sit" the person at the destination of the teleport, then you unsit him so he will stand up.

The sit position is relative to the sit prim and is affected by the prim's rotation.
_____________________
Aodhan's Forge shop at slurl.com/secondlife/Rieul/95/213/107
Cro Sola
Registered User
Join date: 19 Jul 2006
Posts: 34
08-10-2006 03:46
yeah i get what it does and how it does it but how does rotation work, i know its <x,y,z,s> but how does the rotation work i dont get it.
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
08-10-2006 04:04
It can be even easier to have the "default" left-mouse click action to be set as "sitting action".

One click (touch) would do the TP trick.
No need for right-click,select "sit" from Radial menu anymore
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-10-2006 04:30
From: Cro Sola
yeah i get what it does and how it does it but how does rotation work, i know its <x,y,z,s> but how does the rotation work i dont get it.

Rotations in LSL are represented by quaternions. The s part of the rotation is equal to cos(theta/2) where theta is the angle you are rotatiing. The x, y, and z parts are a vector that points along the axis of rotation and has a length of sin(theta/2).

The quaternion <0, 0, 0, 1> represents a zero rotation (in fact, there is a constant called ZERO_ROTATION that you can use in place of it). That is, no rotation at all: the avatar will be aligned with the axes of the prim that has the script in it. The avatar will be looking in the direction of the prims x-axis (red), with the prim's y-axis (green) to its left and the prim's z-axis (blue) pointing, "up."
Aodhan McDunnough
Gearhead
Join date: 29 Mar 2006
Posts: 1,518
08-10-2006 04:33
From: Cro Sola
yeah i get what it does and how it does it but how does rotation work, i know its <x,y,z,s> but how does the rotation work i dont get it.


That's a quaternion. The easiest way to handle it is to set the angles x-rot, y-rot, and z-rot (in radians) in a vector to what you want, then perform an euler (vector) to rotation (rotation quaternion) conversion within LSL.
_____________________
Aodhan's Forge shop at slurl.com/secondlife/Rieul/95/213/107
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
08-10-2006 05:32
This will well help you out a bit more. This is in a format you are use to using, editing rotations directly is a bit more difficult. I believe this is in refernce to the object local axis. now if you put in 90,0,0 it will rotate sit posting in refference to the objects local rotation at the offset point you defined.
CODE
llSitTarget(<0,0,1>, llEuler2Rot(<0,0,0> * DEG_TO_RAD)); 


BTW. if you put in llSitTarget(ZERO_VECTOR, ZERO_ROTATION); this in a way turns off/cancels the sit postion also makeing other functions not work like llAvatarOnSitTarget not work.
Cro Sola
Registered User
Join date: 19 Jul 2006
Posts: 34
08-10-2006 06:19
ok thanks for all the input but im a complet noob when it comes to scripting, i would like to no in lamens (dumb ass) terms what the rotation funtion does for example

if i made a box and put my above code in it as in
CODE

default
{
state_entry()
{
llSitTarget(<0,0,1>,<0,0,0,1>); // Set the target one meter above the center of the prim
llSetSitText("Pose!");
}

touch_start(integer total_number)
{
llSay(0, "Touched.");
}
}


what would happen when i right clicked on the box and hit pose!

sorry im such a dumb ass
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
08-10-2006 07:20
The AVs root position will float 1 meter above the objects center (asuming the object has not been turned at a weird anlgle othere than <0,0,0>;). nothing more.

oh and when you touch it, the box will say "touched".
Bitzer Balderdash
Dazed and Confused
Join date: 21 Dec 2005
Posts: 246
08-10-2006 07:37
No need to apologise for being a "dumb ass" - not knowing an answer doesn't necessarily make you dumb :)

OK, to answer your question, the rotation <0,0,0,1> will not rotate you at all. It is a zero rotation.

I'm afraid that it is bordering on impossible to explain quaternions in layman's terms, since they are a mathematical representation of an arbitrary rotation about an arbitrary axis. Understanding what they do and how they work involved some fairly complex 3d visualisation and trigonometry, so, unless your math is pretty good, I would suggest that the best way to use them is by using llEuler2Rot which allows you to specify the angle to rotate by around the normal x,y,z axes, and converts this to a quaternion for you.

If you really want to know more about quaternions themselves, the wiki page (here) has a brief explanation, and also links at the bottom to math resource sites that go into much greater depth.

I would strongly reocmmend having pain-killers to hand before you start though, since some of that will really make your head ache.
Gattz Gilman
Banned from RealLife :/
Join date: 29 Feb 2004
Posts: 316
08-10-2006 07:47
here is a freebie teleport script
CODE

key lastAVkey = NULL_KEY;
vector target=<104.62897, 168.52283, 24.14328>;//enter the arrival position here

vector offset;
default
{
on_rez(integer params)
{

offset = (target- llGetPos()) * (ZERO_ROTATION / llGetRot());
llSitTarget(offset, ZERO_ROTATION);
}

state_entry()
{

offset = (target- llGetPos()) * (ZERO_ROTATION / llGetRot());
llSetSitText("Teleport");
llSitTarget(offset, ZERO_ROTATION);
}
touch_start(integer i)
{
llSay(0,"Right-click me, and select Teleport");
}
changed(integer change)
{
key currentAVkey = llAvatarOnSitTarget();
if (currentAVkey != NULL_KEY && lastAVkey == NULL_KEY)
{
lastAVkey = currentAVkey;
if (!(llGetPermissions() & PERMISSION_TRIGGER_ANIMATION))
llRequestPermissions(currentAVkey,PERMISSION_TRIGGER_ANIMATION);
llUnSit(currentAVkey);
llStopAnimation("sit");
llResetScript();
}
}
}

_____________________
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
08-10-2006 11:51
What the rotations do, in general, is rotate you around the prim that you're sitting on.

I can't remember the numbers of the top of my head, so I cheat and have a script that lets me set them and touch the object to say it's rotation.

<-0.70711, 0.00000, 0.00000, 0.70711> is 270º around X (or -90 if you prefer)
<0.70711, -0.00000, 0.00000, 0.70711> is 90º around X
<0.00000, 0.70711, 0.00000, 0.70711> is 90º around Y
<0.00000, 0.00000, 0.70711, 0.70711> is 90º around Z.

So... you can see that the numbers scale in the first three places represent something about the axis you're rotating around. If you're good with square roots you might spot that 0.707 is ?2/2 so the magnitude of the vector is 1. SL likes that, possibly insists on it.

As you tumble the prim you can get funnier numbers like: <0.46194, 0.19134, 0.46194, 0.73254> (which is 45º around each axis). This is why it gets rather tricky to put into words.

For the application you are talking about I'd suggest copying these numbers and pasting them one at a time into the rotation value in a sit script and seeing what they do.

If you'd like a more mathematical answer, the vecot you use for the sit position, <0,0,1> in your example, gets rotated by the rotation that you define. If your "sit" prim is orientated to the global axes you'll get things like sitting on your nose and back, one ear and at some whacky angle from these rotations.

The people suggesting working in Eulers are, for most of us, just right. We've been taught over the years to think of rotations that way, it works for us that way. Quaternions are counter-intuitive for the vast bulk of us - but they make a lot of things work faster in computer computations, so they're useful in that respect, possibly even essential.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Cro Sola
Registered User
Join date: 19 Jul 2006
Posts: 34
08-11-2006 06:52
thanks for all you help its clear up my question :)