diff options
-rw-r--r-- | OpenSim.RegionServer/OpenSimMain.cs | 78 | ||||
-rw-r--r-- | OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 57 |
2 files changed, 132 insertions, 3 deletions
diff --git a/OpenSim.RegionServer/OpenSimMain.cs b/OpenSim.RegionServer/OpenSimMain.cs index 48eff1b..b2ee3b6 100644 --- a/OpenSim.RegionServer/OpenSimMain.cs +++ b/OpenSim.RegionServer/OpenSimMain.cs | |||
@@ -505,20 +505,92 @@ namespace OpenSim | |||
505 | case "help": | 505 | case "help": |
506 | m_console.WriteLine("show users - show info about connected users"); | 506 | m_console.WriteLine("show users - show info about connected users"); |
507 | m_console.WriteLine("shutdown - disconnect all clients and shutdown"); | 507 | m_console.WriteLine("shutdown - disconnect all clients and shutdown"); |
508 | m_console.WriteLine("regenerate - regenerate the sim's terrain"); | ||
509 | break; | 508 | break; |
510 | 509 | ||
511 | case "show": | 510 | case "show": |
512 | Show(cmdparams[0]); | 511 | Show(cmdparams[0]); |
513 | break; | 512 | break; |
514 | 513 | ||
515 | case "regenerate": | 514 | case "terrain": |
516 | LocalWorld.RegenerateTerrain(); | 515 | RunTerrainCmd(cmdparams); |
517 | break; | 516 | break; |
518 | 517 | ||
519 | case "shutdown": | 518 | case "shutdown": |
520 | Shutdown(); | 519 | Shutdown(); |
521 | break; | 520 | break; |
521 | |||
522 | default: | ||
523 | m_console.WriteLine("Unknown command"); | ||
524 | break; | ||
525 | } | ||
526 | } | ||
527 | |||
528 | /// <summary> | ||
529 | /// Processes a terrain-specific command | ||
530 | /// </summary> | ||
531 | /// <remarks>TODO: Move this into BasicTerrain directly (no need to hard limit what each terrain engine can support)</remarks> | ||
532 | /// <param name="args"></param> | ||
533 | public void RunTerrainCmd(string[] args) | ||
534 | { | ||
535 | string command = args[0]; | ||
536 | switch (command) | ||
537 | { | ||
538 | case "help": | ||
539 | m_console.WriteLine("terrain regenerate - rebuilds the sims terrain using a default algorithm"); | ||
540 | m_console.WriteLine("terrain seed <seed> - sets the random seed value to <seed>"); | ||
541 | m_console.WriteLine("terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'"); | ||
542 | m_console.WriteLine("terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'"); | ||
543 | break; | ||
544 | |||
545 | case "seed": | ||
546 | LocalWorld.Terrain.setSeed(Convert.ToInt32(args[1])); | ||
547 | break; | ||
548 | |||
549 | case "regenerate": | ||
550 | LocalWorld.Terrain.hills(); | ||
551 | break; | ||
552 | |||
553 | case "load": | ||
554 | switch (args[1].ToLower()) | ||
555 | { | ||
556 | case "f32": | ||
557 | LocalWorld.Terrain.loadFromFileF32(args[2]); | ||
558 | break; | ||
559 | |||
560 | case "f64": | ||
561 | LocalWorld.Terrain.loadFromFileF64(args[2]); | ||
562 | break; | ||
563 | |||
564 | case "img": | ||
565 | m_console.WriteLine("Error - IMG mode is presently unsupported."); | ||
566 | break; | ||
567 | |||
568 | default: | ||
569 | m_console.WriteLine("Unknown image or data format"); | ||
570 | break; | ||
571 | } | ||
572 | break; | ||
573 | |||
574 | case "save": | ||
575 | switch (args[1].ToLower()) | ||
576 | { | ||
577 | case "f32": | ||
578 | LocalWorld.Terrain.writeToFileF32(args[2]); | ||
579 | break; | ||
580 | |||
581 | case "f64": | ||
582 | LocalWorld.Terrain.writeToFileF64(args[2]); | ||
583 | break; | ||
584 | |||
585 | default: | ||
586 | m_console.WriteLine("Unknown image or data format"); | ||
587 | break; | ||
588 | } | ||
589 | break; | ||
590 | |||
591 | default: | ||
592 | m_console.WriteLine("Unknown terrain command"); | ||
593 | break; | ||
522 | } | 594 | } |
523 | } | 595 | } |
524 | 596 | ||
diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index 65e267a..080671b 100644 --- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -103,6 +103,63 @@ namespace OpenSim.Terrain | |||
103 | } | 103 | } |
104 | 104 | ||
105 | /// <summary> | 105 | /// <summary> |
106 | /// Loads a file consisting of 256x256 floats and imports it as an array into the map. | ||
107 | /// </summary> | ||
108 | /// <remarks>TODO: Move this to libTerrain itself</remarks> | ||
109 | /// <param name="filename">The filename of the float array to import</param> | ||
110 | public void loadFromFileF32(string filename) | ||
111 | { | ||
112 | System.IO.FileInfo file = new System.IO.FileInfo(filename); | ||
113 | System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read); | ||
114 | System.IO.BinaryReader bs = new System.IO.BinaryReader(s); | ||
115 | int x, y; | ||
116 | for (x = 0; x < w; x++) | ||
117 | { | ||
118 | for (y = 0; y < h; y++) | ||
119 | { | ||
120 | heightmap.map[x, y] = (double)bs.ReadSingle(); | ||
121 | } | ||
122 | } | ||
123 | } | ||
124 | |||
125 | public void writeToFileF64(string filename) | ||
126 | { | ||
127 | System.IO.FileInfo file = new System.IO.FileInfo(filename); | ||
128 | System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write); | ||
129 | System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s); | ||
130 | |||
131 | int x, y; | ||
132 | for (x = 0; x < w; x++) | ||
133 | { | ||
134 | for (y = 0; y < h; y++) | ||
135 | { | ||
136 | bs.Write(heightmap.get(x,y)); | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | |||
141 | public void writeToFileF32(string filename) | ||
142 | { | ||
143 | System.IO.FileInfo file = new System.IO.FileInfo(filename); | ||
144 | System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write); | ||
145 | System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s); | ||
146 | |||
147 | int x, y; | ||
148 | for (x = 0; x < w; x++) | ||
149 | { | ||
150 | for (y = 0; y < h; y++) | ||
151 | { | ||
152 | bs.Write((float)heightmap.get(x, y)); | ||
153 | } | ||
154 | } | ||
155 | } | ||
156 | |||
157 | public void setSeed(int val) | ||
158 | { | ||
159 | heightmap.seed = val; | ||
160 | } | ||
161 | |||
162 | /// <summary> | ||
106 | /// Raises land in a sphere around the specified coordinates | 163 | /// Raises land in a sphere around the specified coordinates |
107 | /// </summary> | 164 | /// </summary> |
108 | /// <param name="rx">Center of the sphere on the X axis</param> | 165 | /// <param name="rx">Center of the sphere on the X axis</param> |