Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Spinning Object

Peter Linden
Registered User
Join date: 18 Nov 2002
Posts: 177
04-14-2003 14:22
Spinning Object

Summary: The following script will make an object spin. To use, merely
create any single-primitive object, attach this script, and it will
spin at a slow readable rate.

Usage: This is a great script for spinning signs, rotating doors and
silly attachments. It uses very little processing power and is amusing
if the object is attached to your head.

Script:
CODE

default
{
state_entry()
{
llTargetOmega(<0,0,1>, 2, 2);
}
}


Notes:
I've found that setting past 8 makes it spin a little too fast. To
speed the rotation of the spinning object, merely change the line
llTargetOmega(<0,0,1>, 2, 2); to read
llTargetOmega(<0,0,1>, 3, 2);
to go faster or
llTargetOmega(<0,0,1>, 4, 2);
to go even faster or
llTargetOmega(<0,0,1>, 5, 2);
to go yet faster. You get the idea.


Credits:
Script written by:
Cory Linden 2-27-03
Modified and commented by:
Peter Linden 3-3-03
RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
Original Thread
01-02-2005 00:39
/15/78/1899/1.html

This doesnt work if its attached to your av must a been nice when it did work
Draciav Svarog
Registered User
Join date: 12 Jan 2005
Posts: 1
01-17-2005 00:33
Is there anyway to get them to spin slower than the default?
Chromal Brodsky
ExperimentalMetaphysicist
Join date: 24 Feb 2004
Posts: 243
01-18-2005 07:37
From: Draciav Svarog
Is there anyway to get them to spin slower than the default?

Yes. The first argument to llTargetOmega() is a vector specifying rotation axis speeds in radians per second.
Because a radian is Pi * 2, or approximately 6.28, for your typical non-physical object,
CODE
llTargetOmega( <0,0,6.28>, 1, 1 ); 

should rotate it about one revolution per second, and,
CODE
llTargetOmega( <0,0,0.628>, 1, 1 ); 

should rotate about once every ten seconds.

The second parameter is spinrate, which you could also use to adjust the rate of spin. As I understand it, it acts as a multiplier on the first parameter. You can read more about how llTargetOmega() works here .
Chandra Page
Build! Code. Sleep?
Join date: 7 Oct 2004
Posts: 360
01-18-2005 10:47
From: Draciav Svarog
Is there anyway to get them to spin slower than the default?


Slower spin is simply a matter of using a smaller value for llTargetOmega's second parameter. For example, the following rotates at half the rate of Peter Linden's original example:

CODE
default
{
state_entry()
{
llTargetOmega(<0,0,1>, 1, 2);
}
}


You can achieve even slower rotation by using a fractional value for the spin rate parameter. I find that 0.5 works well for a rotating vendor display that I've built; it gives the object a little motion to attract attention, but doesn't spin so fast that it makes the customer nauseous. :)

If you're interested in precisely controlling the spin rate, you should keep in mind that the rate is measured in radians of rotation per second. There are 2 * PI radians around a circle, so to achieve a rate of one revolution per second, you could use the following:

CODE
llTargetOmega(<0,0,1>, TWO_PI, 2);


TWO_PI is an LSL constant equal to 2 * PI.
_____________________
Come visit the In Effect main store and café
Drawbridge (160, 81)
Particle effects, fashion, accessories, and coffee!
On the Web at SL Exchange and SL Boutique
Lance LeFay
is a Thug
Join date: 1 May 2003
Posts: 1,488
01-20-2005 20:21
I have but one question for all of you..


WHY?!
_____________________
"Hoochie Hair is high on my list" - Andrew Linden
"Adorable is 'they pay me to say you are cute'" -Barnesworth Anubis
Sudane Erato
Grump
Join date: 14 Nov 2004
Posts: 413
01-21-2005 07:52
My experiments with this appear to show that the rotation axes are always global. Could someone show a conversion to rotation around local axis?

Rotation is extremely complex!

Sudane
Chandra Page
Build! Code. Sleep?
Join date: 7 Oct 2004
Posts: 360
01-26-2005 12:19
From: Sudane Erato
My experiments with this appear to show that the rotation axes are always global. Could someone show a conversion to rotation around local axis?

Rotation is extremely complex!


I think this may do what you want, but I'm not in-world and I haven't tried it yet, so your mileage may vary:

CODE
llTargetOmega(<0, 0, 1> * llGetRot(), 2, 2);


In theory, this should rotate an object around its local Z-axis, rather than the global Z-axis. But it's only a theory.

And yes, rotation makes my head hurt. I should have paid more attention in math classes, but the desk was so comfy, and the lecture hall was so warm, and the professor's voice was such a soothing monotone...
_____________________
Come visit the In Effect main store and café
Drawbridge (160, 81)
Particle effects, fashion, accessories, and coffee!
On the Web at SL Exchange and SL Boutique
Mutamu Shark
Statistical Impossibility
Join date: 6 Jan 2005
Posts: 3
01-26-2005 15:28
the first 2 numbers: llTargetOmega(<0,0,1>, 1, 2); do something to axis but i have no idea what as sch >.> i want an object to rate when its put vertically, as it is a have spinning objects but you have to stand on em to look at em properly >.>
Sudane Erato
Grump
Join date: 14 Nov 2004
Posts: 413
01-27-2005 09:23
From: Chandra Page
... have paid more attention in math classes, but the desk was so comfy, and the lecture hall was so warm, and the professor's voice was such a soothing monotone...

Hehe :) Yes, my feelings exactly!

Thanks for the code. I'll try it out.

Sudane
Yoofaloof Pacer
Registered User
Join date: 12 Apr 2005
Posts: 27
Clockwise / Anti-clockwise
03-19-2006 09:17
How would you go about changing rotation of spin from clockwise to anti-clockwise?
Yoofaloof Pacer
Registered User
Join date: 12 Apr 2005
Posts: 27
03-20-2006 04:15
How do you get an object to spin in the opposite direction?
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
03-20-2006 18:03
From: Yoofaloof Pacer
How would you go about changing rotation of spin from clockwise to anti-clockwise?


Negative numbers :)
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Yoofaloof Pacer
Registered User
Join date: 12 Apr 2005
Posts: 27
03-21-2006 01:53
Cheers Travis!


Just tried negative numbers to no effect. Any more ideas?
Magnum Serpentine
Registered User
Join date: 20 Nov 2003
Posts: 1,811
07-09-2006 09:19
From: Peter Linden
Spinning Object

Summary: The following script will make an object spin. To use, merely
create any single-primitive object, attach this script, and it will
spin at a slow readable rate.

Usage: This is a great script for spinning signs, rotating doors and
silly attachments. It uses very little processing power and is amusing
if the object is attached to your head.

Script:
CODE

default
{
state_entry()
{
llTargetOmega(<0,0,1>, 2, 2);
}
}


Notes:
I've found that setting past 8 makes it spin a little too fast. To
speed the rotation of the spinning object, merely change the line
llTargetOmega(<0,0,1>, 2, 2); to read
llTargetOmega(<0,0,1>, 3, 2);
to go faster or
llTargetOmega(<0,0,1>, 4, 2);
to go even faster or
llTargetOmega(<0,0,1>, 5, 2);
to go yet faster. You get the idea.


Credits:
Script written by:
Cory Linden 2-27-03
Modified and commented by:
Peter Linden 3-3-03



This works good for rotating scripts in my Astronomy Room

From: someone
llTargetOmega(<0,0,1>,0.48,1.0); (For second life)


This is the setting for Second Life (I put a map of SL on a globe works pretty well )

From: someone
llTargetOmega(<0,0,1>,.06,2.0); (For Earth)


This is the setting for the Earth.

From: someone
llTargetOmega(<0,0,1>,-.14,1.0); (For Venus)


This is the setting for the planet Venus... Note the -.14 this makes the planet rotate backwards as it does in real life.

From: someone
llTargetOmega(<0,0,1>,.02,1.0); (For Mercury)


This is an example of an extremely slow rotation. The Planet Mercury takes almost 200 days to rotate about its axis but it rotates around the sun in 88 days.

I have also experimented with wild orbits of Moons...

here is the most extreme I believe that exist in my collection...

From: someone
llTargetOmega(<0,1,1>,0.11,1.0); (For the Lost lands)


I should add that I have made any globe that has a moon rotating around it phantom in an attempt to avoid having one prim solid inside another.
Fami Aoi
Registered User
Join date: 1 Aug 2006
Posts: 1
08-01-2006 02:04
I put all of these numbers in and the object sorta kinda just sits there...
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
08-01-2006 05:47
From: Fami Aoi
I put all of these numbers in and the object sorta kinda just sits there...

It worked for me... one thing to keep in mind, if you have the object right-clicked and selected in Edit mode (with edit panel open and all) it will sit still. The rotation only kicks in when you focus on something different.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
08-01-2006 06:38
The other values in the vector are the other global axes for rotation. If you want something like a drive shaft for a water wheel something like <1.0, 0.0, 0.0> or <0.0, 1.0, 0.0> will do what you want.

You can have non-zero values in two or all three spots in the vector for a tumble effect.

Setting the values of the vector to something other than 1.0 scales them appropirately, so <0.0, 0.0, -5.5> will spin in the opposite direction and 5.5 times faster than the same script with <0.0, 0.0, 1.0> for its vector value.

The spin rate will scale ALL the vector values equally, so llTargetOmega(<1.0, -3.2, 16.947>, 1.0, 1.0); will spin twice as fast around each axis (in a wild tumble) than llTargetOmega(<1.0, -3.2, 16.947>, 0.5, 1.0);

The gain appears not to matter for non-physical objects, as long as it's >0.

And yes, <0.0, 0.0, 1.0> * llGetRot() should make it tumble around it's local z axis.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Tex Nasworthy
Udder Disgrace
Join date: 2 Sep 2006
Posts: 1,330
09-17-2007 13:54
From: Eloise Pasteur
And yes, <0.0, 0.0, 1.0> * llGetRot() should make it tumble around it's local z axis.


I'm very new to scripting so please bear with me.

Here's the script I'm trying on a simple cube.

default
{
state_entry()
{
llTargetOmega(<0,0,1> * llGetRot(), 0.5, 2);
}
}

If I understood what I read correctly this should rotate the cube around it's local Z axis.
It does rotate around the local Z, when aligned with the global Z. But if I manually rotate the cube the script still rotates around the global Z. Maybe there is something about local and global axis's that I'm not undertsanding.

Any help would be appreciated.

Thanks,
Tex
Tex Nasworthy
Udder Disgrace
Join date: 2 Sep 2006
Posts: 1,330
09-17-2007 17:28
After a little bit of trial and error the script in the previous post works, sort of. LOL

If I manually rotate the prim prior to loading the script it rotates around the local Z.

If I rotate it again manually, or take it, rerez, and then rotate manually it rotates around what was the local z axis when the script was inserted. If I delete the script and then reinsert it, then prim rotates around the new local Z.

Signed newbie scripter still looking for clues,
Tex
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
09-17-2007 18:04
llTargetOmega always rotates an object on the global axes, regardless of how the object is rotated. It along with the omega value in the particles system have been a source of consternation of many. They always work on the global axis.