|
![](/i/fill.gif) |
Here is what I have:
vector Rot = <0,0,0>;
default
{
state_entry()
{
llSetTimerEvent(0);
}
touch_start(integer total_number)
{
llSetTimerEvent(0.1);
}
timer()
{
vector pos = llGetLocalPos();
vector npos;
float x = pos.x;
float y = pos.y;
float z = pos.z;
Rot = Rot + <0.5,1,1>;
if (Rot.x > 359)
{
Rot.x = 0;
}
if (Rot.y > 359)
{
Rot.y = 0;
}
if (Rot.z > 359)
{
Rot.z = 0;
}
y = llCos(Rot.x)*y - llSin(Rot.x)*z;
z = llSin(Rot.x)*y + llCos(Rot.x)*z;
z = llCos(Rot.y)*z - llSin(Rot.y)*x;
x = llSin(Rot.y)*z + llCos(Rot.y)*x;
x = llCos(Rot.z)*x - llSin(Rot.z)*y;
y = llSin(Rot.z)*x + llCos(Rot.z)*y;
npos = <x,y,z>;
llSetPos(npos);
llSetLocalRot(llEuler2Rot(Rot * DEG_TO_RAD));
}
}
The problem is, when it runs it "starts" where I placed the object, then
the distance from it to the main object shrinks each time. I.e., if the
main object is at <0,0,0> and the "child" is at <0.00809, 0.00888,
1.29409>, then the following passes do this:
[20:43] Object: <-0.25235, -0.23316, 0.69239>
[20:43] Object: <-0.01824, 0.22825, -0.05867>
[20:44] Object: <0.15534, -0.26676, 0.06066>
[20:44] Object: <-0.30133, 0.21328, 0.07791>
[20:44] Object: <0.22322, 0.14242, -0.26685>
[20:44] Object: <0.10885, 0.17888, -0.19385>
[20:44] Object: <-0.16811, -0.19235, -0.21766>
[20:44] Object: <-0.12149, 0.12519, 0.19799>
[20:44] Object: <0.02029, -0.11608, -0.13033>
[20:44] Object: <-0.11644, 0.11593, 0.12039>
[20:44] Object: <0.15958, 0.01220, -0.11591>
[20:44] Object: <0.12300, 0.06275, -0.01218>
[20:44] Object: <-0.05051, -0.04145, -0.06274>
[20:44] Object: <0.00101, 0.03214, 0.04145>
[20:44] Object: <0.03001, -0.03942, -0.03215>
[20:44] Object: <-0.02687, 0.03668, 0.03942>
Getting closer and closer to <0,0,0>.
So, what am I doing wrong here, or what equations do I need instead. The
site I looked at "implied" that the existing "location", i.e., X,Y,Z of
the object would feed through the calculations to end up with something
the same "distance" from the center point as before. However, it was
also code intended to be used in Java or Flash for 3D, so the example
was a mess of crap that involved translating that into 2D points.
Obviosly I am missing something here, but I have no clue why/how the
code is supposed to work, so have no clue why it simply doesn't in this
case. (llGetLocalPos returns the position relative to the location of
the "master" prim, i.e., if the master is at 143,12,23, then the
"local" point is still centered on 0,0,0, supposedly, so that's not
where the issue seems to be coming from. :( )
Help please!!
--
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
|
![](/i/fill.gif) |