diff --git a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs index f80826535e..aa785b03c2 100644 --- a/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs @@ -118,7 +118,7 @@ namespace OpenSim.Terrain 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 load - loads a terrain from disk, type can be 'F32', 'F64', 'RAW' or 'IMG'\n"; resultText += "terrain save - saves a terrain to disk, type can be 'F32' or 'F64'\n"; resultText += "terrain save grdmap - creates a PNG snapshot of the region using a named gradient map\n"; resultText += "terrain rescale - rescales a terrain to be between and meters high\n"; @@ -170,6 +170,10 @@ namespace OpenSim.Terrain loadFromFileF64(args[2]); break; + case "raw": + loadFromFileSLRAW(args[2]); + break; + case "img": resultText = "Error - IMG mode is presently unsupported."; return false; @@ -275,6 +279,32 @@ namespace OpenSim.Terrain tainted++; } + /// + /// Loads a file formatted in the SL .RAW Format used on the main grid + /// + /// This file format stinks and is best avoided. + /// A path to the .RAW format + public void loadFromFileSLRAW(string filename) + { + System.IO.FileInfo file = new System.IO.FileInfo(filename); + System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read); + System.IO.BinaryReader bs = new System.IO.BinaryReader(s); + int x, y; + for (x = 0; x < w; x++) + { + for (y = 0; y < h; y++) + { + heightmap.map[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0); + bs.ReadBytes(11); // Advance the stream to next bytes. + } + } + + bs.Close(); + s.Close(); + + tainted++; + } + /// /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array. ///