Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

rotate about an arbitrary point.

Grafikimon Oh
Grafik Design
Join date: 1 Feb 2007
Posts: 35
02-11-2007 14:57
I want to make a object rotate around a point but not neccessarily its center.

for example if you hand a ring around your wrist and began to spin your wrist the ring would spin at the point of contact not the actual center of the ring.

is this possible?
AJ DaSilva
woz ere
Join date: 15 Jun 2005
Posts: 1,993
02-11-2007 17:30
To do it client-side you need to have the root prim of the object at the centre of rotation, so add a transparent one if there isn't one there.

Server-side you can do it like this:
CODE
offsetRot(vector rotPoint, rotation rotAngle)
{
rotation newRot = llGetRot() * rotAngle;

vector currentPos = llGetPos();
vector newPos = rotPoint + ((currentPos - rotPoint) * rotAngle);

llSetPrimitiveParams([PRIM_POSITION, newPos, PRIM_ROTATION, newRot]);
}
Grafikimon Oh
Grafik Design
Join date: 1 Feb 2007
Posts: 35
02-11-2007 18:51
one of those headaches i guess. using an extra prim or using a a complex script.

which is the better way to go system wise.

thanks for the code. I'll get it working and see how it goes