From 61017d10d8ec045883e0a80bc12388390c16f95f Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 1 Aug 2007 21:46:48 +0000 Subject: [PATCH] * F32 Terrain load function written to support loading tiles from a larger heightmap. --- .../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 b54f4fe263..bfb49411e9 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs @@ -577,6 +577,48 @@ namespace OpenSim.Region.Terrain tainted++; } + /// + /// 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 ///