05-01-2008 11:30
I am developing a script to be loaded inside a sit, so that independently on where the sit is and how is rotated, the view is always the same, that is, the eye is in a fixed position as well as fixed the position the eye is looking for. The block of code is

CODE

llSetCameraEyeOffset(eyeOffset) ;
llSetCameraAtOffset(targetOffset) ;
llForceMouselook(FALSE) ;


of course. The problem is how to calculate "eyeOffset" and "targetOffset" vectors. This is what I did, but it does not work as expected:

CODE

vector eyePosition = <...fixed value...> ;
vector targetPosition = <...fixed value...> ;
...
eyeOffset = eyePosition - llGetPos() ;
targetOffset = targetPosition - llGetPos() ;


In theory the rotation of sit should not apply. But I do not get what I want. So I changed it to

CODE

eyeOffset = (eyePosition - llGetPos())*llGetLocalRot() ;
targetOffset = (targetPosition - llGetPos())*llGetLocalRot() ;


Better. It semed that rotation should be applied, but the result is that I point to the target, but from the sit position. So if the angle between sit-taget and eye-target is wide, I get the target from a side, not front.

Any idea how to fix this?