Jump to content

Rotatation (root prim) and counter rotation (child prim) - Help please!


Amalsu
 Share

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

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

Recommended Posts

Hi scripting gurus,

 

I'm faced with a tiny problem. I want to do some object rotation and have been stuck on a particular problem for some time and it's getting frustrating.

Here's a little schematic of I what I want to do: http://img846.imageshack.us/img846/932/schematicg.png

 

  • I have a root prim (blue square)
  • I have a child prim (red/yellow globe, linked to root prim of course)
  • I'm rotating the root prim counter-clockwise

Now I'd like to rotate the child prim clockwise, so the yellow half is always facing the same direction (south). When I put the same script I use on the root prim into the child prim with the same values (just negative), it seems to work on first sight, but angles start to differ soon and the child prim's rotation is off a few full circles later.

So I guess what I would have to do is constantly poll for the root prim's current rotation and subtract it from the child's current rotation, right?

This sounds nice in theory, but I haven't gotten it to work. I have to admit though, I'm very much a scripting dummy. :smileysad:

Help please?

 

Oh, yes - here's the script I use on the root prim (googled it):

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

}

 

Link to comment
Share on other sites

TargetOmega is a client-side effect, you can't ask the server for the current rotation because the server doesn't know. I'd say there's no way you can get the timing to be right with TargetOmega because everyone who sees it is going to see it at a different point. You'll have to use a timer and SetRot, although the effect will be much less smooth.

  • Like 1
Link to comment
Share on other sites

Smoothness of movement wouldn't be that much of an issue since it's going to be a very, very slow rotation. What I need this for is to create a moon orbiting around a planet, but its bright side has to face the sun at any given time.

Thanks for the tip, I hope I can get that script right!

Link to comment
Share on other sites

If smoothness is not an issue, then just put the motion in a timer and update the rotation at each step with llSetPos and llSetRot  (or, better, llSetLinkPrimitiveParamsFast(linkno,[PRIM_POS_LOCAL, PRIM_ROT_LOCAL]);   Or, maybe use llSetKeyframedMotion, which will give you smooth motion too.)

Link to comment
Share on other sites

Sounds like the simplest solution here (assuming the planet is just a sphere)  is to just rotate the linkset the direction you want the moon to orbit in, using whatever method you want, then just use a smooth scrolling texture animation on the planet to make it look like it's rotating in the opposite direction. You could do the whole deal with like 2 function calls and negligable server lag that way.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4443 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...