Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rez, Rotation, Translation

Lillani Lowell
Registered User
Join date: 5 Apr 2006
Posts: 171
07-13-2006 00:23
Okay, I'm HORRIBLE with math and rotations and whatnot.

This is what I'm trying to do.

I have an object which rez's a cube on command. What I need to do with this cube is to rez the cube sharing the root prim's rotation and then translate it so it lines up along the local X/Y with a cube already linked to the root. I know the difference in location, and as long as the object is not rotated, the prim rez's and translates properly. But as soon as the whole object is angled, it will rez at the proper rotation but will not translate properly.

Let's say I have this.....

vPosition = llGetPos();
rRotation = llGetRot();

llRezObject( "cube", vPosition, ZERO_VECTOR, rRotation, 1 );

How do I make this newly rez'd cube translate into the same position as another cube which is linked to the root? (assume we know the difference/distance from root to child).

Did I explain this clearly enough? I don't know. If anyone is in-world and want me to show them..... :)
Marcuw Schnook
Scripter
Join date: 24 Dec 2005
Posts: 246
07-13-2006 07:43
Tell me about it.

I've been fighting, struggling, wrestling (and loosing) with rotations, quaternations and positions ever since I started working on teleporting/moving/rezzing objects...

Not to mention the global alignmetn (world coords/rotation) relative to object (root) or linked (local coords.rotation); pfff


It's pure horror....


Isn't there some (scripting) class that explains it once and for all? I'd be happy to learn.
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
07-13-2006 08:21
From: Lillani Lowell
But as soon as the whole object is angled, it will rez at the proper rotation but will not translate properly.

CODE

touch_start(integer total_number)
{
vector position = llGetPos(); // location of root object
rotation angle = llGetRot(); // rotation of root object
vector offset = <0.5, 0, 0>; // location of new cube relative to the root object

llRezObject( "cube", position + (offset * angle), ZERO_VECTOR, angle, 1 );
}

"offset * angle" is the important part. Basically, to translate things in local space of another object rather than in global coordinate system, you multiply the translation vector by rotation of the object which serves as 'root' of your own coordinate system.
Lillani Lowell
Registered User
Join date: 5 Apr 2006
Posts: 171
07-13-2006 10:49
Thanks Joannah, that works beautifully, you're awesome. :)
Linnian Sugar
Registered User
Join date: 30 Mar 2005
Posts: 31
07-24-2006 05:31
this fixes my problem sort off but its can seem to get an item right that has rotaion any more help?
Linnian Sugar
Registered User
Join date: 30 Mar 2005
Posts: 31
07-24-2006 06:00
Oh hold on!! after downing jug of energy drink it came clear to me, looks more like this now

vector position = llGetPos(); // location of root object
rotation angle = llGetRot(); // rotation of root object
vector offset = <0, 3.50000, 0.02964>; // location of new cube relative to the root object
rotation offset2 = <0.00010, 0.00000, -1.00000, -0.00015>;

llRezObject( "elbow up", position + (offset * angle), ZERO_VECTOR, offset2 * angle, 1 );


added a nother offset I *'s that to angle