Jump to content

Yet Another Rotation Query


Carbon Philter
 Share

Recommended Posts

I'm still trying to master rotations and thought I had it nailed but yet again find I'm missing something, and would appreciate assistance.

I want to have a child prim emitting particles in the xy plane relative to a vehicle's root prim which has no variation in its z axis - boat and propeller wake - but need to have the option to rotate the wake emitter to face either directly forward or backwards. Hope that makes sense!

I knocked up a test rig and put a toggle script in the child prim to check it out and it almost works. The emitter prim rotates forward/backward as required, whatever the root prim's horizontal direction , but with the script as written the child emitter prim is rotating around it's own z axis as the root prim faces different directions in the xy plane, and that skews the angle emission of the particles, and I need to avoid that.

here's the almost working tester:

integer switch;
vector input;

default
{
    touch_start(integer total_number)
    {
        switch = !switch;
        rotation quat = llEuler2Rot(input);
        if (switch==TRUE)
        {
            input = <0, 3*PI/2, 0> ;
            llOwnerSay("Touched.");
        }
        else if (switch==FALSE)
        {
        input = <0, PI/2, 0> ;
        }
        llSetLinkPrimitiveParamsFast(2, [PRIM_ROT_LOCAL, llGetLocalRot()*quat]);
    }
} 

 It's got to be something straightforward in the relationship between the local rotations of the root and child but so far I can't grasp it. Help!!

Thanks

Carbon

 

Link to comment
Share on other sites

Unless I am misunderstanding your setup, all you need to do is get the local rotation of the child prim (not llGetLocalRot(), which is the local rotation of the root), and apply it.  Something like this ...

integer switch;default{    touch_start(integer total_number)    {        vector input = <0, (2*(switch = !switch)+1)*PI/2, 0> ;        rotation quat = llEuler2Rot(input);        rotation rLoc = (rotation)llList2String(llGetLinkPrimitiveParams(2,[PRIM_ROT_LOCAL]),0);        llSetLinkPrimitiveParamsFast(2, [PRIM_ROT_LOCAL, rLoc*quat]);    }} 

 Edit:  Which is what Dora said while I was typing.^^   :smileyvery-happy:

Link to comment
Share on other sites

Many thanks, Dora. Got it in one!

I was continuing tests and set up another rig but did it the 'old fashioned way' using llMessageLinked and then used that to set the child's local rot. Maybe not the tidiest of script solutions but got that way to work!

vector input;integer switch;default{    link_message(integer sender_num, integer num, string msg, key id)    {    if(msg = "rotate")    {        switch = !switch;        if (switch==TRUE)        {            input = <0, -PI/2, 0> ;}            else if (switch==FALSE)        {            input = <0, PI/2, 0> ;        }        llSetLocalRot( llEuler2Rot(input));    }}

 Guess it's a combination of the rotation function and using the LinkPrimParametersFast function I need to get my head round. Maybe overcomplicating things through ignorance. :matte-motes-dont-cry:

Thanks again.

Carbon

Link to comment
Share on other sites

One significant difference between your two versions is that, in the first, you say 

rotation quat = llEuler2Rot(input);

before you've assigned any valute to input.   I think this means that your code actually means 

 llSetLinkPrimitiveParamsFast(2, [PRIM_ROT_LOCAL, llGetLocalRot()*ZERO_VECTOR]);

regardless of what value is assigned to input.

In your second example, with the link messages, you (correctly) assign a value to input and then convert it to a rotation.

Link to comment
Share on other sites

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...