Jump to content

Make a link 'nod' 15deg in its own local rotation?


Beowulf Zessinthal
 Share

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

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

Recommended Posts

Calling local Geniuses!

i cannot make a link 'nod' 15 degrees in its own current local frame of reference

 i want to do it by adding a rotation to a current rotation.

I think i need to start by conversion to Euler .. but my example script adds the 15deg relative to the object rot, not the link rot.

Any clever ideas on offer!?



 

default
{
    state_entry(){
    //join two prims, set the top one to some random angle
    }

    touch_start(integer total_number){
    //get the current local rotation of a prim in degrees
    rotation origQuat = llList2Rot( llGetLinkPrimitiveParams(2, [PRIM_ROT_LOCAL]), 0);
    vector eulerAngle = llRot2Euler(origQuat);
    eulerAngle = eulerAngle * RAD_TO_DEG; //llOwnerSay((string)eulerAngle + " degrees");
    
    //now add 15 degrees ON ITS OWN LOCAL Y AXIS, and convert back to quats
    vector nodAngle= eulerAngle + <0, 15, 0>;
    nodAngle *= DEG_TO_RAD;
    rotation nodQuat = llEuler2Rot(nodAngle);
    
    //now make make the link nod the 15deg forward and then return to the original rotation:
    llSetLinkPrimitiveParams(2, [PRIM_ROT_LOCAL, nodQuat]);
    llSleep(1);
    llSetLinkPrimitiveParams(2, [PRIM_ROT_LOCAL, origQuat]);
    //but it has added the 15 degrees to the object local, not the link local!
    }
    
}

 

Link to comment
Share on other sites

If you want to make your object rotate down around the y-axis by 15 degrees, you should be using

llSetLinkPrimitiveParamsFast(2,[PRIM_ROT_LOCAL, llEuler2Rot(<0.0,15.0*DEG_TO_RAD,0.0>)*OrigQuat]);

where the origQuat is the rotation that you got from

rotation origQuat = llList2Rot( llGetLinkPrimitiveParams(2, [PRIM_ROT_LOCAL]), 0);

 When you want it to rotate up again, you just use

llSetLinkPrimitiveParams(2, [PRIM_ROT_LOCAL, origQuat]);

 as you did.

Link to comment
Share on other sites

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