From f74a9bcdc7b0682c1c205e9d640fbfa5f214840b Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Thu, 24 Jul 2008 07:45:58 +0000 Subject: Implements llSetForce() and llGetForce(). These are experimental and the units may not match the Linden implementation. --- .../Shared/Api/Implementation/LSL_Api.cs | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9832cfc..ed320f8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -43,6 +43,7 @@ using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; using OpenSim.Region.Environment.Modules.World.Land; using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Physics.Manager; using OpenSim.Region.ScriptEngine.Shared; using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; using OpenSim.Region.ScriptEngine.Shared.ScriptBase; @@ -1430,14 +1431,40 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetForce(LSL_Types.Vector3 force, int local) { m_host.AddScriptLPS(1); - NotImplemented("llSetForce"); + //NotImplemented("llSetForce"); + + if (m_host.ParentGroup != null) + { + if (m_host.ParentGroup.RootPart != null) + { + if (local != 0) + force *= llGetRot(); + + m_host.ParentGroup.RootPart.SetForce(new PhysicsVector((float)force.x, (float)force.y, (float)force.z)); + } + } } public LSL_Types.Vector3 llGetForce() { + LSL_Types.Vector3 force = new LSL_Types.Vector3(0.0, 0.0, 0.0); + m_host.AddScriptLPS(1); - NotImplemented("llGetForce"); - return new LSL_Types.Vector3(); + //NotImplemented("llGetForce"); + //return new LSL_Types.Vector3(); + + if (m_host.ParentGroup != null) + { + if (m_host.ParentGroup.RootPart != null) + { + PhysicsVector tmpForce = m_host.ParentGroup.RootPart.GetForce(); + force.x = tmpForce.X; + force.y = tmpForce.Y; + force.z = tmpForce.Z; + } + } + + return force; } public LSL_Types.LSLInteger llTarget(LSL_Types.Vector3 position, double range) -- cgit v1.1