Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotation on Rez

Yrrek Gran
Crackpot Inventor
Join date: 20 Oct 2006
Posts: 209
01-10-2008 06:43
For the life of me, I do not understand rotations at all. Probably never will figure it out.

My problem, a pier that rezzes boats. I need the boat to rez parallel to the pier but no matter what I do, it is rezzed 90 degrees.

Someone please help :)

CODE


integer readytorez;
float REZTIMER = 60;

default
{
state_entry()
{
readytorez = TRUE;
llSetColor(<1,1,1>, ALL_SIDES);
}

touch_start(integer total_number)
{
if(readytorez)
{
vector pos = llGetPos();
pos.x +=0.5;
pos.y -=1.0;
pos.z += 1.5;
llRezObject("Diegoland Kayak Blue v1.0", pos, ZERO_VECTOR,<0,0,0,0>, 1);
llSetColor(<1,0,0>, ALL_SIDES);
llGiveInventory(llDetectedKey(0), "BoatingDiegoland");
llSleep(5);
llGiveInventory(llDetectedKey(0), "Kayak Paddle");
readytorez = FALSE;
llSetTimerEvent(REZTIMER);
}
else
{
llWhisper(0, "Sorry, this station is not ready to create a new boat yet.");
}
}

timer()
{
readytorez = TRUE;
llSetColor(<1,1,1>, ALL_SIDES);
llSetTimerEvent(0);
}
}

CODE
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
01-10-2008 07:01
try

llRezObject("Diegoland Kayak Blue v1.0", pos, ZERO_VECTOR,llEuler2Rot(DEG_2_RAD*<0,0,90>;), 1);
Yrrek Gran
Crackpot Inventor
Join date: 20 Oct 2006
Posts: 209
01-10-2008 07:45
/me slaps forehead

Ah yes! I used to know that! lol

Thanks Squirrel
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-10-2008 14:43
and if you want to rez it relative to the piers rotation (so the pier can be placed at any angle try

llRezObject( "Diegoland Kayak Blue v1.0", pos * llGetRot(), llEuler2Rot(DEG_2_RAD*<0,0,90>;) * llGetRot(), 1);
_____________________
|
| . "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...
| -
Yrrek Gran
Crackpot Inventor
Join date: 20 Oct 2006
Posts: 209
01-10-2008 16:40
It is DEG_TO_RAD right? I get a function call mismatch type or number of arguments.

The more I try the more lost I am getting. One time had it rez in the correct position then rotate back to where I didn't want it.

I thought I would outsmart SL and rebuild the boat on the world coords that I wanted it to rez. Silly me, my boat went sideways! LOL!

This is not working and I just don't understand.

AHHHHHHHHHHHHHHH!
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-10-2008 16:47
Don't let it confuse you too much.

From: Void Singer
and if you want to rez it relative to the piers rotation (so the pier can be placed at any angle try

llRezObject( "Diegoland Kayak Blue v1.0", pos * llGetRot(), llEuler2Rot(DEG_2_RAD*<0,0,90>;) * llGetRot(), 1);


This shouldn't be multiplying pos by llGetRot(). It also is missing the velocity parameter, which is probably the reason you are getting the compilation error. But the parameter for the rotation should be good like that.
Yrrek Gran
Crackpot Inventor
Join date: 20 Oct 2006
Posts: 209
01-10-2008 17:41
Well, I thank you all for your help, but no workie! Everything that I thought I knew is now just a pile of mush.

/me wonders if I can rotate the sim to match the kayak?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-10-2008 18:28
whoops
CODE

llRezObject( "Diegoland Kayak Blue v1.0",
llGetPos() + offset_from_rezzor * llGetRot(),
ZERO_VECTOR,
llEuler2Rot( <0, 0, 90 * DEG_2_RAD> ) * llGetRot(), //-- Assumes only the z axis of the rezzor is rotated in the initial build
1);

that's the code from most holovendors and similar to what most build in a box solutions use to position builds

for a static build you can eliminate the get pos line and just put in your already calculated postion, but it's nice to have if you ever want to move the build or change it's rotation, similarly euler 2 rot line you can omit the * llGetRot protion and just use your calculated rot

sorry for the confusion =/
_____________________
|
| . "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...
| -
Yrrek Gran
Crackpot Inventor
Join date: 20 Oct 2006
Posts: 209
01-11-2008 11:59
Ok, I have tried everything to no avail.

It appears that the boat rezzes correctly for an instant, bow to the south, then rotates back to the original position. Bow to the east.

This brings me to another question. When the boat was built, the bow was facing east. From my experience any object created then taken back to inventory will be rezzed back to the origional rotation, correct?

My question is, can the default rez rotation be changed in the object itself? Is it a linked prim problem? Could it have something to do with the reference selection, Local, World when it was taken into inventory?

This should not be this difficult! lol :))
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
01-11-2008 12:18
From: Yrrek Gran
It appears that the boat rezzes correctly for an instant, bow to the south, then rotates back to the original position. Bow to the east.

I would suspect that a script in the boat itself is doing something strange. Try this: make a copy of the boat, remove (or set to not running) all scripts in the copy, and try the same with that copy. If it rezzes and stays in the proper orientation, you need to look through the boat's scripts, not the object doing the rezzing.
Yrrek Gran
Crackpot Inventor
Join date: 20 Oct 2006
Posts: 209
01-11-2008 12:37
From: Hewee Zetkin
I would suspect that a script in the boat itself is doing something strange. ....... If it rezzes and stays in the proper orientation, you need to look through the boat's scripts, not the object doing the rezzing.


Ahh! Good idea Hewee! Will give it a try as soon as I can.

Thanks :)
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
rezzing a regular triangle
01-11-2008 13:22
I am writing a geodesic dome script (I know that there are others, I just want to write one). I can't seem to get the rotation of the triangular faces right. I have three points for the triangle, p0, p1, and p2 and I am trying to rez a thin prism prim with corners at those three points. The following code almost works for setting the rez rotation but almost all of the faces are slightly off. What am I doing wrong?

<php>
vector left = p1 - p2;
vector up = (p0 - p2) % (p1 - p2);
vector fwd = left % up;
rotation rot = llAxes2Rot(fwd, left, up);
</php>
Ollj Oh
Registered User
Join date: 28 Aug 2007
Posts: 522
01-11-2008 18:45
To globaly rotate a RELATIVELY rotated prim relative to a another HOWEVER rotated prim just use this rotation:
TARGETrotation = RELATIVErotation / HOWEVERrotation

For parallel alignment:
TARGETrotation = llEuler2Rot(0,0,0) / HOWEVERrotation

can i has physical prim chains now?
Yrrek Gran
Crackpot Inventor
Join date: 20 Oct 2006
Posts: 209
01-12-2008 07:56
Yep! An onRez rotation call burried in the middle of the boat script!!!:(

Thanks Hewee, and to everyone who helped me. Guess what? I almost understand rotations now, lol!

The final rotation script:

CODE


vector pos = llGetPos();
pos.x -=.755;
pos.y +=1.5;
pos.z += 1.5;

llRezObject("Diegoland Kayak Blue v1.05", pos, ZERO_VECTOR, llEuler2Rot( <0, 0, 270 * DEG_TO_RAD>), 1);

CODE
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-12-2008 18:19
it's generally safer to do all rotations as muliplication (division may work in some global cases but doesn't give the assumed behavior in local rotations, gives a fliping kind of action, first one way, then another)

rotate an object around the global (sim) axis (think of it a pin into the ground)
curent rotation * new rotation amount

rotate an object around the local objects axis (think of an axle)
new rotation amount * current rotation

set a rotation globally
just the rotation

I wrote out some more rotation formulas including reversing directions and rotating around an offset point (and bugs regarding set prim params) here https://wiki.secondlife.com/wiki/User:Void_Singer/Rotations all tested.
_____________________
|
| . "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...
| -