diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 57 |
1 files changed, 1 insertions, 56 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 943f37d..ac22638 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -3039,7 +3039,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3039 | 3039 | ||
3040 | public void llLookAt(LSL_Vector target, double strength, double damping) | 3040 | public void llLookAt(LSL_Vector target, double strength, double damping) |
3041 | { | 3041 | { |
3042 | /* | ||
3043 | m_host.AddScriptLPS(1); | 3042 | m_host.AddScriptLPS(1); |
3044 | // Determine where we are looking from | 3043 | // Determine where we are looking from |
3045 | LSL_Vector from = llGetPos(); | 3044 | LSL_Vector from = llGetPos(); |
@@ -3058,69 +3057,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3058 | // we need to convert from a vector describing | 3057 | // we need to convert from a vector describing |
3059 | // the angles of rotation in radians into rotation value | 3058 | // the angles of rotation in radians into rotation value |
3060 | 3059 | ||
3061 | <<<<<<< HEAD:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | ||
3062 | LSL_Types.Quaternion rot = llEuler2Rot(angle); | ||
3063 | |||
3064 | // This would only work if your physics system contains an APID controller: | ||
3065 | // Quaternion rotation = new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
3066 | // m_host.startLookAt(rotation, (float)damping, (float)strength); | ||
3067 | |||
3068 | // Orient the object to the angle calculated | ||
3069 | llSetRot(rot); | ||
3070 | */ | ||
3071 | |||
3072 | //The above code, while nice, doesn't replicate the behaviour of SL and tends to "roll" the object. | ||
3073 | //There's probably a smarter way of doing this, my rotation math-fu is weak. | ||
3074 | // http://bugs.meta7.com/view.php?id=28 | ||
3075 | // - Tom | ||
3076 | |||
3077 | /* And the following does not do the job either. It has to be performed inside the ODE glue-code. -.- .._. | ||
3078 | LSL_Rotation newrot = llGetRot() * llRotBetween(new LSL_Vector(1.0d, 0.0d, 0.0d) * llGetRot(), new LSL_Vector(0.0d, 0.0d, -1.0d)); | ||
3079 | llSetRot(newrot * llRotBetween(new LSL_Vector(0.0d,0.0d,1.0d) * newrot, target - llGetPos())); | ||
3080 | */ | ||
3081 | if (m_host.PhysActor != null && !m_host.PhysActor.IsPhysical) | ||
3082 | { | ||
3083 | // Part is non-phys, convert this to a llSetRot() | ||
3084 | Vector3 tgt = new Vector3((float)target.x, (float)target.y, (float)target.z); | ||
3085 | Vector3 dir = tgt - m_host.GroupPosition; | ||
3086 | dir.Normalize(); | ||
3087 | float tzrot = (float)Math.Atan2(dir.Y, dir.X); | ||
3088 | float txy = (float)Math.Sqrt((dir.X * dir.X) + (dir.Y * dir.Y)); | ||
3089 | float terot = (float)Math.Atan2(-dir.Z, txy); | ||
3090 | LSL_Vector az = new LSL_Vector(0.0f, 0.0f, tzrot); | ||
3091 | LSL_Vector ae = new LSL_Vector(0.0f, terot, 0.0f); | ||
3092 | LSL_Types.Quaternion spin = llEuler2Rot(az); | ||
3093 | LSL_Types.Quaternion rot = llEuler2Rot(ae) * spin; | ||
3094 | ======= | ||
3095 | LSL_Rotation rot = llEuler2Rot(angle); | 3060 | LSL_Rotation rot = llEuler2Rot(angle); |
3096 | 3061 | ||
3097 | // Per discussion with Melanie, for non-physical objects llLookAt appears to simply | 3062 | // Per discussion with Melanie, for non-physical objects llLookAt appears to simply |
3098 | // set the rotation of the object, copy that behavior | 3063 | // set the rotation of the object, copy that behavior |
3099 | if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) | 3064 | if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical) |
3100 | { | 3065 | { |
3101 | >>>>>>> master:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | ||
3102 | llSetRot(rot); | 3066 | llSetRot(rot); |
3103 | } | 3067 | } |
3104 | else | 3068 | else |
3105 | { | 3069 | { |
3106 | <<<<<<< HEAD:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | ||
3107 | // Physical, send the target vector to RotLookAt method inside a 'rotation', the .w -99.9 value indicates it is really a LookAt. | ||
3108 | Quaternion q = new Quaternion((float)target.x, (float)target.y, (float)target.z, -99.9f); | ||
3109 | m_host.RotLookAt(q, (float)strength, (float)damping); | ||
3110 | } | ||
3111 | |||
3112 | } | ||
3113 | |||
3114 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | ||
3115 | { | ||
3116 | m_host.AddScriptLPS(1); | ||
3117 | // NotImplemented("llRotLookAt"); | ||
3118 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | ||
3119 | |||
3120 | ======= | ||
3121 | m_host.StartLookAt(Rot2Quaternion(rot), (float)strength, (float)damping); | 3070 | m_host.StartLookAt(Rot2Quaternion(rot), (float)strength, (float)damping); |
3122 | } | 3071 | } |
3123 | >>>>>>> master:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | ||
3124 | } | 3072 | } |
3125 | 3073 | ||
3126 | public void llStopLookAt() | 3074 | public void llStopLookAt() |
@@ -3543,8 +3491,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3543 | m_host.AddScriptLPS(1); | 3491 | m_host.AddScriptLPS(1); |
3544 | } | 3492 | } |
3545 | 3493 | ||
3546 | <<<<<<< HEAD:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | ||
3547 | ======= | ||
3548 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) | 3494 | public void llRotLookAt(LSL_Rotation target, double strength, double damping) |
3549 | { | 3495 | { |
3550 | m_host.AddScriptLPS(1); | 3496 | m_host.AddScriptLPS(1); |
@@ -3561,7 +3507,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3561 | } | 3507 | } |
3562 | } | 3508 | } |
3563 | 3509 | ||
3564 | >>>>>>> master:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | ||
3565 | public LSL_Integer llStringLength(string str) | 3510 | public LSL_Integer llStringLength(string str) |
3566 | { | 3511 | { |
3567 | m_host.AddScriptLPS(1); | 3512 | m_host.AddScriptLPS(1); |