aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs734
1 files changed, 0 insertions, 734 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
deleted file mode 100644
index 67acef7..0000000
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ /dev/null
@@ -1,734 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Reflection;
32using libsecondlife;
33using log4net;
34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.Environment.Modules.ModuleFramework;
38using OpenSim.Region.Environment.Modules.Terrain.FileLoaders;
39using OpenSim.Region.Environment.Modules.Terrain.FloodBrushes;
40using OpenSim.Region.Environment.Modules.Terrain.PaintBrushes;
41using OpenSim.Region.Environment.Scenes;
42
43namespace OpenSim.Region.Environment.Modules.Terrain
44{
45 public class TerrainModule : IRegionModule, ICommandableModule, ITerrainModule
46 {
47 #region StandardTerrainEffects enum
48
49 /// <summary>
50 /// A standard set of terrain brushes and effects recognised by viewers
51 /// </summary>
52 public enum StandardTerrainEffects : byte
53 {
54 Flatten = 0,
55 Raise = 1,
56 Lower = 2,
57 Smooth = 3,
58 Noise = 4,
59 Revert = 5,
60
61 // Extended brushes
62 Erode = 255,
63 Weather = 254,
64 Olsen = 253
65 }
66
67 #endregion
68
69 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
70
71 private readonly Commander m_commander = new Commander("Terrain");
72
73 private readonly Dictionary<StandardTerrainEffects, ITerrainFloodEffect> m_floodeffects =
74 new Dictionary<StandardTerrainEffects, ITerrainFloodEffect>();
75
76 private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
77
78 private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =
79 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
80
81 private ITerrainChannel m_channel;
82 private Dictionary<string, ITerrainEffect> m_plugineffects;
83 private ITerrainChannel m_revert;
84 private Scene m_scene;
85 private bool m_tainted = false;
86
87 #region ICommandableModule Members
88
89 public ICommander CommandInterface
90 {
91 get { return m_commander; }
92 }
93
94 #endregion
95
96 #region IRegionModule Members
97
98 /// <summary>
99 /// Creates and initialises a terrain module for a region
100 /// </summary>
101 /// <param name="scene">Region initialising</param>
102 /// <param name="config">Config for the region</param>
103 public void Initialise(Scene scene, IConfigSource config)
104 {
105 m_scene = scene;
106
107 // Install terrain module in the simulator
108 if (m_scene.Heightmap == null)
109 {
110 lock (m_scene)
111 {
112 m_channel = new TerrainChannel();
113 m_scene.Heightmap = m_channel;
114 m_revert = new TerrainChannel();
115 UpdateRevertMap();
116 }
117 }
118 else
119 {
120 m_channel = m_scene.Heightmap;
121 m_revert = new TerrainChannel();
122 UpdateRevertMap();
123 }
124
125 m_scene.RegisterModuleInterface<ITerrainModule>(this);
126 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
127 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
128 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
129 }
130
131 /// <summary>
132 /// Enables terrain module when called
133 /// </summary>
134 public void PostInitialise()
135 {
136 InstallDefaultEffects();
137 InstallInterfaces();
138 LoadPlugins();
139 }
140
141 public void Close()
142 {
143 }
144
145 public string Name
146 {
147 get { return "TerrainModule"; }
148 }
149
150 public bool IsSharedModule
151 {
152 get { return false; }
153 }
154
155 #endregion
156
157 #region ITerrainModule Members
158
159 /// <summary>
160 /// Loads a terrain file from disk and installs it in the scene.
161 /// </summary>
162 /// <param name="filename">Filename to terrain file. Type is determined by extension.</param>
163 public void LoadFromFile(string filename)
164 {
165 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
166 {
167 if (filename.EndsWith(loader.Key))
168 {
169 lock (m_scene)
170 {
171 try
172 {
173 ITerrainChannel channel = loader.Value.LoadFile(filename);
174 m_scene.Heightmap = channel;
175 m_channel = channel;
176 UpdateRevertMap();
177 }
178 catch (NotImplementedException)
179 {
180 m_log.Error("[TERRAIN]: Unable to load heightmap, the " + loader.Value +
181 " parser does not support file loading. (May be save only)");
182 throw new TerrainException(String.Format("unable to load heightmap: parser {0} does not support loading", loader.Value));
183 }
184 catch (FileNotFoundException)
185 {
186 m_log.Error(
187 "[TERRAIN]: Unable to load heightmap, file not found. (A directory permissions error may also cause this)");
188 throw new TerrainException(
189 String.Format("unable to load heightmap: file {0} not found (or permissions do not allow access", filename));
190 }
191 }
192 CheckForTerrainUpdates();
193 m_log.Info("[TERRAIN]: File (" + filename + ") loaded successfully");
194 return;
195 }
196 }
197 m_log.Error("[TERRAIN]: Unable to load heightmap, no file loader availible for that format.");
198 throw new TerrainException(String.Format("unable to load heightmap from file {0}: no loader available for that format", filename));
199 }
200
201 /// <summary>
202 /// Saves the current heightmap to a specified file.
203 /// </summary>
204 /// <param name="filename">The destination filename</param>
205 public void SaveToFile(string filename)
206 {
207 try
208 {
209 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
210 {
211 if (filename.EndsWith(loader.Key))
212 {
213 loader.Value.SaveFile(filename, m_channel);
214 return;
215 }
216 }
217 }
218 catch (NotImplementedException)
219 {
220 m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented.");
221 throw new TerrainException(String.Format("unable to save heightmap: {0}: saving of this file format not implemented"));
222 }
223 }
224
225 #region Plugin Loading Methods
226
227 private void LoadPlugins()
228 {
229 m_plugineffects = new Dictionary<string, ITerrainEffect>();
230 // Load the files in the Terrain/ dir
231 string[] files = Directory.GetFiles("Terrain");
232 foreach (string file in files)
233 {
234 m_log.Info("Loading effects in " + file);
235 try
236 {
237 Assembly library = Assembly.LoadFrom(file);
238 foreach (Type pluginType in library.GetTypes())
239 {
240 try
241 {
242 if (pluginType.IsAbstract || pluginType.IsNotPublic)
243 continue;
244
245 if (pluginType.GetInterface("ITerrainEffect", false) != null)
246 {
247 ITerrainEffect terEffect = (ITerrainEffect) Activator.CreateInstance(library.GetType(pluginType.ToString()));
248 if (!m_plugineffects.ContainsKey(pluginType.Name))
249 {
250 m_plugineffects.Add(pluginType.Name, terEffect);
251 m_log.Info("E ... " + pluginType.Name);
252 } else
253 {
254 m_log.Warn("E ... " + pluginType.Name + " (Already added)");
255 }
256 }
257 else if (pluginType.GetInterface("ITerrainLoader", false) != null)
258 {
259 ITerrainLoader terLoader = (ITerrainLoader) Activator.CreateInstance(library.GetType(pluginType.ToString()));
260 m_loaders[terLoader.FileExtension] = terLoader;
261 m_log.Info("L ... " + pluginType.Name);
262 }
263 }
264 catch (AmbiguousMatchException)
265 {
266 }
267 }
268 }
269 catch (BadImageFormatException)
270 {
271 }
272 }
273 }
274
275 #endregion
276
277 #endregion
278
279 /// <summary>
280 /// Installs into terrain module the standard suite of brushes
281 /// </summary>
282 private void InstallDefaultEffects()
283 {
284 // Draggable Paint Brush Effects
285 m_painteffects[StandardTerrainEffects.Raise] = new RaiseSphere();
286 m_painteffects[StandardTerrainEffects.Lower] = new LowerSphere();
287 m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere();
288 m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere();
289 m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere();
290 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_revert);
291 m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere();
292 m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere();
293 m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere();
294
295 // Area of effect selection effects
296 m_floodeffects[StandardTerrainEffects.Raise] = new RaiseArea();
297 m_floodeffects[StandardTerrainEffects.Lower] = new LowerArea();
298 m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea();
299 m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea();
300 m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea();
301 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_revert);
302
303 // Filesystem load/save loaders
304 m_loaders[".r32"] = new RAW32();
305 m_loaders[".f32"] = m_loaders[".r32"];
306 m_loaders[".ter"] = new Terragen();
307 m_loaders[".raw"] = new LLRAW();
308 m_loaders[".jpg"] = new JPEG();
309 m_loaders[".jpeg"] = m_loaders[".jpg"];
310 m_loaders[".bmp"] = new BMP();
311 m_loaders[".png"] = new PNG();
312 m_loaders[".gif"] = new GIF();
313 m_loaders[".tif"] = new TIFF();
314 m_loaders[".tiff"] = m_loaders[".tif"];
315 }
316
317 /// <summary>
318 /// Saves the current state of the region into the revert map buffer.
319 /// </summary>
320 public void UpdateRevertMap()
321 {
322 int x;
323 for (x = 0; x < m_channel.Width; x++)
324 {
325 int y;
326 for (y = 0; y < m_channel.Height; y++)
327 {
328 m_revert[x, y] = m_channel[x, y];
329 }
330 }
331 }
332
333 /// <summary>
334 /// Loads a tile from a larger terrain file and installs it into the region.
335 /// </summary>
336 /// <param name="filename">The terrain file to load</param>
337 /// <param name="fileWidth">The width of the file in units</param>
338 /// <param name="fileHeight">The height of the file in units</param>
339 /// <param name="fileStartX">Where to begin our slice</param>
340 /// <param name="fileStartY">Where to begin our slice</param>
341 public void LoadFromFile(string filename, int fileWidth, int fileHeight, int fileStartX, int fileStartY)
342 {
343 int offsetX = (int) m_scene.RegionInfo.RegionLocX - fileStartX;
344 int offsetY = (int) m_scene.RegionInfo.RegionLocY - fileStartY;
345
346 if (offsetX >= 0 && offsetX < fileWidth && offsetY >= 0 && offsetY < fileHeight)
347 {
348 // this region is included in the tile request
349 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
350 {
351 if (filename.EndsWith(loader.Key))
352 {
353 lock (m_scene)
354 {
355 ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY,
356 fileWidth, fileHeight,
357 (int) Constants.RegionSize,
358 (int) Constants.RegionSize);
359 m_scene.Heightmap = channel;
360 m_channel = channel;
361 UpdateRevertMap();
362 }
363 return;
364 }
365 }
366 }
367 }
368
369 /// <summary>
370 /// Performs updates to the region periodically, synchronising physics and other heightmap aware sections
371 /// </summary>
372 private void EventManager_OnTerrainTick()
373 {
374 if (m_tainted)
375 {
376 m_tainted = false;
377 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised());
378 m_scene.SaveTerrain();
379 m_scene.CreateTerrainTexture(true);
380 }
381 }
382
383 /// <summary>
384 /// Processes commandline input. Do not call directly.
385 /// </summary>
386 /// <param name="args">Commandline arguments</param>
387 private void EventManager_OnPluginConsole(string[] args)
388 {
389 if (args[0] == "terrain")
390 {
391 string[] tmpArgs = new string[args.Length - 2];
392 int i;
393 for (i = 2; i < args.Length; i++)
394 tmpArgs[i - 2] = args[i];
395
396 m_commander.ProcessConsoleCommand(args[1], tmpArgs);
397 }
398 }
399
400 /// <summary>
401 /// Installs terrain brush hook to IClientAPI
402 /// </summary>
403 /// <param name="client"></param>
404 private void EventManager_OnNewClient(IClientAPI client)
405 {
406 client.OnModifyTerrain += client_OnModifyTerrain;
407 }
408
409 /// <summary>
410 /// Checks to see if the terrain has been modified since last check
411 /// </summary>
412 private void CheckForTerrainUpdates()
413 {
414 bool shouldTaint = false;
415 float[] serialised = m_channel.GetFloatsSerialised();
416 int x;
417 for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize)
418 {
419 int y;
420 for (y = 0; y < m_channel.Height; y += Constants.TerrainPatchSize)
421 {
422 if (m_channel.Tainted(x, y))
423 {
424 SendToClients(serialised, x, y);
425 shouldTaint = true;
426 }
427 }
428 }
429 if (shouldTaint)
430 {
431 m_tainted = true;
432 }
433 }
434
435 /// <summary>
436 /// Sends a copy of the current terrain to the scenes clients
437 /// </summary>
438 /// <param name="serialised">A copy of the terrain as a 1D float array of size w*h</param>
439 /// <param name="x">The patch corner to send</param>
440 /// <param name="y">The patch corner to send</param>
441 private void SendToClients(float[] serialised, int x, int y)
442 {
443 m_scene.ForEachClient(
444 delegate(IClientAPI controller) { controller.SendLayerData(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised); });
445 }
446
447 private void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west,
448 float south, float east, IClientAPI remoteClient)
449 {
450 // Not a good permissions check, if in area mode, need to check the entire area.
451 if (m_scene.PermissionsMngr.CanTerraform(remoteClient.AgentId, new LLVector3(north, west, 0)))
452 {
453 if (north == south && east == west)
454 {
455 if (m_painteffects.ContainsKey((StandardTerrainEffects) action))
456 {
457 m_painteffects[(StandardTerrainEffects) action].PaintEffect(
458 m_channel, west, south, size, seconds);
459
460 CheckForTerrainUpdates();
461 }
462 else
463 {
464 m_log.Debug("Unknown terrain brush type " + action);
465 }
466 }
467 else
468 {
469 if (m_floodeffects.ContainsKey((StandardTerrainEffects) action))
470 {
471 bool[,] fillArea = new bool[m_channel.Width,m_channel.Height];
472 fillArea.Initialize();
473
474 int x;
475 for (x = 0; x < m_channel.Width; x++)
476 {
477 int y;
478 for (y = 0; y < m_channel.Height; y++)
479 {
480 if (x < east && x > west)
481 {
482 if (y < north && y > south)
483 {
484 fillArea[x, y] = true;
485 }
486 }
487 }
488 }
489
490 m_floodeffects[(StandardTerrainEffects) action].FloodEffect(
491 m_channel, fillArea, size);
492
493 CheckForTerrainUpdates();
494 }
495 else
496 {
497 m_log.Debug("Unknown terrain flood type " + action);
498 }
499 }
500 }
501 }
502
503 #region Console Commands
504
505 private void InterfaceLoadFile(Object[] args)
506 {
507 LoadFromFile((string) args[0]);
508 CheckForTerrainUpdates();
509 }
510
511 private void InterfaceLoadTileFile(Object[] args)
512 {
513 LoadFromFile((string) args[0],
514 (int) args[1],
515 (int) args[2],
516 (int) args[3],
517 (int) args[4]);
518 CheckForTerrainUpdates();
519 }
520
521 private void InterfaceSaveFile(Object[] args)
522 {
523 SaveToFile((string) args[0]);
524 }
525
526 private void InterfaceBakeTerrain(Object[] args)
527 {
528 UpdateRevertMap();
529 }
530
531 private void InterfaceRevertTerrain(Object[] args)
532 {
533 int x, y;
534 for (x = 0; x < m_channel.Width; x++)
535 for (y = 0; y < m_channel.Height; y++)
536 m_channel[x, y] = m_revert[x, y];
537
538 CheckForTerrainUpdates();
539 }
540
541 private void InterfaceElevateTerrain(Object[] args)
542 {
543 int x, y;
544 for (x = 0; x < m_channel.Width; x++)
545 for (y = 0; y < m_channel.Height; y++)
546 m_channel[x, y] += (double) args[0];
547 CheckForTerrainUpdates();
548 }
549
550 private void InterfaceMultiplyTerrain(Object[] args)
551 {
552 int x, y;
553 for (x = 0; x < m_channel.Width; x++)
554 for (y = 0; y < m_channel.Height; y++)
555 m_channel[x, y] *= (double) args[0];
556 CheckForTerrainUpdates();
557 }
558
559 private void InterfaceLowerTerrain(Object[] args)
560 {
561 int x, y;
562 for (x = 0; x < m_channel.Width; x++)
563 for (y = 0; y < m_channel.Height; y++)
564 m_channel[x, y] -= (double) args[0];
565 CheckForTerrainUpdates();
566 }
567
568 private void InterfaceFillTerrain(Object[] args)
569 {
570 int x, y;
571
572 for (x = 0; x < m_channel.Width; x++)
573 for (y = 0; y < m_channel.Height; y++)
574 m_channel[x, y] = (double) args[0];
575 CheckForTerrainUpdates();
576 }
577
578 private void InterfaceShowDebugStats(Object[] args)
579 {
580 double max = Double.MinValue;
581 double min = double.MaxValue;
582 double avg;
583 double sum = 0;
584
585 int x;
586 for (x = 0; x < m_channel.Width; x++)
587 {
588 int y;
589 for (y = 0; y < m_channel.Height; y++)
590 {
591 sum += m_channel[x, y];
592 if (max < m_channel[x, y])
593 max = m_channel[x, y];
594 if (min > m_channel[x, y])
595 min = m_channel[x, y];
596 }
597 }
598
599 avg = sum / (m_channel.Height * m_channel.Width);
600
601 m_log.Info("Channel " + m_channel.Width + "x" + m_channel.Height);
602 m_log.Info("max/min/avg/sum: " + max + "/" + min + "/" + avg + "/" + sum);
603 }
604
605 private void InterfaceEnableExperimentalBrushes(Object[] args)
606 {
607 if ((bool) args[0])
608 {
609 m_painteffects[StandardTerrainEffects.Revert] = new WeatherSphere();
610 m_painteffects[StandardTerrainEffects.Flatten] = new OlsenSphere();
611 m_painteffects[StandardTerrainEffects.Smooth] = new ErodeSphere();
612 }
613 else
614 {
615 InstallDefaultEffects();
616 }
617 }
618
619 private void InterfaceRunPluginEffect(Object[] args)
620 {
621 if ((string) args[0] == "list")
622 {
623 m_log.Info("List of loaded plugins");
624 foreach (KeyValuePair<string, ITerrainEffect> kvp in m_plugineffects)
625 {
626 m_log.Info(kvp.Key);
627 }
628 return;
629 }
630 if ((string) args[0] == "reload")
631 {
632 LoadPlugins();
633 return;
634 }
635 if (m_plugineffects.ContainsKey((string) args[0]))
636 {
637 m_plugineffects[(string) args[0]].RunEffect(m_channel);
638 CheckForTerrainUpdates();
639 }
640 else
641 {
642 m_log.Warn("No such plugin effect loaded.");
643 }
644 }
645
646 private void InstallInterfaces()
647 {
648 // Load / Save
649 string supportedFileExtensions = "";
650 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
651 supportedFileExtensions += " " + loader.Key + " (" + loader.Value + ")";
652
653 Command loadFromFileCommand =
654 new Command("load", InterfaceLoadFile, "Loads a terrain from a specified file.");
655 loadFromFileCommand.AddArgument("filename",
656 "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
657 supportedFileExtensions, "String");
658
659 Command saveToFileCommand =
660 new Command("save", InterfaceSaveFile, "Saves the current heightmap to a specified file.");
661 saveToFileCommand.AddArgument("filename",
662 "The destination filename for your heightmap, the file extension determines the format to save in. Supported extensions include: " +
663 supportedFileExtensions, "String");
664
665 Command loadFromTileCommand =
666 new Command("load-tile", InterfaceLoadTileFile, "Loads a terrain from a section of a larger file.");
667 loadFromTileCommand.AddArgument("filename",
668 "The file you wish to load from, the file extension determines the loader to be used. Supported extensions include: " +
669 supportedFileExtensions, "String");
670 loadFromTileCommand.AddArgument("file width", "The width of the file in tiles", "Integer");
671 loadFromTileCommand.AddArgument("file height", "The height of the file in tiles", "Integer");
672 loadFromTileCommand.AddArgument("minimum X tile", "The X region coordinate of the first section on the file",
673 "Integer");
674 loadFromTileCommand.AddArgument("minimum Y tile", "The Y region coordinate of the first section on the file",
675 "Integer");
676
677 // Terrain adjustments
678 Command fillRegionCommand =
679 new Command("fill", InterfaceFillTerrain, "Fills the current heightmap with a specified value.");
680 fillRegionCommand.AddArgument("value", "The numeric value of the height you wish to set your region to.",
681 "Double");
682
683 Command elevateCommand =
684 new Command("elevate", InterfaceElevateTerrain, "Raises the current heightmap by the specified amount.");
685 elevateCommand.AddArgument("amount", "The amount of height to add to the terrain in meters.", "Double");
686
687 Command lowerCommand =
688 new Command("lower", InterfaceLowerTerrain, "Lowers the current heightmap by the specified amount.");
689 lowerCommand.AddArgument("amount", "The amount of height to remove from the terrain in meters.", "Double");
690
691 Command multiplyCommand =
692 new Command("multiply", InterfaceMultiplyTerrain, "Multiplies the heightmap by the value specified.");
693 multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double");
694
695 Command bakeRegionCommand =
696 new Command("bake", InterfaceBakeTerrain, "Saves the current terrain into the regions revert map.");
697 Command revertRegionCommand =
698 new Command("revert", InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap.");
699
700 // Debug
701 Command showDebugStatsCommand =
702 new Command("stats", InterfaceShowDebugStats,
703 "Shows some information about the regions heightmap for debugging purposes.");
704
705 Command experimentalBrushesCommand =
706 new Command("newbrushes", InterfaceEnableExperimentalBrushes,
707 "Enables experimental brushes which replace the standard terrain brushes. WARNING: This is a debug setting and may be removed at any time.");
708 experimentalBrushesCommand.AddArgument("Enabled?", "true / false - Enable new brushes", "Boolean");
709
710 //Plugins
711 Command pluginRunCommand =
712 new Command("effect", InterfaceRunPluginEffect, "Runs a specified plugin effect");
713 pluginRunCommand.AddArgument("name", "The plugin effect you wish to run, or 'list' to see all plugins", "String");
714
715 m_commander.RegisterCommand("load", loadFromFileCommand);
716 m_commander.RegisterCommand("load-tile", loadFromTileCommand);
717 m_commander.RegisterCommand("save", saveToFileCommand);
718 m_commander.RegisterCommand("fill", fillRegionCommand);
719 m_commander.RegisterCommand("elevate", elevateCommand);
720 m_commander.RegisterCommand("lower", lowerCommand);
721 m_commander.RegisterCommand("multiply", multiplyCommand);
722 m_commander.RegisterCommand("bake", bakeRegionCommand);
723 m_commander.RegisterCommand("revert", revertRegionCommand);
724 m_commander.RegisterCommand("newbrushes", experimentalBrushesCommand);
725 m_commander.RegisterCommand("stats", showDebugStatsCommand);
726 m_commander.RegisterCommand("effect", pluginRunCommand);
727
728 // Add this to our scene so scripts can call these functions
729 m_scene.RegisterModuleCommander("Terrain", m_commander);
730 }
731
732 #endregion
733 }
734} \ No newline at end of file