Difference between revisions of "Talk:LlLookAt"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "I dont understand a '''common logic behind llMoveToTarget and llLookAt functions'''. I can use llMoveToTarget in an object attached to Avatar, then avatars moves with an object a…")
 
 
(6 intermediate revisions by 4 users not shown)
Line 2: Line 2:
I can use llMoveToTarget in an object attached to Avatar, then avatars moves with an object and so i can drive it to any place i want.
I can use llMoveToTarget in an object attached to Avatar, then avatars moves with an object and so i can drive it to any place i want.
Which is very nice and usefull. I would expect to find same behaviour in llLookAt, so i can from an attachment rotate an Avatar to any position I like. But it is not so, Avatar does not rotate, only moves.
Which is very nice and usefull. I would expect to find same behaviour in llLookAt, so i can from an attachment rotate an Avatar to any position I like. But it is not so, Avatar does not rotate, only moves.
Maybe it is my fault and there is a way to do it, so if anybody knows anything about it please let me know. Thanx in advance.
Maybe it is my fault and there is a way to do it, so if anybody knows anything about it please let me know. Thanx in advance.[[User:Martinek Martinsyde|Martinek Martinsyde]] 17:11, 5 February 2011 (PST)
 
:There is no way to rotate an avatar with a script. The reasoning being this it would imply moving the default position and angle of the camera, which the user might not agree with. Instead of resolving the murky camera behavior expectations, they just didn't enable the feature at all. -- '''[[User:Strife_Onizuka|Strife]]''' <sup><small>([[User talk:Strife_Onizuka|talk]]|[[Special:Contributions/Strife_Onizuka|contribs]])</small></sup> 10:36, 8 February 2011 (PST)
 
But they allow to move avatar exactly this way with llMoveToTarget(...).
 
== The Math ==
 
I have been tinkering with this for about 3 hours now and cant figure out what makes llLookAt tick, it seems super simple but that's just because its all in one function. What im working on is a AI like line of sight program using Raycasts and sensors and i need to get the orientation between the ends of the ray. How i usually get the rotation value that llLookAt uses to get its rot, without all the looking. Normally its easy to get the prim to look at the target, give its rotation, and then calculate. but i cant have this looking at everything.
 
Most of my attempts always end with the same results as adding + <0.0,1.0,0.0>. Its noobish... {{Unsigned|Krade DimondAK|12:58, 31 January 2013}}
 
<lsl>vector targetPoint = llVecNorm( targetPos - basePos );
while (targetPoint != <0.0, 0.0, 1.0>){
    vector topPoint = <0.0, 0.0, 1.0>; //-- 1 unit local up
    rotation targetRot = llRotBetween( topPoint, targetPoint );
    llSetRotation( targetRot * currentRot);
    targetPoint = llVecNorm( targetPos - basePos );
}</lsl>
:the basic idea of how it works (not the exact implementation) is a bit like that... for more complicated specifics, you might want to check out [[geometric]], which has various geometric functions that determine point intersections, and [[llRotBetween]] which has the reference math used in determining the rotation between points<br/>-- '''[[User:Void_Singer|Void]]''' <sup><small>([[User_talk:Void_Singer|talk]]|[[Special:Contributions/Void_Singer|contribs]])</small></sup> 10:10, 1 February 2013 (PST)

Latest revision as of 19:51, 1 February 2013

I dont understand a common logic behind llMoveToTarget and llLookAt functions. I can use llMoveToTarget in an object attached to Avatar, then avatars moves with an object and so i can drive it to any place i want. Which is very nice and usefull. I would expect to find same behaviour in llLookAt, so i can from an attachment rotate an Avatar to any position I like. But it is not so, Avatar does not rotate, only moves. Maybe it is my fault and there is a way to do it, so if anybody knows anything about it please let me know. Thanx in advance.Martinek Martinsyde 17:11, 5 February 2011 (PST)

There is no way to rotate an avatar with a script. The reasoning being this it would imply moving the default position and angle of the camera, which the user might not agree with. Instead of resolving the murky camera behavior expectations, they just didn't enable the feature at all. -- Strife (talk|contribs) 10:36, 8 February 2011 (PST)

But they allow to move avatar exactly this way with llMoveToTarget(...).

The Math

I have been tinkering with this for about 3 hours now and cant figure out what makes llLookAt tick, it seems super simple but that's just because its all in one function. What im working on is a AI like line of sight program using Raycasts and sensors and i need to get the orientation between the ends of the ray. How i usually get the rotation value that llLookAt uses to get its rot, without all the looking. Normally its easy to get the prim to look at the target, give its rotation, and then calculate. but i cant have this looking at everything.

Most of my attempts always end with the same results as adding + <0.0,1.0,0.0>. Its noobish... —The preceding unsigned comment was added on 12:58, 31 January 2013 by Krade DimondAK

<lsl>vector targetPoint = llVecNorm( targetPos - basePos ); while (targetPoint != <0.0, 0.0, 1.0>){

   vector topPoint = <0.0, 0.0, 1.0>; //-- 1 unit local up
   rotation targetRot = llRotBetween( topPoint, targetPoint );
   llSetRotation( targetRot * currentRot);
   targetPoint = llVecNorm( targetPos - basePos );

}</lsl>

the basic idea of how it works (not the exact implementation) is a bit like that... for more complicated specifics, you might want to check out geometric, which has various geometric functions that determine point intersections, and llRotBetween which has the reference math used in determining the rotation between points
-- Void (talk|contribs) 10:10, 1 February 2013 (PST)