Jump to content

Child Prim Rotation


Tibbybob
 Share

Recommended Posts

Hi,

 

I want a child prim to rotate relative to the direction the root prim is "facing".  The root prim will be in motion, constantly changing direction with some up and down movement; the child prim needs to follow the root prim on x and y (it's at the front of the root prim) but rotate at its center on z to a certain number of degrees to the left or right of the root's direction.

I have tried to understand and follow some different examples that I found here and on the SL wiki, but the more I try the worse it gets :(

Thanks for any and all help!

Link to comment
Share on other sites

If I understand correctly, you are setting the child prim's local rotation, and you want it to match the root's global rotation, plus or minus a perturbation.  So try something like

llSetLinkPrimitiveParamsFast(child_link_no,[PRIM_LOCAL_ROT, llEuler2Rot(perturbation_rot)*llGetRot()]);

If your perturbation is a +/- 10 degree rotation around the child prim's Z axis, you might write it as

vector perturbation_rot = <0.0,0.0,10.0 - llFrand(20.0)>*DEG_TO_RAD ;

You'll need to update that everytime the root prim rotates, so put both in a timer event with a suitably short time frame.

ETA: OK, so that wasn't right, but this is ....

integer gON;default{    touch_start(integer total_number)    {        llSetTimerEvent(0.3 * (gON = !gON));    }        timer()    {        vector perturbation_rot =<0.0,0.0,10.0-llFrand(20.0)>*DEG_TO_RAD ;        llSetLinkPrimitiveParamsFast(2,[PRIM_ROT_LOCAL, llEuler2Rot(perturbation_rot)]);        llSetLinkPrimitiveParamsFast(LINK_THIS,[PRIM_ROTATION,llEuler2Rot(<0.0,0.0,2.0>*DEG_TO_RAD)*llGetRot(),PRIM_POSITION,llGetPos() + <0.0,0.0,0.5-llFrand(1.0)>]);    }}

 Tested it in world. The two-prim linkset bounces up and down randomly and the orbiting child prim wobbles back and forth on its own Z axis, like Earth's Moon with its axial perturbations. It's pretty cool.


Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...