From 08750501617ca332ab196b2f25030e3c635c9dd6 Mon Sep 17 00:00:00 2001 From: dahlia Date: Tue, 10 Dec 2013 13:57:18 -0800 Subject: [PATCH] Add console utility commands "scale scene" and "translate scene". Note that repeated use of these commands will induce floating point accumulation errors. Please back up your region before using. --- OpenSim/Region/Application/OpenSim.cs | 90 ++++++++++++++++++++++++++- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index c2d9942ba6..0a6ae98e39 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -297,10 +297,20 @@ namespace OpenSim HandleEditScale); m_console.Commands.AddCommand("Objects", false, "rotate scene", - "rotate scene ", - "Rotates all scene objects around x:128, y:128", + "rotate scene [centerX, centerY]", + "Rotates all scene objects around centerX, centerY (defailt 128, 128) (please back up your region before using)", HandleRotateScene); + m_console.Commands.AddCommand("Objects", false, "scale scene", + "scale scene ", + "Scales the scene objects (please back up your region before using)", + HandleScaleScene); + + m_console.Commands.AddCommand("Objects", false, "translate scene", + "translate scene xOffset yOffset zOffset", + "translates the scene objects (please back up your region before using)", + HandleTranslateScene); + m_console.Commands.AddCommand("Users", false, "kick user", "kick user [--force] [message]", "Kick a user off the simulator", @@ -549,6 +559,82 @@ namespace OpenSim }); } + private void HandleScaleScene(string module, string[] args) + { + string usage = "Usage: scale scene "; + + if (args.Length < 3) + { + MainConsole.Instance.Output(usage); + return; + } + + float factor = (float)(Convert.ToSingle(args[2])); + + float minZ = float.MaxValue; + + SceneManager.ForEachSelectedScene(delegate(Scene scene) + { + scene.ForEachSOG(delegate(SceneObjectGroup sog) + { + if (sog.AttachmentPoint == 0) + { + if (sog.RootPart.AbsolutePosition.Z < minZ) + minZ = sog.RootPart.AbsolutePosition.Z; + } + }); + }); + + SceneManager.ForEachSelectedScene(delegate(Scene scene) + { + scene.ForEachSOG(delegate(SceneObjectGroup sog) + { + if (sog.AttachmentPoint == 0) + { + Vector3 tmpRootPos = sog.RootPart.AbsolutePosition; + tmpRootPos.Z -= minZ; + tmpRootPos *= factor; + tmpRootPos.Z += minZ; + + foreach (SceneObjectPart sop in sog.Parts) + { + if (sop.ParentID != 0) + sop.OffsetPosition *= factor; + sop.Scale *= factor; + } + + sog.UpdateGroupPosition(tmpRootPos); + } + }); + }); + } + + private void HandleTranslateScene(string module, string[] args) + { + string usage = "Usage: translate scene "; + + if (args.Length < 5) + { + MainConsole.Instance.Output(usage); + return; + } + + float xOFfset = (float)Convert.ToSingle(args[2]); + float yOffset = (float)Convert.ToSingle(args[3]); + float zOffset = (float)Convert.ToSingle(args[4]); + + Vector3 offset = new Vector3(xOFfset, yOffset, zOffset); + + SceneManager.ForEachSelectedScene(delegate(Scene scene) + { + scene.ForEachSOG(delegate(SceneObjectGroup sog) + { + if (sog.AttachmentPoint == 0) + sog.UpdateGroupPosition(sog.AbsolutePosition + offset); + }); + }); + } + /// /// Creates a new region based on the parameters specified. This will ask the user questions on the console ///