Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Q: Lock Local FWD Axis Rot

Sam Stork
Registered User
Join date: 19 Mar 2006
Posts: 5
06-30-2006 17:05
Hi,

Locking the local Fwd Axis' rotation?


Imagine a security camera, this camera follows an agent, you use this:
CODE

rotation rotglobal = llGetRot() * llRotBetween(<0, 1, 0> * llGetRot(), llVecNorm(llDetectedPos(0) - llGetPos())));


llSetRot(rotglobal);


Ok, the great thing about this idea is that it doesn't look one bit like a camera.
If you assume the Fwd Axis here is the Y axis, the Y axis won't stay zerofied.
Of course, a security camera doesn't roll over it's Fwd Axis, so my question is, how do I lock it?

I have tried a few things.
My latest attempt was trying to take the global rotation, making it a local rotation, then a vector of course, zerofying the Y axis, and then going back to global rotation with my new local rotation.
Which looks as such:

CODE

vector between = llRot2Euler(llGetRot() * llRotBetween(<0, 1, 0> * llGetRot(), llVecNorm(llDetectedPos(0) - llGetPos()))) * RAD_TO_DEG;


rotation rotglobal = llEuler2Rot(between * DEG_TO_RAD);

rotation rotlocal = rotglobal * llGetRot();

vector veclocal = llRot2Euler(rotlocal) * RAD_TO_DEG;
veclocal.y = 0;

rotlocal = llEuler2Rot(veclocal * DEG_TO_RAD);

rotglobal = rotlocal / llGetRot();

llSetRot(rotglobal);



And this works pretty nicely. But it tries to stabalize for some reason, and takes some time to get straight. And also, sometimes it just doesn't work at all. But better than without this global to local to global.

Maybe the functions of SL aren't precise enough or maybe I am a retard?

Please call me a retard and give me an answer! =D
Sam Stork
Registered User
Join date: 19 Mar 2006
Posts: 5
Answer
07-02-2006 03:50
The asnwer was given to me by Seigmancer Nino:

CODE

llLookAt(llDetectedPos(0), 2.5, 0.1);


=) I'm such a tardhead