Jump to content

rotation script help


MsReality
 Share

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

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

Recommended Posts

I'm building a water feature that has three cylinder prims stacked one on top of the other and connected.  The prims have been set so the two on top are the child prims and the bottom prim is the parent.  I'm attempting to have the two on top rotate ... one to the right and one to the left.  Each child prim has multiple prims attached that appear to be water spouting from them.  All of these prims sit in a base that looks like water within a marble tub. 

 

I looked at different tutorial sites and thought I had found one with simple instructions to have the two top cylinders rotate and followed the instructions specifically, however, it is not functioning correctly.  Could you look at my script and tell me what elements I am missing or what I could do differently to make this work as I have envisioned it to work.

{   

    state_entry()

           

    {
llSetPos(llGetPos()+<-1,0,0>);

    //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);    

    }

     

}

 

Also, I would like to add the element of water particles in the air from the rotation.

 

Thank you for you assistance.

MsReality

Link to comment
Share on other sites

Well, you won't be able to do all of that, but you can at least get the basics to work.  Try this ...

default{    state_entry()    {        llSetLinkPrimitiveParamsFast(2,[PRIM_OMEGA,<0.0,0.0,1.0>,0.3,0.3]);        llSetLinkPrimitiveParamsFast(3,[PRIM_OMEGA,<0.0,0.0,1.0>,-0.3,0.3]);    }}

 That will rotate your top cylinder one direction and the middle cylinder the opposite direction.  Unfortunately, though, you can't link anything to either of those prims and expect them to rotate with it.  PRIM_OMEGA (or the parent function, llTargetOmega) affects only that one prim, unless you put it in the root prim and expect it to rotate the entire object.  You have only two solutions that I can think of:

1. Don't link your three cylinders at all.  Make each of them an independent object, maybe with attached gargoyles, and make each entire object spin with a simple llTargetOmega script like the one in your inventory >>. Library >> Scripts folder.

2. Make the middle and top cylinders sculpties, complete with all of its extras, so that each is a single prim.  That's a bit of work, but it could look cool.

(I'm not even going to suggest llSetRot, which would not only be a nasty bear to script, the result would look choppy and very unsatisfactory.)

For spouting particles, study llParticleSystem or -- even better -- visit the Particle Lab in world and do their tutorials to learn how it's done.  That's how most of us learned.

Link to comment
Share on other sites

It looks like you are trying to link them all?  That wont work.  A child prim will not carry additional prims that rotate as they will only move themselves and not any attached prims where a parent prim will rotate anything attached to it.

However, there are some tricks to emulate this.  Try using a texture animation instead.  As with some of my ceiling fans, I have an animated texture for my fan blades that then rotate around a parent prim that rotates.  It creates the look of having multiple movements where it really a trick with animated textures.

Link to comment
Share on other sites

I built 3 prims (two copied from the first) then inserted the script below that you gave me... first into one on the top then into all three... then just the bottom one... then tried linking them... they still don't rotate... hmmmmmm  I must still be doing something wrong?

Can you add some advice ... I'm a novice so I'm not certain if I'm doing something wrong or missing a step.  Thank you for your help!

default
{
    state_entry()
    {
        llSetLinkPrimitiveParamsFast(2,[PRIM_OMEGA,<0.0,0.0,1.0>,0.3,0.3]);
        llSetLinkPrimitiveParamsFast(3,[PRIM_OMEGA,<0.0,0.0,1.0>,-0.3,0.3]);
    }
}

Link to comment
Share on other sites

I do not have them connected and they still rotate so I added one of my water prims to it and it rotates with the prim... I am so stoked!  Now all I need to do is figure out how to add water particles around the fountain?  Any advice?  I sooooooooo appreciate what you've done to help me tonight!!!

Link to comment
Share on other sites

This is such a wonderful site!  I was able to get my fountain to do exactly what I wanted it to do... I couldn't be more pleased with the assistance I received.  I will save the scripting for use later for another project.  I can't thank you enough!!!

Link to comment
Share on other sites

I have copied your script into my own three prims but it won't work in mine.  I checked out every aspect but can't get it to work

I was given these instructions by a classmate but am now sure where or how to do this

Jashar Resident: in the script therre is a place wehere is says someting like rotate (x,y,x).

Link to comment
Share on other sites

I copied the script I was given into my prims but it won't work. However, It works fine in the prims shared with me. I was told that there is a place where is says someting like rotate (x,y,x) that needs to be set but I don't know where to look to find it to make this work and where I find the (x,y,x) to insert that information. 

This is the script I was given

default
{
    state_entry()
    {
        llSetLinkPrimitiveParamsFast(2,[PRIM_OMEGA,<0.0,0.0,1.0>,0.3,0.3]);
        llSetLinkPrimitiveParamsFast(3,[PRIM_OMEGA,<0.0,0.0,1.0>,-0.3,0.3]);
    }

}

 

Link to comment
Share on other sites

I think your friend is thinking of a different script.  Yes, it is possible to rotate linked prims separately using llSetLinkPrimitiveParams and the parameter PRIM_ROT_LOCAL, but that is a relatively tricky bit of scripting and it makes for a rotation that is choppy instead of nice and smooth.  Only llTargetOmega, which does its work client-side, will give you smooth motion.

The X, Y, Z values in the script that you have are between the < > brackets.  That vector describes the orientation of the rotational axis of the prim you want to set spinning.  In that first command, for example, you are telling prim #2 to rotate around its Z axis (X = 0.0; Y = 0.0; Z = 1.0).  The other command is doing the same thing for prim #3.

I can't imagine why that script isn't working for you unless, of course, your three prims aren't linked.

Link to comment
Share on other sites

Hmmm... If I had known that this was a homework assignment, I probably would not have sent you that script.  Look back at my post (#8) in which I said I was sending you a demo.  The demo, which included this script, consisted of three linked prims, with the root prim as the bottom one.  If your three prims are not linked, the script won't work.  After all, that's what llSetLinkPrimitiveParamsFast does. 

The second example that I sent you later last night consisted of a base object (with no script in it) and two unlinked rotating prims (with a separate script in each one).  Those prims are not linked, because of the peculiar trick I had to use for making a particle stream update to track the rotation of a prim. Let me explain........

When we use llTargetOmega (or PRIM_OMEGA) to spin a prim, nothing is actually moving, as far as SL's servers know. All of the spinning is a visual effect, done by your own graphics card.  That's fine if all we want is a rotating prim, but you asked for a rotating prim that spews particles.  Unless we tell the servers to really turn the prim, the particle emitter will always point in the same direction.   Therefore, I had to write a script that makes the servers turn the prim by calculating a new rotation in steps and using llSetRot, and then overlay that with llTargetOmega to tell your graphics card to make the apparent motion smooth.  If you watch that second demo carefully, you'll see that the prim rotates smoothly but the particle emitter jumps ahead in 10 degree hops.  (If you are really interested, this is the principle used in the popular Smooth Rotating Door script used by many builders.)

So why not link the prims?  Because calculating and updating the local rotation of child prims is a real bear to do. It is much easier to leave the prims UNlinked and use two separate scripts with llTargetOmega.  Unless you are likely to move the structure around, it doesn't make any difference whether the prims are linked or not.  Also, if they are unlinked then you can attach other things to each of the rotating prims without messing up their spinning, as you discovered. Again, if you look back in this thread you'll see that I pointed out this difference in my first response to your OP.

I will be back in world again this evening if you need more help.

 

Link to comment
Share on other sites

First, let me explalin that it is perfectly alright for me to search out script and use it in my projects.  My instructor has given our class permission to do so as this is not a scripting class but a first level class.  He wants us to know how to add them to our objects and to view them but we are not required to write them.  So asking for you assistance was encouraged by him and well within the parameters of our class.  I have already informed him of my source.

Thank you for that thorough explanation.  I will print it and see if I can now make my examples work properly.  Your patience and thorough explanations have been of great value to my learning experience!  I have already informed my other classmates of you assistance and will most definitely efer this site to others who need assistance.

 

Thank you again,

MsReality

Link to comment
Share on other sites

I have written up the information you offered to me with visual examples as well as the script examples that you sent me for my future reference.  I am also submitting this to my professor to distribute if he would like to do so.  I would be happy to send you a copy also.

 

MsReality

Link to comment
Share on other sites

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