Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

2000 L for reversing this front wheel script

RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
04-17-2005 01:17
I'm pretty sure this is open source anyway its been alterd some to make it work as a rudder on my airships now I'm trying to use it for the rudders on on a thing I'm calling a leaf blower (looks like 4 leaves held together by a few sticks and you fly it) anyway works great for the leaf on the right but the leafs are made from spheres and the left one is
rotated in the opposite direction if i put this same script in it it turns the pointy end of the leaf toward the front of the vehical I need a smart person who understands whats going on here to reverse this for me and will give a 2000 L and a leaf blower to the one who comes up with the script I need to make this work.

CODE

//**********************************************
//Title: Car Front Wheel
//Author: Aaron Perkins
//Date: 2/17/2004
//**********************************************

string lastCommand = "";

rotation Inverse(rotation r)
{
r.x = -r.x;
r.y = -r.y;
r.z = -r.z;
return r;
}
rotation GetParentRot()
{
// Inverse2(llGetLocalRot())*llGetRot();
return Inverse(llGetLocalRot())*llGetRot();
}
SetLocalRot(rotation x)
{
llSetRot(x*Inverse(GetParentRot()));
}

default
{
state_entry()
{
}
link_message(integer sender_num, integer num, string str, key id)
{
if(str == "WHEEL_DRIVING")
{
state driving;
}
}
}

state driving
{
state_entry()
{
SetLocalRot(llEuler2Rot(<0,0,0.14159> ));
llSetTimerEvent(0.5);
}
timer()
{
vector vel = llGetVel();
float speed = llVecMag(vel);
}
link_message(integer sender_num, integer num, string str, key id)
{
if(str == "FIN_FORWARD")
{
SetLocalRot(llEuler2Rot(<0, 0, 180.14159 > ));
}
if(str == "FIN_REVERSE")
{
SetLocalRot(llEuler2Rot(<0, 0, 180.14159 > ));
}
if(str == "FINLEFT")
{
SetLocalRot(llEuler2Rot(<0, 0, 180.14159 + 0.5> ));
//llWhisper(0, "Left");
}
if(str == "FINRIGHT")
{
SetLocalRot(llEuler2Rot(<0, 0, 180.14159 - 0.5> ));
}
}
state_exit()
{
SetLocalRot(llEuler2Rot(<0,0,0> ));
}
}
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-17-2005 01:34
Hooo.... first off, keep the Lindens unless you have a dire need to pay someone.

This is... messy. Not in a good way... but that's excusable because many commands we have now weren't available over a year ago. Going right down the line:
CODE

//**********************************************
//Title: Car Front Wheel
//Author: Aaron Perkins
//Date: 2/17/2004
//Modification: Jeffrey Gomez
//**********************************************

string lastCommand = "";

rotation Inverse(rotation r)
{
//r.x = -r.x;
//r.y = -r.y;
//r.z = -r.z;
// Irrelevant. This is the same as:
r.s *= -1;
return r;
}
rotation GetParentRot()
{
// Inverse2(llGetLocalRot())*llGetRot();
//return Inverse(llGetLocalRot())*llGetRot();
// Irrelevant. This is the same as:
return llGetRootRotation();
}
SetLocalRot(rotation x)
{
//llSetRot(x*Inverse(GetParentRot()));
// Irrelevant. This is now:
llSetLocalRot(x);
}

default
{
state_entry()
{
}
link_message(integer sender_num, integer num, string str, key id)
{
if(str == "WHEEL_DRIVING")
{
state driving;
}
}
}

// Now, to reverse it, we just add a liberal amount of negative signs:
// If this does not work for you, and it probably won't, add PI (the constant)
// to each Z value below.
state driving
{
state_entry()
{
SetLocalRot(llEuler2Rot(<0,0,-0.14159> ));
llSetTimerEvent(0.5);
}
timer()
{
vector vel = llGetVel();
float speed = llVecMag(vel);
}
link_message(integer sender_num, integer num, string str, key id)
{
if(str == "FIN_FORWARD")
{
SetLocalRot(llEuler2Rot(<0, 0, -180.14159 > ));
}
if(str == "FIN_REVERSE")
{
SetLocalRot(llEuler2Rot(<0, 0, -180.14159 > ));
}
if(str == "FINLEFT")
{
SetLocalRot(llEuler2Rot(<0, 0, -1 * (180.14159 + 0.5)> ));
//llWhisper(0, "Left");
}
if(str == "FINRIGHT")
{
SetLocalRot(llEuler2Rot(<0, 0, -1 * (180.14159 - 0.5)> ));
}
}
state_exit()
{
SetLocalRot(llEuler2Rot(<0,0,0> ));
}
}

It looks to me like this might also have a texture animation. If it does, you might need to reverse that as well... because it ain't in this script.
_____________________
---
RacerX Gullwing
Magic Rabbit
Join date: 18 Jun 2004
Posts: 371
04-17-2005 02:57
your close a picture of where its at with that but still about 180 to go ok just read the notes in the script ill try that ok that worked ty I sent out the 2000 and a leaf blower
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-17-2005 10:09
Notice how I wrote this? :)

CODE
// Now, to reverse it, we just add a liberal amount of negative signs:
// If this does not work for you, and it probably won't, add PI (the constant)
// to each Z value below.

You'll want to do this:
CODE
SetLocalRot(llEuler2Rot(<0,0,-0.14159 + PI> ));

...

SetLocalRot(llEuler2Rot(<0, 0, -180.14159 + PI> ));

...

SetLocalRot(llEuler2Rot(<0, 0, (-1 * (180.14159 + 0.5)) + PI> ));

...

SetLocalRot(llEuler2Rot(<0, 0, (-1 * (180.14159 - 0.5)) + PI> ));

...
SetLocalRot(llEuler2Rot(<0,0,PI> ));

... etc.
_____________________
---
Siro Mfume
XD
Join date: 5 Aug 2004
Posts: 747
04-18-2005 02:36
just put your fin or whatever in the position you want it for each position and put in a script that outputs llGetRot();

like: llSay(0, "rotation is: " + llGetRot());

Then plug those numbers into what you already have and take out that euler mess.

This is zero rotation in relation to the parent.
SetLocalRot(<0,0,0,1>;);