Trying to write a general rotator of child prim routine. The code below works but only rotates on a single axis whether I pass in x, y or z. I'm sure it's a matter of basic misunderstanding of rotation but I am stumped. Whether I call MoveChildsRot as below I get the same rotation on the Y axis: MoveChildsRot(10, "x", 2); llSleep(2); MoveChildsRot(10, "y", 2); llSleep(2); MoveChildsRot(10, "z", 2); // calc the rotation
rotation rotAmount ( float amt, string xyz)
{
vector x_angles = < amt,0,0 >;
vector y_angles = < 0,amt,0 >;
vector z_angles = < 0,0,amt >;
vector angles_in_radians;
if (xyz = "x")
{
angles_in_radians = x_angles* DEG_TO_RAD; // Change to Radians
}
if (xyz = "y")
{
angles_in_radians = y_angles* DEG_TO_RAD; // Change to Radians
}
if (xyz = "z")
{
angles_in_radians = z_angles* DEG_TO_RAD; // Change to Radians
}
if (debug) llOwnerSay("Angle in Radians: " + (string)angles_in_radians);
return llEuler2Rot ( angles_in_radians ); // Change to a Rotation
}
// Rotate a child prim
// nAmount: number of degrees to rotate (i.e 10, -10)
// str_xyz: axis to rotate (i.e. "x", "y", "z")
// nun: child prim number
MoveChildsRot(integer nAmount, string str_xyz, integer num)
{
// rotate a child prim
list lRot = llGetLinkPrimitiveParams(num, [PRIM_ROT_LOCAL]);
rotation localRot = llList2Rot(lRot, 0); // current Rot
rotation deltaRot;
if (debug) llOwnerSay( (string)nAmount);
if (debug) llOwnerSay("xyz: " + str_xyz + " " + (string)localRot);
deltaRot = rotAmount ((float)nAmount,str_xyz) ;
llSleep(.5);
if (debug) llOwnerSay("xyz2: " + str_xyz + " Delta: " + (string)deltaRot);
llSetLinkPrimitiveParamsFast(num , [ PRIM_ROT_LOCAL, (localRot * deltaRot)] ) ;
}