Rotate Child Prim not the Root how?

Recommended Posts

Hello i have look for many post and test many scripts and i not able to make a Link child Prim rotate around the root prim without moving the root. is this posible?

is there any help i will apreciate!

thanks

Edited by Lolita Erin

Share on other sites

Edited by Profaitchikenz Haiku
speeling

Share on other sites

If I'm understanding correctly, you're interested in having a child prim rotate around the root as if it was orbiting the root prim, not just rotating the child prim. I'm not sure if there's a more elegant way to accomplish this nowadays, but you can use a while loop to step through some simple trigonometry and progressively set the position of the orbiting child prim. I tore this little function out of one of my other projects and gave it a quick edit so it isn't going to do exactly what you're looking for, but it should show you how to do the math to plot a circle in a set number of slices.

```Xsurround(integer slices)  // slices refers to how smoothe of a circle gets plotted. Larger values make for smoother circles.
{// when run within a child prim, progressively sets the position in circle around X axis
integer count=0; //initialize the loop count
vector position=ZERO_VECTOR; //sets the centerpoint of the circle
float radius=1; //sets how far out from the centerpoint to set the position
while (count<=slices)
{
position.z = radius*llSin(radians * count); //calculates the z component of the circle
position.y = radius*llCos(radians * count); //calculates the y component of the circle
llSetPos(position); // sets the position, if this script is in a child prim it uses local coordinates
++count; //incriments the loop count
}
}```

You'll need to switch to a different function to set the position of a child prim from a root prim to really get what you're after. This doesn't change the rotation of the child prim, so you'll need to figure out where you want it to face with llRotBetween() and then use  llSetLinkPrimitiveParamsFast(linknum, [PRIM_ROT_LOCAL, desiredRoration]); to actually set it.

You may get some timing  issues if you use the fast versions of the llSet* functions, in that case you may want to use the regular functions or add some more padding by breaking the while loop out into a timer event so everything lands in sequence.

I can also send some example scripts or objects if you'd like.

Edited by Myrmidon Hasp

Share on other sites

Take a look at the examples in the section "Rotating Vectors" in the wiki article http://wiki.secondlife.com/wiki/Rotation.

It provides an example of how to rotate an object round a point in space, similar to Myrmidon Hasp's example above, explaining the calculations, but as Myrmidon says (and as the article notes), that's easy to change to make a child prim rotate round the root (the article has a note telling you how to do it).

Share on other sites

Each of these replies is telling you the same thing. If you are hoping to use llTargetOmega to make the child prim revolve around the root, you cannot do it without also rotating the root.  I suspect that's what you have been trying so far. llTargetOmega is a very helpful function but it is limited.  If you put it in the root prim, it rotates the entire linkset.  If you put it in a child prim, it rotates that child. All of the rotation is done client-side.  As far as the SL servers are concerned, none of the prims is actually rotating at all.  If you want to make a more complicated set of rotating objects, you need to make the servers do the work in a timed looping sequence by using llSetRot, llSetLocalRot, or the parameters in llSetLinkPrimitiveParams.  The mathematics can be rather complicated, but it's the only way to solve your problem.

Share on other sites
10 hours ago, Rolig Loon said:

The mathematics can be rather complicated, but it's the only way to solve your problem﻿.

The mathematics looks complicated, I think (at least it does to me) but fortunately there's no need to understand them in order to use them.    The example in the wiki's Rotation article shows how to do the operation (so long as people read the notes to the article too) without needing any particular mathematical knowledge -- that's why I can use them!

Over the road at SLU, Grandma Bates provides two very useful tutorials on rotations that I often still refer to.   The second one is particularly relevant here.

Quite seriously, I was completely at sea with rotations until someone who actually did understand the mathematics behind quaternions persuaded me that I didn't need to worry about it in order to use rotations in LSL. Just remembering a few basic rules and formulae, and knowing when and how to apply them,  now does the job for me.

Edited by Innula Zenovka

Share on other sites
6 hours ago, Myrmidon Hasp said:

If I'm understanding correctly, you're interested in having a child prim rotate around the root as if it was orbiting the root prim, not just rotating the child prim. I'm not sure if there's a more elegant way to accomplish this nowadays, but you can use a while loop to step through some simple trigonometry and progressively set the position of the orbiting child prim. I tore this little function out of one of my other projects and gave it a quick edit so it isn't going to do exactly what you're looking for, but it should show you how to do the math to plot a circle in a set number of slices.

```
Xsurround(integer slices)  // slices refers to how smoothe of a circle gets plotted. Larger values make for smoother circles.
{// when run within a child prim, progressively sets the position in circle around X axis
integer count=0; //initialize the loop count
vector position=ZERO_VECTOR; //sets the centerpoint of the circle
float radius=1; //sets how far out from the centerpoint to set the position
while (count<=slices)
{
position.z = radius*llSin(radians * count); //calculates the z component of the circle
position.y = radius*llCos(radians * count); //calculates the y component of the circle
llSetPos(position); // sets the position, if this script is in a child prim it uses local coordinates
++count; //incriments the loop count
}
}```

You'll need to switch to a different function to set the position of a child prim from a root prim to really get what you're after. This doesn't change the rotation of the child prim, so you'll need to figure out where you want it to face with llRotBetween() and then use  llSetLinkPrimitiveParamsFast(linknum, [PRIM_ROT_LOCAL, desiredRoration]); to actually set it.

You may get some timing  issues if you use the fast versions of the llSet* functions, in that case you may want to use the regular functions or add some more padding by breaking the while loop out into a timer event so everything lands in sequence.

I can also send some example scripts or objects if you'd like.

Share on other sites
2 hours ago, Rolig Loon said:

Each of these replies is telling you the same thing. If you are hoping to use llTargetOmega to make the child prim revolve around the root, you cannot do it without also rotating the root.  I suspect that's what you have been trying so far. llTargetOmega is a very helpful function but it is limited.  If you put it in the root prim, it rotates the entire linkset.  If you put it in a child prim, it rotates that child. All of the rotation is done client-side.  As far as the SL servers are concerned, none of the prims is actually rotating at all.  If you want to make a more complicated set of rotating objects, you need to make the servers do the work in a timed looping sequence by using llSetRot, llSetLocalRot, or the parameters in llSetLinkPrimitiveParams.  The mathematics can be rather complicated, but it's the only way to solve your problem.

Thank you , and yes i try the llTargetOmega and make rotation the child but not do the orb like i need it. thanks again i try to figure out

Share on other sites

whelll i stay up late and found a simple code ver usful, this was what i looking foor ,

here is small video.

i will like to know if is the best way to do it, i read the code and looks is using latest llset

Thanks again

Share on other sites

That's basically the approach that we have each suggested. You could compress it into a few lines of code in a timer event instead of creating a separate function like that, but Wulfie's example expands it in a form that's easy to understand.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.