Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Thoughts on best way to accomplish this....

Archaegeo Platini
Ancient Earth University
Join date: 12 Aug 2004
Posts: 152
10-18-2004 10:59
Say you have a single six sided prim. You want to know which face of the prim is facing up (as viewed standing, with up being towards the sky).

Best way to accomplish this?

I had some luck with llGetRot and converting it to a euclid, but the problem there is the euclids come out as -180 to 180, and rotating something around its Z axis only can change it from 90, 0, 0 euclid to 0, 270, 180 for exaample, which ends up with a lot of if thens.
_____________________
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Dean Archaegeo Platini
Ancient Earth University

Courses for the Second Life

secondlife://Sedig/211/46
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Azelda Garcia
Azelda Garcia
Join date: 3 Nov 2003
Posts: 819
10-18-2004 12:01
Ummm...

Well, I dont konw about *best*, but a way to do it that will work is to take the dot product of llRot2Fwd(rot), llRot2Left(rot) and llRot2Up(rot) with the z-axis, and see which one has the largest number, then you just have to figure out which this axis is pointing up or down, which you can probably do by just checking the z coordinate of the llRot2xxx function.

Disclaimer: its 2am in the morning, and I havent thought this through, but it probably almost works.

Azelda
_____________________
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-18-2004 12:43
should work...
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Archaegeo Platini
Ancient Earth University
Join date: 12 Aug 2004
Posts: 152
10-18-2004 13:30
Thanks much, the below works perfectly
CODE

report_pos()
{
rotation rot;
rot = llGetRot();
vector vec;
float leftz;
float fwdz;
float upz;
vec = llRot2Left(rot);
leftz = vec.z;
vec = llRot2Fwd(rot);
fwdz = vec.z;
vec = llRot2Up(rot);
upz = vec.z;
if(upz > 0.9)
llSay(0, "Six");
else if(upz < -0.9)
llSay(0, "One");
else if(fwdz > 0.9)
llSay(0, "Two");
else if(fwdz < -0.9)
llSay(0, "Five");
else if(leftz > 0.9)
llSay(0, "Four");
else if(leftz < -0.9)
llSay(0, "Three");
else
llSay(0, "MisThrow");
}
_____________________
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Dean Archaegeo Platini
Ancient Earth University

Courses for the Second Life

secondlife://Sedig/211/46
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Zuzi Martinez
goth dachshund
Join date: 4 Sep 2004
Posts: 1,860
10-18-2004 16:45
not to get way off topic but would it be better to make those global variables so you didn't have to declare them every single time? would that make the script faster? does it make a difference?
Archaegeo Platini
Ancient Earth University
Join date: 12 Aug 2004
Posts: 152
10-18-2004 17:55
in this case no big deal, but normally, i wont make a global variable of something that might not be called for a while.

just depends on what the rest of your script is doing

plus in LSL, 16k mem is more of a concern than speed normally. and if you make them global, they are always using memory, if local then not.

of course monkees could be typing shakespear in Ahem as well, shrug
_____________________
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Dean Archaegeo Platini
Ancient Earth University

Courses for the Second Life

secondlife://Sedig/211/46
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
10-18-2004 18:04
yes

CODE

report_pos()
{
rotation rot;
rot = llGetRot();
vector vec;

vec = llRot2Up(rot);
if(vec.z > 0.9)
llSay(0, "Six");
else if(vec.z < -0.9)
llSay(0, "One");
else
{
vec = llRot2Fwd(rot);
if(vec.z > 0.9)
llSay(0, "Two");
else if(vec.z < -0.9)
llSay(0, "Five");
else
{
vec = llRot2Left(rot);
if(vec.z > 0.9)
llSay(0, "Four");
else if(vec.z < -0.9)
llSay(0, "Three");
else
llSay(0, "MisThrow");
}
}
}
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey