Hello,
I have a root for which I make a translation and a linked prim for which I make a rotation. I created this script for my tests:
// Parameters to change
float TIME = 3; // Time in seconds
float HEIGHT = 2; // Height in meters
float ANGLE = .5; // Angle in radian
// Don't touch it!
float TIME_BASE = .04;
float f_step;
vector v_pos;
vector v_rot;
float step;
integer stop = TRUE;
integer up;
float fCos(float x, float y, float t)
{
float F = (1.0 - llCos(t * PI)) / 2.0;
return x * (1.0 - F) + y * F;
}
move()
{
v_pos = llGetPos();
v_rot = llRot2Euler(llList2Rot(llGetLinkPrimitiveParams(2, [PRIM_ROT_LOCAL]), 0));
step = .0;
up = TRUE;
llSetTimerEvent(TIME_BASE);
}
default
{
state_entry()
{
f_step = 1.0 / (TIME / TIME_BASE);
}
on_rez(integer start_param)
{
stop = TRUE;
llSetTimerEvent(.0);
}
touch_end(integer total_number)
{
if(stop = !stop)
{
llSetTimerEvent(.0);
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, v_pos,
PRIM_LINK_TARGET, 2, PRIM_ROT_LOCAL, llEuler2Rot(v_rot)]);
}
else move();
}
timer()
{
if(up)
{
if((step += f_step) >= 1.0) up = FALSE;
}
else
{
if((step -= f_step) <= .0) up = TRUE;
}
llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_POSITION, v_pos + <0, 0, fCos(0, HEIGHT, step)>,
PRIM_LINK_TARGET, 2, PRIM_ROT_LOCAL, llEuler2Rot(v_rot + <0, 0, fCos(0, ANGLE, step)>)]);
}
}
So just 2 linked prims.
It starts and stop with a click.
The move is ok, the rotation is ok but... the relative position of the linked related to the root changes with shaking with a very unsightly effect.
As I do both movements in the same function, I thought I wouldn't have this kind of problem.
If someone has an idea to help me to get a good visual effect !
Thanks.