From 61017d10d8ec045883e0a80bc12388390c16f95f Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Wed, 1 Aug 2007 21:46:48 +0000
Subject: * F32 Terrain load function written to support loading tiles from a
larger heightmap.
---
.../Region/Terrain.BasicTerrain/TerrainEngine.cs | 42 ++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index b54f4fe..bfb4941 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -578,6 +578,48 @@ namespace OpenSim.Region.Terrain
}
///
+ /// Loads a section of a larger heightmap (F32)
+ ///
+ /// File to load
+ /// Size of the file
+ /// Size of the file
+ /// Where do the region coords start for this terrain?
+ /// Where do the region coords start for this terrain?
+ public void LoadFromFileF32(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];
+
+ FileInfo file = new FileInfo(filename);
+ FileStream s = file.Open(FileMode.Open, FileAccess.Read);
+ BinaryReader bs = new BinaryReader(s);
+
+ int x, y;
+ for (x = 0; x < dimensionX; x++)
+ {
+ for (y = 0; y < dimensionY; y++)
+ {
+ tempMap[x,y] = (double)bs.ReadSingle();
+ }
+ }
+
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ heightmap.Set(x, y, tempMap[x + sectionToLoadX, y + sectionToLoadY]);
+ }
+ }
+
+ bs.Close();
+ s.Close();
+
+ 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