aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs58
1 files changed, 57 insertions, 1 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index 248549e..13e3d42 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -609,6 +609,10 @@ namespace OpenSim.Region.Terrain
609 LoadFromFileF32(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), 609 LoadFromFileF32(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
610 Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); 610 Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
611 break; 611 break;
612 case "raw":
613 LoadFromFileSLRAW(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
614 Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
615 break;
612 case "img": 616 case "img":
613 LoadFromFileIMG(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]), 617 LoadFromFileIMG(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
614 Convert.ToInt32(args[5]), Convert.ToInt32(args[6])); 618 Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
@@ -962,6 +966,58 @@ namespace OpenSim.Region.Terrain
962 } 966 }
963 967
964 /// <summary> 968 /// <summary>
969 /// Loads a section of a larger heightmap (RAW)
970 /// </summary>
971 /// <param name="filename">File to load</param>
972 /// <param name="dimensionX">Size of the file</param>
973 /// <param name="dimensionY">Size of the file</param>
974 /// <param name="lowerboundX">Where do the region coords start for this terrain?</param>
975 /// <param name="lowerboundY">Where do the region coords start for this terrain?</param>
976 public void LoadFromFileSLRAW(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY)
977 {
978 // TODO: Mutex fails to release readlock on folder! --> only one file can be loaded into sim
979 //fileIOLock.WaitOne();
980 //try
981 //{
982 int sectionToLoadX = ((offsetX - lowerboundX)*w);
983 int sectionToLoadY = ((offsetY - lowerboundY)*h);
984
985 double[,] tempMap = new double[dimensionX,dimensionY];
986
987 FileInfo file = new FileInfo(filename);
988 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
989 BinaryReader bs = new BinaryReader(s);
990
991 int x, y;
992 for (x = 0; x < dimensionX; x++)
993 {
994 for (y = 0; y < dimensionY; y++)
995 {
996 tempMap[x, y] = (double) bs.ReadByte()*((double) bs.ReadByte()/127.0);
997 bs.ReadBytes(11); // Advance the stream to next bytes.
998 }
999 }
1000
1001 for (y = 0; y < h; y++)
1002 {
1003 for (x = 0; x < w; x++)
1004 {
1005 heightmap.Set(x, y, tempMap[x + sectionToLoadX, y + sectionToLoadY]);
1006 }
1007 }
1008
1009 bs.Close();
1010 s.Close();
1011
1012 tainted++;
1013 //}
1014 //finally
1015 //{
1016 // fileIOLock.ReleaseMutex();
1017 //}
1018 }
1019
1020 /// <summary>
965 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array. 1021 /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array.
966 /// </summary> 1022 /// </summary>
967 /// <param name="filename">The desired output filename</param> 1023 /// <param name="filename">The desired output filename</param>
@@ -1397,4 +1453,4 @@ namespace OpenSim.Region.Terrain
1397 return bmp; 1453 return bmp;
1398 } 1454 }
1399 } 1455 }
1400} \ No newline at end of file 1456}