diff options
author | Adam Frisby | 2007-05-26 09:50:22 +0000 |
---|---|---|
committer | Adam Frisby | 2007-05-26 09:50:22 +0000 |
commit | bd7c1f6d07502ed3805f7f0d4de34b06785f08f2 (patch) | |
tree | 8f8878005d27c0f278972fa670c2f541d5755452 /OpenSim/OpenSim.Terrain.BasicTerrain | |
parent | * Semibug fix: Terrain should not save to database every time a packet is rec... (diff) | |
download | opensim-SC-bd7c1f6d07502ed3805f7f0d4de34b06785f08f2.zip opensim-SC-bd7c1f6d07502ed3805f7f0d4de34b06785f08f2.tar.gz opensim-SC-bd7c1f6d07502ed3805f7f0d4de34b06785f08f2.tar.bz2 opensim-SC-bd7c1f6d07502ed3805f7f0d4de34b06785f08f2.tar.xz |
* Added support for 13 Channel .RAW files. Untested but should work fine (fairly simple).
Diffstat (limited to 'OpenSim/OpenSim.Terrain.BasicTerrain')
-rw-r--r-- | OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index f808265..aa785b0 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -118,7 +118,7 @@ namespace OpenSim.Terrain | |||
118 | case "help": | 118 | case "help": |
119 | resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; | 119 | resultText += "terrain regenerate - rebuilds the sims terrain using a default algorithm\n"; |
120 | resultText += "terrain seed <seed> - sets the random seed value to <seed>\n"; | 120 | resultText += "terrain seed <seed> - sets the random seed value to <seed>\n"; |
121 | resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64' or 'IMG'\n"; | 121 | resultText += "terrain load <type> <filename> - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n"; |
122 | resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'\n"; | 122 | resultText += "terrain save <type> <filename> - saves a terrain to disk, type can be 'F32' or 'F64'\n"; |
123 | resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n"; | 123 | resultText += "terrain save grdmap <filename> <gradient map> - creates a PNG snapshot of the region using a named gradient map\n"; |
124 | resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n"; | 124 | resultText += "terrain rescale <min> <max> - rescales a terrain to be between <min> and <max> meters high\n"; |
@@ -170,6 +170,10 @@ namespace OpenSim.Terrain | |||
170 | loadFromFileF64(args[2]); | 170 | loadFromFileF64(args[2]); |
171 | break; | 171 | break; |
172 | 172 | ||
173 | case "raw": | ||
174 | loadFromFileSLRAW(args[2]); | ||
175 | break; | ||
176 | |||
173 | case "img": | 177 | case "img": |
174 | resultText = "Error - IMG mode is presently unsupported."; | 178 | resultText = "Error - IMG mode is presently unsupported."; |
175 | return false; | 179 | return false; |
@@ -276,6 +280,32 @@ namespace OpenSim.Terrain | |||
276 | } | 280 | } |
277 | 281 | ||
278 | /// <summary> | 282 | /// <summary> |
283 | /// Loads a file formatted in the SL .RAW Format used on the main grid | ||
284 | /// </summary> | ||
285 | /// <remarks>This file format stinks and is best avoided.</remarks> | ||
286 | /// <param name="filename">A path to the .RAW format</param> | ||
287 | public void loadFromFileSLRAW(string filename) | ||
288 | { | ||
289 | System.IO.FileInfo file = new System.IO.FileInfo(filename); | ||
290 | System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read); | ||
291 | System.IO.BinaryReader bs = new System.IO.BinaryReader(s); | ||
292 | int x, y; | ||
293 | for (x = 0; x < w; x++) | ||
294 | { | ||
295 | for (y = 0; y < h; y++) | ||
296 | { | ||
297 | heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0); | ||
298 | bs.ReadBytes(11); // Advance the stream to next bytes. | ||
299 | } | ||
300 | } | ||
301 | |||
302 | bs.Close(); | ||
303 | s.Close(); | ||
304 | |||
305 | tainted++; | ||
306 | } | ||
307 | |||
308 | /// <summary> | ||
279 | /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array. | 309 | /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array. |
280 | /// </summary> | 310 | /// </summary> |
281 | /// <param name="filename">The desired output filename</param> | 311 | /// <param name="filename">The desired output filename</param> |