Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Changing a rezzed object's rotation

Dakota Tebaldi
Voodoo Child
Join date: 6 Feb 2008
Posts: 1,873
02-05-2009 11:44
OK, once again, another scripting problem I can't seem to find help with. I'm coming to you guys because you are awesome.

OK, so I've got an object - let's call it Object A. Object A is scripted so that when a certain condition is met, it rezzes two other objects - Objects B and C. These objects are supposed to rez in a very specific position relative to Object A, so that when they're rezzed, Objects A, B, and C all "line up".

The problem is, a lot can happen to Object A between the time it is rezzed, and the time the condition which causes B and C to rez - Object A's position and rotation can have changed from their starting values. Objects B and C seem to rez in the correct -position- just fine, but I cannot get their -rotations- to update.

In other words, if I rez Object A, it automatically "faces" East. If I make it rez objects B and C right away, they rez in line, also facing East. If I rez Object A, then move it 3 meters in any direction, WITHOUT changing Object A's rotation, and then make it rez objects B and C, they will still rez in line, facing the same direction as Object A. If, however, I rez object A, and then rotate it so it is now facing North instead of East, and then make it rez Objects B and C, B and C will rez still facing East. They will not have rotated, and A, B, and C will thus not line up properly (although B and C will still line up fine with each other obviously).

Looking at the script, it seemed that B and C rez in the proper positions because of "llGetPos() + <position vectors>" in the llRezObject parameters. So, I dug around a bit and found llGetRot, and inserted it the same way in front of the rotation parameters. So, the function would look like this:

From: someone

llRezObject("Object B", llGetPos() + <2.68,-0.02,7.2>, <0.0,0.0,0.0>, llGetRot() + <0.0,0.0,5000,1.0>, 0);


The script compiles and saves just fine, but it doesn't fix the problem. Object B still always rezzes facing East, no matter which direction Object A is facing when the function is called.

I dug around some more, and tried this:

From: someone

llRezObject("Object B", llGetPos() + <2.68,-0.02,7.2>, <0.0,0.0,0.0>, llGetRootRotation() + <0.0,0.0,5000,1.0>, 0);


Which still makes no difference.

What gives? I know this can be done.
_____________________
"...Dakota will grow up to be very scary... but in a HOT and desireable kind of way." - 3Ring Binder

"I really do think it's a pity he didnt "age" himself to 18." - Jig Chippewa

:cool:
Pedro McMillan
SLOODLE Developer
Join date: 28 Jul 2007
Posts: 231
02-05-2009 12:31
The position you specify when rezzing objects is in region coordinates, so if your Object A is rotated, then you need to move the rezzing position round to match. Something like this ought to do I think:

CODE

llRezObject("Object B", llGetPos() + (<2.68,-0.02,7.2> * llGetRot()), <0.0,0.0,0.0>, llGetRot(), 0);
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
02-05-2009 13:38
Just be careful, if you plan to add things to rez later to it, make sure you orient the main prim back to the original rotation. I forgot about this when I was doing something and got some funky results.

If, when you make your object, you define the potion with the main prim on (lets make it easy) Zero rotation (<0, 0, 0>;) and you move it to test your objects rezzing, make sure if you add another object to be rezzed you put the coords in with when you start the script with the main prim <0, 0, 0> in the rotation.

Hope you understand what I'm trying to say, realize I didn't explain it very well. :P
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-05-2009 17:44
Try this:

CODE

vector rezzerPos = llGetPos();
rotation rezzerRot = llGetRot();
vector relativeRezPos = <2.68,-0.02,7.2>;
rotation relativeRezRot = <0.0,0.0,5000,1.0>;
llRezObject(
"Object B",
rezzerPos + relativeRezPos*rezzerRot,
ZERO_VECTOR,
relativeRezRot*rezzerRot,
0);


Note that <0.0,0.0,5000,1.0> is not a correct unit quaternion representing a rotation, but SL SHOULD normalize it for you. I hope the result is what you intend. I just kept it that way in the example.
Dakota Tebaldi
Voodoo Child
Join date: 6 Feb 2008
Posts: 1,873
02-05-2009 18:17
From: Hewee Zetkin

Note that <0.0,0.0,5000,1.0> is not a correct unit quaternion representing a rotation, but SL SHOULD normalize it for you. I hope the result is what you intend. I just kept it that way in the example.


I'm wondering if that had something to do with it. During the initial line-up phase, for some reason I had to enter that value in order to get the rezzed object facing the correct direction (trust me, it took me about half an hour, changing that number, until I finally got where I needed to be). But in any case, Pedro's code kept giving me some bizarre results; I eventually did what I probably should've done at the beginning: gave all three objects a 1x1x1m prim for a root, and arranged things such that when the objects were lined up properly, all three of the root prims occupied the exact same space, and facing the exact same direction. After doing this, I played with Pedro's suggestion for a while.

I found out that the proper code was this (I think - not in-world right this moment):

llRezObject("Object B", llGetPos() + <2.68,-0.02,7.2>, <0.0,0.0,0.0>, llGetRot() * <0.0,0.0,0.0,1>, 0);

So it turns out that with the new root prims on my objects, my original code worked, I just had to replace the + with a *. Of course I had to change a few of the position vectors, but I got rid of the pesky rotation problem and simplified everything.

Again, thanks everybody. I'm just learning all this stuff obviously, so I appreciate any help I get here.
_____________________
"...Dakota will grow up to be very scary... but in a HOT and desireable kind of way." - 3Ring Binder

"I really do think it's a pity he didnt "age" himself to 18." - Jig Chippewa

:cool:
arton Rotaru
Registered User
Join date: 27 Aug 2007
Posts: 43
02-05-2009 19:48
Try this:

llRezObject("Object B",offset_pos*llGetRot() + llGetPos() ,ZERO_VECTOR,llGetRot(),0);