diff options
Diffstat (limited to 'OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs')
-rw-r--r-- | OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 112 |
1 files changed, 99 insertions, 13 deletions
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index fc4ca24..c78af05 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -34,6 +34,17 @@ using OpenJPEGNet; | |||
34 | 34 | ||
35 | namespace OpenSim.Terrain | 35 | namespace OpenSim.Terrain |
36 | { | 36 | { |
37 | public class TerrainCommand | ||
38 | { | ||
39 | public virtual bool run(string[] cmdargs, ref string output) | ||
40 | { | ||
41 | return false; | ||
42 | } | ||
43 | |||
44 | public string args; | ||
45 | public string help; | ||
46 | } | ||
47 | |||
37 | public class TerrainEngine | 48 | public class TerrainEngine |
38 | { | 49 | { |
39 | /// <summary> | 50 | /// <summary> |
@@ -42,6 +53,16 @@ namespace OpenSim.Terrain | |||
42 | public Channel heightmap; | 53 | public Channel heightmap; |
43 | 54 | ||
44 | /// <summary> | 55 | /// <summary> |
56 | /// A copy of heightmap at the last save point (for reverting) | ||
57 | /// </summary> | ||
58 | public Channel revertmap; | ||
59 | |||
60 | /// <summary> | ||
61 | /// Water heightmap (needs clientside mods to work) | ||
62 | /// </summary> | ||
63 | public Channel watermap; | ||
64 | |||
65 | /// <summary> | ||
45 | /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine. | 66 | /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine. |
46 | /// Counts the number of modifications since the last save. (0 = Untainted) | 67 | /// Counts the number of modifications since the last save. (0 = Untainted) |
47 | /// </summary> | 68 | /// </summary> |
@@ -145,6 +166,7 @@ namespace OpenSim.Terrain | |||
145 | { | 166 | { |
146 | case "help": | 167 | case "help": |
147 | resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; | 168 | resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; |
169 | resultText += "terrain voronoi <points> <blocksize> - generates a worley fractal with X points per block"; | ||
148 | resultText += "terrain seed <seed> - sets the random seed value to <seed>\n"; | 170 | resultText += "terrain seed <seed> - sets the random seed value to <seed>\n"; |
149 | resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n"; | 171 | resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n"; |
150 | resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'\n"; | 172 | resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'\n"; |
@@ -160,21 +182,18 @@ namespace OpenSim.Terrain | |||
160 | break; | 182 | break; |
161 | 183 | ||
162 | case "erode": | 184 | case "erode": |
163 | switch (args[1].ToLower()) | 185 | return consoleErosion(args, ref resultText); |
164 | { | 186 | |
165 | case "aerobic": | 187 | case "voronoi": |
166 | // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest | 188 | double[] c = new double[2]; |
167 | heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7])); | 189 | c[0] = -1; |
168 | break; | 190 | c[1] = 1; |
169 | case "thermal": | 191 | heightmap.voronoiDiagram(Convert.ToInt32(args[1]), Convert.ToInt32(args[2]), c); |
170 | heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4])); | ||
171 | break; | ||
172 | default: | ||
173 | resultText = "Unknown erosion type"; | ||
174 | return false; | ||
175 | } | ||
176 | break; | 192 | break; |
177 | 193 | ||
194 | case "hills": | ||
195 | return consoleHills(args, ref resultText); | ||
196 | |||
178 | case "regenerate": | 197 | case "regenerate": |
179 | hills(); | 198 | hills(); |
180 | break; | 199 | break; |
@@ -246,6 +265,73 @@ namespace OpenSim.Terrain | |||
246 | } | 265 | } |
247 | } | 266 | } |
248 | 267 | ||
268 | private bool consoleErosion(string[] args, ref string resultText) | ||
269 | { | ||
270 | switch (args[1].ToLower()) | ||
271 | { | ||
272 | case "aerobic": | ||
273 | // WindSpeed, PickupMinimum,DropMinimum,Carry,Rounds,Lowest | ||
274 | heightmap.AerobicErosion(Convert.ToDouble(args[2]), Convert.ToDouble(args[3]), Convert.ToDouble(args[4]), Convert.ToDouble(args[5]), Convert.ToInt32(args[6]), Convert.ToBoolean(args[7])); | ||
275 | break; | ||
276 | case "thermal": | ||
277 | heightmap.thermalWeathering(Convert.ToDouble(args[2]), Convert.ToInt32(args[3]), Convert.ToDouble(args[4])); | ||
278 | break; | ||
279 | default: | ||
280 | resultText = "Unknown erosion type"; | ||
281 | return false; | ||
282 | } | ||
283 | return true; | ||
284 | } | ||
285 | |||
286 | private bool consoleHills(string[] args, ref string resultText) | ||
287 | { | ||
288 | int count; | ||
289 | double sizeMin; | ||
290 | double sizeRange; | ||
291 | bool island; | ||
292 | bool additive; | ||
293 | bool noisy; | ||
294 | |||
295 | if (args.GetLength(0) > 2) | ||
296 | { | ||
297 | count = Convert.ToInt32(args[2]); | ||
298 | sizeMin = Convert.ToDouble(args[3]); | ||
299 | sizeRange = Convert.ToDouble(args[4]); | ||
300 | island = Convert.ToBoolean(args[5]); | ||
301 | additive = Convert.ToBoolean(args[6]); | ||
302 | noisy = Convert.ToBoolean(args[7]); | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | count = 200; | ||
307 | sizeMin = 20; | ||
308 | sizeRange = 40; | ||
309 | island = true; | ||
310 | additive = true; | ||
311 | noisy = false; | ||
312 | } | ||
313 | |||
314 | switch (args[1].ToLower()) | ||
315 | { | ||
316 | case "blocks": | ||
317 | heightmap.hillsBlocks(count, sizeMin, sizeRange, island, additive, noisy); | ||
318 | break; | ||
319 | case "cones": | ||
320 | heightmap.hillsCones(count, sizeMin, sizeRange, island, additive, noisy); | ||
321 | break; | ||
322 | case "spheres": | ||
323 | heightmap.hillsSpheres(count, sizeMin, sizeRange, island, additive, noisy); | ||
324 | break; | ||
325 | case "squared": | ||
326 | heightmap.hillsSquared(count, sizeMin, sizeRange, island, additive, noisy); | ||
327 | break; | ||
328 | default: | ||
329 | resultText = "Unknown hills type"; | ||
330 | return false; | ||
331 | } | ||
332 | return true; | ||
333 | } | ||
334 | |||
249 | /// <summary> | 335 | /// <summary> |
250 | /// Renormalises the array between min and max | 336 | /// Renormalises the array between min and max |
251 | /// </summary> | 337 | /// </summary> |