Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Rotations and Tigers and Bears!

Gigs Taggart
The Invisible Hand
Join date: 12 Feb 2006
Posts: 406
02-26-2006 16:58
I'm trying to have a prim rotate in a way that it always rotates along the same local axis.

This is for a game I'm making and it will need to interact with physical objects so I can't use the omega functions.

Basically I want a spinning flap that always spins end over end. The problem is when I set it to spin correctly, if I change the orientation of it, it spins in crazy ways because apparently it's spinning relative to the world axes and not its own.

I'm afraid if I leave it like that the final orientation of the game will matter, which is not very desirable.

Here's what I have so far:

CODE

default
{
state_entry()
{
llSetTimerEvent(0.5);
}

timer()
{
rotation rot=llGetRot();
vector eul = <5,0,0>; //5 degrees per cycle
eul *= DEG_TO_RAD; //convert to radians
rotation spin = llEuler2Rot(eul); //convert to quaternion
llSetLocalRot(spin*rot);
}
}
Lindsey Dassin
Fallen Angel
Join date: 14 Sep 2005
Posts: 33
02-26-2006 17:51
It looks like you're applying "spin" to "rot", when you should be applying "rot" to "spin".

Will this do what you're looking for?

CODE

rotation ROT_INCR = < 0.04362, 0, 0, 0.99905 >; // 5 degrees around X

default {
state_entry() {
llSetTimerEvent(0.5);
}

timer() {
llSetLocalRot( ROT_INCR * llGetRot() );
}
}
_____________________
:wq
Gigs Taggart
The Invisible Hand
Join date: 12 Feb 2006
Posts: 406
Thanks
02-26-2006 18:12
Thanks for your help!