29 using System.Reflection;
30 using System.Collections.Generic;
34 using OpenSim.Framework;
35 using OpenSim.Framework.Console;
36 using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
37 using OpenSim.Region.Framework.Interfaces;
38 using OpenSim.Region.Framework.Scenes;
39 using OpenSim.Region.PhysicsModules.SharedBase;
47 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"PhysicsParameters")]
53 private List<Scene> m_scenes =
new List<Scene>();
54 private static bool m_commandsLoaded =
false;
56 #region ISharedRegionModule
57 public string Name {
get {
return "Runtime Physics Parameter Module"; } }
59 public Type ReplaceableInterface {
get {
return null; } }
86 if (m_scenes.Contains(scene))
87 m_scenes.Remove(scene);
94 #endregion INonSharedRegionModule
96 private const string getInvocation =
"physics get [<param>|ALL]";
97 private const string setInvocation =
"physics set <param> [<value>|TRUE|FALSE] [localID|ALL]";
98 private const string listInvocation =
"physics list";
99 private void InstallInterfaces()
101 if (!m_commandsLoaded)
103 MainConsole.Instance.Commands.AddCommand(
104 "Regions",
false,
"physics set",
106 "Set physics parameter from currently selected region",
109 MainConsole.Instance.Commands.AddCommand(
110 "Regions",
false,
"physics get",
112 "Get physics parameter from currently selected region",
115 MainConsole.Instance.Commands.AddCommand(
116 "Regions",
false,
"physics list",
118 "List settable physics parameters",
121 m_commandsLoaded =
true;
126 private void ProcessPhysicsGet(
string module,
string[] cmdparms)
128 if (cmdparms.Length != 3)
130 WriteError(
"Parameter count error. Invocation: " + getInvocation);
133 string parm = cmdparms[2];
137 WriteError(
"Error: no region selected. Use 'change region' to select a region.");
141 Scene scene = SceneManager.Instance.CurrentScene;
143 if (physScene != null)
145 if (parm.ToLower() ==
"all")
149 string val = string.Empty;
162 string val = string.Empty;
169 WriteError(
"Failed fetch of parameter '{0}' from region '{1}'", parm, scene.
RegionInfo.
RegionName);
175 WriteError(
"Region '{0}' physics engine has no gettable physics parameters", scene.
RegionInfo.
RegionName);
180 private void ProcessPhysicsSet(
string module,
string[] cmdparms)
182 if (cmdparms.Length < 4 || cmdparms.Length > 5)
184 WriteError(
"Parameter count error. Invocation: " + getInvocation);
188 string valparm = String.Empty;
193 valparm = cmdparms[3].ToLower();
194 if (cmdparms.Length > 4)
196 if (cmdparms[4].ToLower() ==
"all")
204 WriteError(
" Error parsing parameters. Invocation: " + setInvocation);
210 WriteError(
"Error: no region selected. Use 'change region' to select a region.");
214 Scene scene = SceneManager.Instance.CurrentScene;
215 IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters;
216 if (physScene != null)
220 WriteError(
"Failed set of parameter '{0}' for region '{1}'", parm, scene.
RegionInfo.
RegionName);
225 WriteOut(
"Region '{0}'s physics engine has no settable physics parameters", scene.
RegionInfo.
RegionName);
230 private void ProcessPhysicsList(
string module,
string[] cmdparms)
234 WriteError(
"Error: no region selected. Use 'change region' to select a region.");
237 Scene scene = SceneManager.Instance.CurrentScene;
239 IPhysicsParameters physScene = scene.PhysicsScene as IPhysicsParameters;
240 if (physScene != null)
242 WriteOut(
"Available physics parameters:");
246 WriteOut(
" {0}: {1}", ent.
name, ent.
desc);
251 WriteError(
"Current regions's physics engine has no settable physics parameters");
256 private void WriteOut(
string msg, params
object[] args)
259 MainConsole.Instance.OutputFormat(msg, args);
262 private void WriteError(
string msg, params
object[] args)
265 MainConsole.Instance.OutputFormat(msg, args);
static NumberFormatInfo NumberFormatInfo
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
void Initialise(IConfigSource source)
This is called to initialize the region module. For shared modules, this is called exactly once...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
static SceneManager Instance
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
bool GetPhysicsParameter(string parm, out string value)
Manager for adding, closing and restarting scenes.
PhysParameterEntry[] GetParameterList()
Scene CurrentScene
Scene selected from the console.
Interactive OpenSim region server
bool SetPhysicsParameter(string parm, string value, uint localID)
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
virtual RegionInfo RegionInfo
void PostInitialise()
This is called exactly once after all the shared region-modules have been instanciated and IRegionMod...