aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorDr Scofield2009-02-09 10:04:54 +0000
committerDr Scofield2009-02-09 10:04:54 +0000
commit07804f6937eb163a80cd0da25dc2da81336ad152 (patch)
tree810866f6cda72fffe061a3da97e951862fd98d9f /OpenSim/Region
parentfixing refactoring artefact. (fixes mantis #3113) (diff)
downloadopensim-SC_OLD-07804f6937eb163a80cd0da25dc2da81336ad152.zip
opensim-SC_OLD-07804f6937eb163a80cd0da25dc2da81336ad152.tar.gz
opensim-SC_OLD-07804f6937eb163a80cd0da25dc2da81336ad152.tar.bz2
opensim-SC_OLD-07804f6937eb163a80cd0da25dc2da81336ad152.tar.xz
This patch implements llLookAt to the extent that an object will correctly
rotate and point to the target, however it doesnt yet use the damping or strength parameters. From: Robert Smart <smartrob@uk.ibm.com>
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs24
1 files changed, 23 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index c14d454..a73977e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2506,8 +2506,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2506 2506
2507 public void llLookAt(LSL_Vector target, double strength, double damping) 2507 public void llLookAt(LSL_Vector target, double strength, double damping)
2508 { 2508 {
2509 // partial implementation, rotates objects correctly but does not apply strength or damping attributes
2510
2509 m_host.AddScriptLPS(1); 2511 m_host.AddScriptLPS(1);
2510 NotImplemented("llLookAt"); 2512 // Determine where we are looking from
2513 LSL_Vector from = llGetPos();
2514
2515 // Work out the normalised vector from the source to the target
2516 LSL_Vector delta = llVecNorm(target - from);
2517 LSL_Vector angle = new LSL_Vector(0,0,0);
2518
2519 // Calculate the yaw
2520 // subtracting PI_BY_TWO is required to compensate for the odd SL co-ordinate system
2521 angle.x = llAtan2(delta.z, delta.y) - ScriptBaseClass.PI_BY_TWO;
2522
2523 // Calculate pitch
2524 angle.y = llAtan2(delta.x, llSqrt((delta.y * delta.y) + (delta.z * delta.z)));
2525
2526 // we need to convert from a vector describing
2527 // the angles of rotation in radians into rotation value
2528
2529 LSL_Types.Quaternion rot = llEuler2Rot(angle);
2530
2531 // Orient the object to the angle calculated
2532 llSetRot(rot);
2511 } 2533 }
2512 2534
2513 public void llStopLookAt() 2535 public void llStopLookAt()