Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Script: Rotating linked objects.

Dragon Grimm
Not a junior member.
Join date: 2 Apr 2003
Posts: 8
05-24-2003 23:33
This script makes a linked object rotate continuously, the way it works is that when you apply this script to a child object (the object you want to rotate) it will check the parent's local rotation wich seems to be the only way to do this.

CODE

default
{
state_entry()
{
//multiply desired rotation (<x,y,z>) with local rotation of parent, rate is PI, gain is 1.
llTargetOmega(<0,0,0> * llGetLocalRot(),PI,1.0);
}

}


The reason the script multiplies the rotation with the local rotation of the parent is that all linked objects use the local rotation of it's parent instead of the world rotation axis so that it stays the same when the parent object is rotated at a different angle. This may seem a bit simple because all it is is the modified rotate function but I felt I needed to address this change because many people don't know this little piece of extra code needed.

Usage:
First link the object you want to rotate with the main object.

Make sure you select the rotator object first, then the main object so that the main object becomes the parent.

After this is done select the rotating object using select individual, then simply put the script in that object and you're all set.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
Original Thread:
01-21-2005 13:28
/15/8b/2698/1.html

I need an added idea

Thanks much. I was looking for this kind of information.

But this script seems to be usable when the moving object is just one, no linked.
I make a linked object and make it move by the gross, and when I want it to link
to another object that must be a root one, what should I do?
Anyone, let me know, plz.
Punklord Drago
Registered User
Join date: 8 Sep 2004
Posts: 22
01-25-2005 06:01
take out the * llGetLocalRot()
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
01-28-2005 07:14
Imagine a helicopter.
Like this ;)

X <--- a propeller
I <--- a shaft
O <--- a body

You can make a propeller with a shaft spin by the only TargetOmega script.
But you'll find that it will not work well when it comes to link it to the body.
The script will make even the body spin.
Useing the avobe script, you'll find just the shaft spin,
the body and the poropeller remain stationary, I don't know why.
Barbarra Blair
Short Person
Join date: 18 Apr 2004
Posts: 588
01-28-2005 10:03
You would need to rotate the blades and shaft separately (but together). However, you probably don't need to rotate the shaft, really.
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
01-31-2005 07:14
Barrbara, you're right in deed.
But the point is that I need to rotate a couple of objects linked each other
together, and keeping to rotate those objects, linking them to the other stable one.

Imagine, there are three blades and a body, no shaft.
I cross three blades and link them one another to build a propeller. And I can rotate
them completely together. Then, can I link them to the body
Simple rotating script doesn't work at all. What about Dragon's (above) one
You'll see just the (former) parent blade spin (worse sitll by different axis) and
other blades remain stationary in spite of getting along with until a while ago.

Someone might say,"Build a propeller of one prim like a saucer tube, and paint
blades by texture". Ya, you're right for my example, but what I want to do is....
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
01-31-2005 21:20
If all you want to do is to rotate a blade around it's end instead of it's middle, that's easy.

Take a cube and use cut to remove 50% of it: begin = 0.375 end = 0.875

Now make the blade out of that with the Y dimension being the length of the blade X 2 (you cut away 1/2 of Y in the 1st step).

By doing this, you will see that the centerpoint of the blade prim is now at one end (the old center) of the remaining prim. By cutting the prim another 25% you can put the centerpoint in a corner instead of the middle of one end... Makes for some interesting possibilities there as well.

The only downside is the max blade length is reduced from 10 to 5 meters... If you need longer blades thatn that you'll need to figure out some other method. The draw blades on a disk method has the same limitations though (1/2 of 10 meters per blade) so there's no loss using my method.

This works for making single prim doors as well... just edit the rotation script to change the axis of rotation to match whatever final prim shape you end up using...
Gryphon Stonebender
Registered User
Join date: 25 Jan 2005
Posts: 24
02-01-2005 19:57
OK this works well... What is "linking objects"? I'm sure I do it, but I do not know it bt that name?

Also is there a way to control the speed of the spin? Does changing the llGetLocalRot(),PI,1.0); do somthing? what is the max/min?

thanks,
Racer Plisskin
Rezerator
Join date: 2 Jan 2005
Posts: 147
02-02-2005 19:35
Linking objects is what you do when you hit "<ctrl>+L" after selecting serveral prims you want to make into a joined group. The last prim selected is known as the 'base'/'root'/'parent' prim.

EG: make 3 spheres of different sizes, stack them verticaly with the largest on the bottom and smallest on the top. Select all 3 and link them to get a very basic snowman shaped object.

In the example above, llGetLocalRot is defining the axis of rotation (in relation to the base prim), the PI field represents how far to spin each second in radians (larger number is faster, smaller number is slower). The last field gets tricky and has to do with how 'physical' objects interact with each other OR 'how much force does the spin have?' I'm guessing it can be thought of as torque. EG: drop a ball on a spinning fan and it gets bounced off in some direction. The more torque, the harder the ball got hit and the less the fan was slowed down by the impact.

This link explains in more detail how llTargetOmega works to rotate a prim: http://secondlife.com/badgeo/wakka.php?wakka=llTargetOmega

Racer P.
gene Poole
"Foolish humans!"
Join date: 16 Jun 2004
Posts: 324
03-18-2005 23:08
Since you are multiplying the zero vector by the root prim's rotation, your net rotation vector will be zero as well, which causes llTargetOmega not to rotate anything. I would recommend using a non-zero literal factor, such as <0, 0, 1> or <0, 0, 0.1>. (Tested with 1.5.14).
Michael Psaltery
Registered User
Join date: 6 Jun 2004
Posts: 57
04-01-2005 15:24
The effect I have observed appears to involve the order in which you link the prims. In this case, if the propeller and shaft are children and the body is the parent of the object, then setting the target omega should work (at least it seems to in my scripts... until you attach an avatar to it, as with vehicles)

One probably more resource-friendly solution to the problem might be to use a texture with transparency and apply to a disc, using llSetTextureRotation() to animate it. This is used for wheels in the various vehicle examples I have seen.

From: Seagel Neville
Imagine a helicopter.
Like this ;)

X <--- a propeller
I <--- a shaft
O <--- a body

You can make a propeller with a shaft spin by the only TargetOmega script.
But you'll find that it will not work well when it comes to link it to the body.
The script will make even the body spin.
Useing the avobe script, you'll find just the shaft spin,
the body and the poropeller remain stationary, I don't know why.
Arcane Muromachi
Registered User
Join date: 21 Mar 2005
Posts: 1
Probs
04-06-2005 16:27
Here is the problem I am having... I have multiple objects, around 6, that I have spinning in different directions at diff speeds. When I link them together, take the linked object and then drop (rez) the object anew... The objects refuse to move... I tried the script u listed and added them to each object in the link one at a time, but still it doesn't move... I tried making them all phantoms, didn't matter... They were moving before I took it and dropped it... The 6 objects are touching eachother, and it almost looks like their vibrating a little, as if they are not moving because they are colliding with one another, not sure as to why... Physics is off, so that isn't it... How do I get the parent and children prims to perform their different moves, or is this even possible?

Thanks,

Arcane
Komuso Tokugawa
Registered User
Join date: 3 Mar 2005
Posts: 93
04-23-2005 07:13
Has anyone got the script at the thread top to work?

I keep getting really weird results.


It seems to work when I build it (sometimes???) and then when I inventory it and re-rez it it sits there doing nothing.

Script resets make it jerk into motion, then it stops.

Occaisionally I'll leave it for awhile and then find the whole linked object rotating.

Any tips?

thank you,
kt
Komuso Tokugawa
Registered User
Join date: 3 Mar 2005
Posts: 93
04-23-2005 23:08
Has anyone got this to work?

I keep getting weird results.

It seems to work whne I build it, but when I take it and rerez it just sits there.
Sctipt restart makes it jerk, and then stop.
Sometimes after a while it starts rotating, but the whole linked object does it.

Any clues?

many thanks,
kt
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread
04-25-2005 08:15
/54/8a/44187/1.html
_____________________
i've got nothing. ;)