Jump to content

Rotate Child Prim not the Root how?


Lolita Erin
 Share

You are about to reply to a thread that has been inactive for 2058 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

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 radians=DEG_TO_RAD*360/slices; //calculates how many radians are incrimented per slice
    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
  • Like 1
Link to comment
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).

Link to comment
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.

  • Thanks 2
Link to comment
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.

http://www.sluniverse.com/php/vb/tutorials/62235-basic-introduction-rotations.html

http://www.sluniverse.com/php/vb/tutorials/62479-introduction-rotations-translations-rotation-tutorial.html

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
  • Like 2
Link to comment
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 radians=DEG_TO_RAD*360/slices; //calculates how many radians are incrimented per slice
    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.

Thank you i will try to follow your advise!

Link to comment
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

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2058 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...