aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain
diff options
context:
space:
mode:
authorAdam Frisby2008-04-22 07:53:32 +0000
committerAdam Frisby2008-04-22 07:53:32 +0000
commitc8eb8d66fdedebbbb82348a9a60cd47fb0955305 (patch)
tree24572c1d599a1b9e249b190070e1cebbcbc29583 /OpenSim/Region/Environment/Modules/Terrain
parent* Added missing reference to OpenSim.Framework.Communications to RemoteAdminP... (diff)
downloadopensim-SC_OLD-c8eb8d66fdedebbbb82348a9a60cd47fb0955305.zip
opensim-SC_OLD-c8eb8d66fdedebbbb82348a9a60cd47fb0955305.tar.gz
opensim-SC_OLD-c8eb8d66fdedebbbb82348a9a60cd47fb0955305.tar.bz2
opensim-SC_OLD-c8eb8d66fdedebbbb82348a9a60cd47fb0955305.tar.xz
* Committing new terrain plugin effects system. Loads DLLs in /bin/Terrain/ as terrain module extensions. Committing sample plugin library.
* prebuild.xml changes.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs83
1 files changed, 73 insertions, 10 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
index f758c91..40d4771 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
@@ -35,7 +35,6 @@ using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.Environment.Modules.ModuleFramework; 37using OpenSim.Region.Environment.Modules.ModuleFramework;
38using OpenSim.Region.Environment.Modules.Terrain.Effects;
39using OpenSim.Region.Environment.Modules.Terrain.FileLoaders; 38using OpenSim.Region.Environment.Modules.Terrain.FileLoaders;
40using OpenSim.Region.Environment.Modules.Terrain.FloodBrushes; 39using OpenSim.Region.Environment.Modules.Terrain.FloodBrushes;
41using OpenSim.Region.Environment.Modules.Terrain.PaintBrushes; 40using OpenSim.Region.Environment.Modules.Terrain.PaintBrushes;
@@ -80,6 +79,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
80 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); 79 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
81 80
82 private ITerrainChannel m_channel; 81 private ITerrainChannel m_channel;
82 private Dictionary<string, ITerrainEffect> m_plugineffects;
83 private ITerrainChannel m_revert; 83 private ITerrainChannel m_revert;
84 private Scene m_scene; 84 private Scene m_scene;
85 private bool m_tainted = false; 85 private bool m_tainted = false;
@@ -135,6 +135,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
135 { 135 {
136 InstallDefaultEffects(); 136 InstallDefaultEffects();
137 InstallInterfaces(); 137 InstallInterfaces();
138 LoadPlugins();
138 } 139 }
139 140
140 public void Close() 141 public void Close()
@@ -184,7 +185,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
184 { 185 {
185 m_log.Error( 186 m_log.Error(
186 "[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)"); 187 "[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)");
187 throw new Exception(String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access", 188 throw new Exception(String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access",
188 filename)); 189 filename));
189 } 190 }
190 } 191 }
@@ -194,7 +195,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
194 } 195 }
195 } 196 }
196 m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format."); 197 m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format.");
197 throw new Exception(String.Format("unable to load heightmap from file {0}: no loader available for that format", 198 throw new Exception(String.Format("unable to load heightmap from file {0}: no loader available for that format",
198 filename)); 199 filename));
199 } 200 }
200 201
@@ -222,6 +223,46 @@ namespace OpenSim.Region.Environment.Modules.Terrain
222 } 223 }
223 } 224 }
224 225
226 #region Plugin Loading Methods
227
228 private void LoadPlugins()
229 {
230 m_plugineffects = new Dictionary<string, ITerrainEffect>();
231 // Load the files in the Terrain/ dir
232 string[] files = Directory.GetFiles("Terrain");
233 foreach (string file in files)
234 {
235 m_log.Info("Loading effects in " + file);
236 try
237 {
238 Assembly library = Assembly.LoadFrom(file);
239 foreach (Type pluginType in library.GetTypes())
240 {
241 try
242 {
243 if (pluginType.IsAbstract || pluginType.IsNotPublic)
244 continue;
245
246 if (pluginType.GetInterface("ITerrainEffect", false) != null)
247 {
248 ITerrainEffect terEffect = (ITerrainEffect) Activator.CreateInstance(library.GetType(pluginType.ToString()));
249 m_plugineffects.Add(pluginType.Name, terEffect);
250 m_log.Info("... " + pluginType.Name);
251 }
252 }
253 catch (AmbiguousMatchException)
254 {
255 }
256 }
257 }
258 catch (BadImageFormatException)
259 {
260 }
261 }
262 }
263
264 #endregion
265
225 #endregion 266 #endregion
226 267
227 /// <summary> 268 /// <summary>
@@ -564,10 +605,31 @@ namespace OpenSim.Region.Environment.Modules.Terrain
564 } 605 }
565 } 606 }
566 607
567 private void InterfacePerformEffectTest(Object[] args) 608 private void InterfaceRunPluginEffect(Object[] args)
568 { 609 {
569 CookieCutter cookie = new CookieCutter(); 610 if ((string) args[0] == "list")
570 cookie.RunEffect(m_channel); 611 {
612 m_log.Info("List of loaded plugins");
613 foreach (KeyValuePair<string, ITerrainEffect> kvp in m_plugineffects)
614 {
615 m_log.Info(kvp.Key);
616 }
617 return;
618 }
619 if ((string) args[0] == "reload")
620 {
621 LoadPlugins();
622 return;
623 }
624 if (m_plugineffects.ContainsKey((string) args[0]))
625 {
626 m_plugineffects[(string) args[0]].RunEffect(m_channel);
627 CheckForTerrainUpdates();
628 }
629 else
630 {
631 m_log.Warn("No such plugin effect loaded.");
632 }
571 } 633 }
572 634
573 private void InstallInterfaces() 635 private void InstallInterfaces()
@@ -634,9 +696,10 @@ namespace OpenSim.Region.Environment.Modules.Terrain
634 "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time."); 696 "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time.");
635 experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean"); 697 experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean");
636 698
637 // Effects 699 //Plugins
638 Command effectsTestCommand = 700 Command pluginRunCommand =
639 new Command("test", InterfacePerformEffectTest, "Performs an effects module test"); 701 new Command("effect", InterfaceRunPluginEffect, "Runs a specified plugin effect");
702 pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String");
640 703
641 m_commander.RegisterCommand("load", loadFromFileCommand); 704 m_commander.RegisterCommand("load", loadFromFileCommand);
642 m_commander.RegisterCommand("load-tile", loadFromTileCommand); 705 m_commander.RegisterCommand("load-tile", loadFromTileCommand);
@@ -648,8 +711,8 @@ namespace OpenSim.Region.Environment.Modules.Terrain
648 m_commander.RegisterCommand("bake", bakeRegionCommand); 711 m_commander.RegisterCommand("bake", bakeRegionCommand);
649 m_commander.RegisterCommand("revert", revertRegionCommand); 712 m_commander.RegisterCommand("revert", revertRegionCommand);
650 m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand); 713 m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand);
651 m_commander.RegisterCommand("test", effectsTestCommand);
652 m_commander.RegisterCommand("stats", showDebugStatsCommand); 714 m_commander.RegisterCommand("stats", showDebugStatsCommand);
715 m_commander.RegisterCommand("effect", pluginRunCommand);
653 716
654 // Add this to our scene so scripts can call these functions 717 // Add this to our scene so scripts can call these functions
655 m_scene.RegisterModuleCommander("Terrain", m_commander); 718 m_scene.RegisterModuleCommander("Terrain", m_commander);