Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

texture rotation: smooth?

Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
06-11-2008 18:49
This script does what I want, except the rotation is "jerky," like a cheap watch. I want it to rotate smoothly, like a Rolex. Is there a way to adjust something to make this script do that, or does anyone have a different one? Thanks -- couldn't find this issue in search. --Avion

float rotate;

default
{
state_entry()
{
rotate = 0;
llSetTimerEvent(.001);

}

timer()
{
rotate = rotate + 0.005;
if (rotate==10.1)
{
rotate = 0;

}
llRotateTexture(rotate,ALL_SIDES);
}
}
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
06-11-2008 20:49
Your timer event of 0.001 seconds isn't going to work, as the minimum period between events is 0.05 seconds and the llRotateTexture() function imposes a script delay of 0.2 seconds in any case.

This should do it, though the animation can get out of sync and may need a stop/start added every once in a while if you want it to "keep time" or anything:

CODE

float SPIN_RATE = 5.0; // radians per second

default
{
state_entry()
{
llSetTextureAnim(ANIM_ON | LOOP | SMOOTH | ROTATE, ALL_SIDES, 0, 0, 0.0, TWO_PI, SPIN_RATE);
}
}


I used 5 radians per second like you seemed to want from the timer event and amount in the script, though really you'd only get 0.005 radians every 0.2 seconds (0.1 rad/s) because of the script delay mentioned above. Change to taste.
Avion Raymaker
Palacio del Emperador!
Join date: 18 Jun 2007
Posts: 980
06-12-2008 19:51
Thanks a lot, Hewee. That is perfect. This is for a spinning galaxy, so the spin rate set to a very slow 0.02 R / sec here makes it look great.

--Avion