From 571bd78e587c409a3fcba4a8ec48c0187843997d Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 15 Jul 2007 22:36:35 +0000 Subject: * More scripting enhancemnents and properties. --- .../CSharpEngine/Examples/ExportRegionToLSL.cs | 44 ++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes/scripting/Engines') diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs index 4cc2c96..d9f1f0a 100644 --- a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs +++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs @@ -3,6 +3,9 @@ using OpenSim.Framework; using OpenSim.Region.Environment; using OpenSim.Region.Environment.Scenes; +using System.Collections.Generic; +using libsecondlife; + namespace OpenSim.Region.Scripting.Examples { public class LSLExportScript : IScript @@ -18,15 +21,50 @@ namespace OpenSim.Region.Scripting.Examples { script = scriptInfo; - script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(events_OnScriptConsole); + script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg); } - void events_OnScriptConsole(string[] args) + void ProcessConsoleMsg(string[] args) { if (args[0].ToLower() == "lslexport") { - + string sequence = ""; + + foreach (KeyValuePair obj in script.world.Objects) + { + SceneObject root = obj.Value; + + sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n"; + + string rootPrim = processPrimitiveToString(root.rootPrimitive); + + sequence += "ROOT:" + rootPrim; + + foreach (KeyValuePair prim in root.Children) + { + string child = processPrimitiveToString(prim.Value); + sequence += "CHILD:" + child; + } + } + + System.Console.WriteLine(sequence); } } + + string processPrimitiveToString(OpenSim.Region.Environment.Scenes.Primitive prim) + { + string desc = prim.Description; + string name = prim.Name; + LLVector3 pos = prim.Pos; + LLVector3 rot = new LLVector3(); + LLVector3 scale = prim.Scale; + LLVector3 rootPos = prim.WorldPos; + + string setPrimParams = ""; + + setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n"; + + return setPrimParams; + } } } \ No newline at end of file -- cgit v1.1