|
 |
OK, this code, finally, mostly works:
vector Rot;
vector RotChange;
vector RotAngle;
float x;
float y;
float z;
default
{
state_entry()
{
llSetTimerEvent(0);
llSetLocalRot(<0,0,0,0>);
llSetPos(<1,1,1>);
Rot = <0,0,0>;
//Change to adjust how it moves.
RotChange = <10,0,0>;
}
on_rez(integer dummy)
{
llSetTimerEvent(0);
}
touch_start(integer total_number)
{
llSetTimerEvent(0.1);
vector pos = llGetLocalPos();
x = pos.x;
y = pos.y;
z = pos.z;
}
timer()
{
vector bpos = llGetRootPosition();
//llOwnerSay((string)pos);
//llOwnerSay((string)bpos);
vector npos;
Rot = Rot + RotChange;
RotAngle = Rot * DEG_TO_RAD;
if (Rot.x > 359)
{
Rot.x = 0;
}
if (Rot.y > 359)
{
Rot.y = 0;
}
if (Rot.z > 359)
{
Rot.z = 0;
}
float xx = x;
float xy = llCos(RotAngle.x)*y - llSin(RotAngle.x)*z;
float xz = llSin(RotAngle.x)*y + llCos(RotAngle.x)*z;
float yy = xy;
float yz = llCos(RotAngle.y)*xz - llSin(RotAngle.y)*xx;
float yx = llSin(RotAngle.y)*xz + llCos(RotAngle.y)*xx;
float zx = llCos(RotAngle.z)*yx - llSin(RotAngle.z)*yy;
float zy = llSin(RotAngle.z)*yx + llCos(RotAngle.z)*yy;
float zz = yz;
npos = <zx,zy,zz>;
llSetPos(npos);
llSetLocalRot(llEuler2Rot(Rot * DEG_TO_RAD));
//llSetRot(llEuler2Rot(Rot * DEG_TO_RAD));
}
}
However, I still get some real "odd" behavior if I try to do more than
one direction at a time, like RotChange = <10,0,10>. Instead of
following the expected path, it seems to curve off in the wrong
direction, back to the starting point, then around in a curve, ending
up.. Well, its impossible to describe exactly, but, suffice to say that
instead of looping from 1,1,1, ending up at a point diagonal to where it
started, it instead ends up following some other odd path, which doesn't
fit what I expect to see. Would this be the so called "gimble lock"
issue that is sometimes described? I am more confused by what is going
wrong now, or even if it "is" going wrong, than I was before. lol
--
void main () {
if version = "Vista" {
call slow_by_half();
call DRM_everything();
}
call functional_code();
}
else
call crash_windows();
}
<A HREF='http://www.daz3d.com/index.php?refid=16130551'>Get 3D Models,
3D Content, and 3D Software at DAZ3D!</A>
Post a reply to this message
|
 |