* F32 Terrain load function written to support loading tiles from a larger heightmap.

afrisby
Adam Frisby 2007-08-01 21:46:48 +00:00
parent 32565509e2
commit 61017d10d8
1 changed files with 42 additions and 0 deletions

View File

@ -577,6 +577,48 @@ namespace OpenSim.Region.Terrain
tainted++;
}
/// <summary>
/// Loads a section of a larger heightmap (F32)
/// </summary>
/// <param name="filename">File to load</param>
/// <param name="dimensionX">Size of the file</param>
/// <param name="dimensionY">Size of the file</param>
/// <param name="lowerboundX">Where do the region coords start for this terrain?</param>
/// <param name="lowerboundY">Where do the region coords start for this terrain?</param>
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++;
}
/// <summary>
/// Loads a file formatted in the SL .RAW Format used on the main grid
/// </summary>