From 571bd78e587c409a3fcba4a8ec48c0187843997d Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Sun, 15 Jul 2007 22:36:35 +0000 Subject: [PATCH] * More scripting enhancemnents and properties. --- .../Region/Environment/Scenes/Primitive.cs | 8 ++++ OpenSim/Region/Environment/Scenes/Scene.cs | 5 +++ .../Region/Environment/Scenes/SceneObject.cs | 8 ++++ .../Examples/ExportRegionToLSL.cs | 44 +++++++++++++++++-- 4 files changed, 62 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index 23dcf6e771..0e5b08329f 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs @@ -81,6 +81,14 @@ namespace OpenSim.Region.Environment.Scenes } + public PrimitiveBaseShape Shape + { + get + { + return this.m_Shape; + } + } + public LLVector3 WorldPos { get diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index aa081724d9..5e2e49478d 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -112,6 +112,11 @@ namespace OpenSim.Region.Environment.Scenes get { return m_scriptManager; } } + public Dictionary Objects + { + get { return Prims; } + } + #endregion #region Constructors diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index c9255841bd..8de7cdb322 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs @@ -75,6 +75,14 @@ namespace OpenSim.Region.Environment.Scenes } } + public Dictionary Children + { + get + { + return this.ChildPrimitives; + } + } + /// /// /// 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 4cc2c96eaa..d9f1f0a220 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