From 4a9e40ea472f2e3ae45945392093ef54a8e026bd Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Thu, 16 Aug 2007 23:29:28 +0000
Subject: * Added support for the IMG-format loader to terrain's load-tile
function.
---
.../Region/Terrain.BasicTerrain/TerrainEngine.cs | 41 ++++++++++++++++++++++
1 file changed, 41 insertions(+)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index 4b9c5d6..4976e5d 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -400,6 +400,10 @@ namespace OpenSim.Region.Terrain
LoadFromFileF32(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
break;
+ case "img":
+ LoadFromFileIMG(args[2], Convert.ToInt32(args[3]), Convert.ToInt32(args[4]),
+ Convert.ToInt32(args[5]), Convert.ToInt32(args[6]));
+ break;
default:
resultText = "Unknown or unsupported image or data format";
return false;
@@ -658,6 +662,43 @@ namespace OpenSim.Region.Terrain
}
///
+ /// Loads a larger tiled image across a terrain
+ ///
+ /// Filename to load from (any generic image format should work)
+ /// The dimensions of the image
+ /// The dimensions of the image
+ /// Where sim coords begin for this patch
+ /// Where sim coords begin for this patch
+ public void LoadFromFileIMG(string filename, int dimensionX, int dimensionY, int lowerboundX, int lowerboundY)
+ {
+ int sectionToLoadX = ((this.offsetX - lowerboundX) * this.w);
+ int sectionToLoadY = ((this.offsetY - lowerboundY) * this.h);
+
+ double[,] tempMap = new double[dimensionX, dimensionY];
+
+ System.Drawing.Bitmap lgrBmp = new Bitmap(filename);
+
+ int x, y;
+ for (x = 0; x < dimensionX; x++)
+ {
+ for (y = 0; y < dimensionY; y++)
+ {
+ tempMap[x, y] = (float)lgrBmp.GetPixel(x, y).GetBrightness();
+ }
+ }
+
+ for (y = 0; y < h; y++)
+ {
+ for (x = 0; x < w; x++)
+ {
+ heightmap.Set(x, y, tempMap[x + sectionToLoadX, y + sectionToLoadY]);
+ }
+ }
+
+ tainted++;
+ }
+
+ ///
/// Loads a file formatted in the SL .RAW Format used on the main grid
///
/// This file format stinks and is best avoided.
--
cgit v1.1