Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

rez object with rotation related to prim.

Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
05-28-2008 21:10
Heres the thing:
I want to rez an object, say a hottub, in the corner of a floor prim of a house which could have any arbitrary rotation.

Only script 4 and 5 rez with correct location and rotation but if I turn the prim the object rezzes in the same location regardless of which rotation the rezzing prim is.

I have used previous examples from this forum and have spent at least 50 hours and a couple of months (on and off) on this so, as always, my last resort is to ask for help. I have made a very serious attempt in the last couple of days but it eludes me. I've probably missed or screwed one that does work. Please correct one of these for me. I'm sure others could benefit too.
Also if you could point out the major problem other than Rotations are a PITA.
I thank you for even looking.
I have placed 5 test prims setup here @ http://slurl.com/secondlife/Bangu/238/198/501 They can be copied and abused and have full perms.
CODE

//test script1
vector Angle = <0,0,53>; //Enter a vector rotation
rotation quat; //your rotation converted to quat
vector pos;

default
{
state_entry()
{ llSay(0, " Is ready");
pos = <1,1,1>;
vector eul = Angle; // in Euler form..
eul *= DEG_TO_RAD; //convert to radians...
rotation quat = llEuler2Rot( eul ); //convert to quaternion..
}
touch_start(integer total_number)

{
llSay(-565651,"remove");
llSleep(1);
llRezObject("Test1", llGetPos() + pos, <0,0,0>, quat,42); //quat inserted
}


//THIS ONE IS JUST PLAIN BROKEN!
CODE

//test script2
integer rot;
rotation dorot;
vector pos;
default
{
state_entry()
{
llSay(0, " Is ready");
vector pos = <1,1,1>;
rotation rot = <0,0,53,1>;
}

touch_start(integer total_number)
{
llSay(-565652,"remove");
llSleep(1);
llRezObject("Test",llGetPos()+ pos, <0,0,1>,<0,0,0>,llSetRot()*<0,0,rot,1>, 0);
}
}



CODE

//test script3
integer rot;
rotation dorot;
vector pos;
default
{
state_entry()
{
llSay(0, " Is ready");
rot = 53;
pos = <1,1,1>;
llSay(0, "Ready!");
}

touch_start(integer total_number)
{
llSay(-565653,"remove");
llSleep(1);
llRezObject("Test3", llGetLocalPos() + pos, <0,0,0>,<0,0,rot,1>,0) ;
}
}


CODE

//test script4
vector rot;
rotation dorot;
vector pos;
default
{
state_entry()
{
llSay(0, " Is ready");
pos= <1,1,1>;
rot= <0,0,53>;
dorot = llGetLocalRot() * llEuler2Rot(rot * DEG_TO_RAD);
}

touch_start(integer total_number)
{
llSay(-565654,"remove");
llSleep(1);
llRezObject("Test4",llGetLocalPos()+pos,<0,0,0>,llGetLocalRot()+<0,0,0,1>*dorot,0) ;
}
}

CODE

//test script5
vector rot;
rotation dorot;
vector pos;
default
{ state_entry()
{
llSay(0, " Is ready");
rot= <0,0,53>;
dorot = llGetRot() * llEuler2Rot(rot * DEG_TO_RAD);
pos = <1,1,1>;
}

touch_start(integer total_number)

{
llSay(-565655,"remove");
llSleep(1);
llRezObject("Test5",llGetPos()+pos,<0,0,0>,<0,0,0,1>*dorot,0) ;
}
}

_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
05-30-2008 18:15
Well, I've re-read the wiki, searched llRezObject with google and spent a few more hours moving bits of code around, breaking, fixing and I don't get it.

I'll pay someone to fix it. Any takers before I hop over to help wanted? Or where can I buy such a script?
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
05-30-2008 20:30
Thanks to Talon Brown who popped in and pointed me to this OLD fix which I didn't find:
/54/f2/150751/1.html#post1342846
Which now I can see.
CODE
 llRezObject("Test4",llGetPos() + pos * rot, ZERO_VECTOR, rot, 0) ;
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------
Kornscope Komachi
Transitional human
Join date: 30 Aug 2006
Posts: 1,041
05-31-2008 21:41
Well, I'm afraid that after further testing it does not work as required.
CODE

//test script4.3
vector rot;
rotation dorot;
vector pos;
default
{
state_entry()
{
llSay(0, " Is ready");
pos= <0.9,1,-0.10>;
rot= <0,0,90>;
dorot = llGetRot() * llEuler2Rot(rot * DEG_TO_RAD);
}

link_message(integer sender, integer num, string message, key id)
{
if(message == "RezHottub"){
llSay(-565656,"remove");
llSleep(1);
llRezObject("hottub1a",llGetPos()+pos*llGetRot(),<0,0,0>,llGetRot()*dorot,0) ;
}

if(message == "RemHottub"){llSay(-565656,"remove");}
}
}

I wanted to place the tub in the corner and rotated 90deg. After rezzing, it is in the correct place and almost correct but odd rotations which must come from llGetPos()+pos*llGetRot()
x =359.65
y =0.05
z =270
Other times the hottub might rez at other angles which are way off.

Back to the drawing board or move to another project for a while and give it another rest.
_____________________
SCOPE Homes, Bangu
-----------------------------------------------------------------