aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation
diff options
context:
space:
mode:
authordahlia2015-02-02 02:47:47 -0800
committerdahlia2015-02-02 02:47:47 -0800
commit1eedc2b4af192973889341da5615139cfd65f152 (patch)
tree1e6a719d25805ffaea38923a6778ff785cc3a1fb /OpenSim/Region/ScriptEngine/Shared/Api/Implementation
parentPrevent null entries being treated as URI's when DataSnapshot service splits ... (diff)
downloadopensim-SC-1eedc2b4af192973889341da5615139cfd65f152.zip
opensim-SC-1eedc2b4af192973889341da5615139cfd65f152.tar.gz
opensim-SC-1eedc2b4af192973889341da5615139cfd65f152.tar.bz2
opensim-SC-1eedc2b4af192973889341da5615139cfd65f152.tar.xz
Compute rotation for llLookAt() with local positive X axis pointing down
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs25
1 files changed, 11 insertions, 14 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 97e3eeb..debc262 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -3092,20 +3092,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3092 // Determine where we are looking from 3092 // Determine where we are looking from
3093 LSL_Vector from = llGetPos(); 3093 LSL_Vector from = llGetPos();
3094 3094
3095 // Work out the normalised vector from the source to the target 3095 // normalized direction to target
3096 LSL_Vector delta = llVecNorm(target - from); 3096 LSL_Vector dir = llVecNorm(target - from);
3097 LSL_Vector angle = new LSL_Vector(0,0,0); 3097 // use vertical to help compute left azis
3098 3098 LSL_Vector up = new LSL_Vector(0.0, 0.0, 1.0);
3099 // Calculate the yaw 3099 // find normalized left axis parallel to horizon
3100 // subtracting PI_BY_TWO is required to compensate for the odd SL co-ordinate system 3100 LSL_Vector left = llVecNorm(LSL_Vector.Cross(up, dir));
3101 angle.x = llAtan2(delta.z, delta.y) - ScriptBaseClass.PI_BY_TWO; 3101 // make up orthogonal to left and dir
3102 3102 up = LSL_Vector.Cross(dir, left);
3103 // Calculate pitch 3103
3104 angle.y = llAtan2(delta.x, llSqrt((delta.y * delta.y) + (delta.z * delta.z))); 3104 // compute rotation based on orthogonal azes
3105 3105 LSL_Rotation rot = new LSL_Rotation(0.0, 0.707107, 0.0, 0.707107) * llAxes2Rot(dir, left, up);
3106 // we need to convert from a vector describing
3107 // the angles of rotation in radians into rotation value
3108 LSL_Rotation rot = llEuler2Rot(angle);
3109 3106
3110 // Per discussion with Melanie, for non-physical objects llLookAt appears to simply 3107 // Per discussion with Melanie, for non-physical objects llLookAt appears to simply
3111 // set the rotation of the object, copy that behavior 3108 // set the rotation of the object, copy that behavior