From 7dd98f30943f66e7f0c4c63db1190fad2f437185 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Tue, 24 Apr 2007 18:01:37 +0000 Subject: Moved console input-handling function "RunTerrainCmd" into BasicTerrain itself, this allows independent versions of BasicTerrain to have different functionality exposed directly. --- OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 80 +++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) (limited to 'OpenSim.Terrain.BasicTerrain/TerrainEngine.cs') diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index 38c4d0f..73b4378 100644 --- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs @@ -100,6 +100,86 @@ namespace OpenSim.Terrain } /// + /// Processes a terrain-specific command + /// + /// TODO: Move this into BasicTerrain directly (no need to hard limit what each terrain engine can support) + /// + public bool RunTerrainCmd(string[] args, ref string resultText) + { + string command = args[0]; + switch (command) + { + case "help": + resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; + resultText += "terrain seed - sets the random seed value to \n"; + resultText += "terrain load - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'\n"; + resultText += "terrain save - saves a terrain to disk, type can be 'F32' or 'F64'\n"; + resultText += "terrain rescale - rescales a terrain to be between and meters high\n"; + resultText += "terrain multiply - multiplies a terrain by \n"; + return false; + + case "seed": + setSeed(Convert.ToInt32(args[1])); + break; + + case "regenerate": + hills(); + break; + + case "rescale": + setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); + break; + + case "multiply": + heightmap *= Convert.ToDouble(args[1]); + break; + + case "load": + switch (args[1].ToLower()) + { + case "f32": + loadFromFileF32(args[2]); + break; + + case "f64": + loadFromFileF64(args[2]); + break; + + case "img": + resultText = "Error - IMG mode is presently unsupported."; + return false; + + default: + resultText = "Unknown image or data format"; + return false; + } + break; + + case "save": + switch (args[1].ToLower()) + { + case "f32": + writeToFileF32(args[2]); + break; + + case "f64": + writeToFileF64(args[2]); + break; + + default: + resultText = "Unknown image or data format"; + return false; + } + break; + + default: + resultText = "Unknown terrain command"; + return false; + } + return true; + } + + /// /// Renormalises the array between min and max /// /// Minimum value of the new array -- cgit v1.1