Terrain can now import from a specially formatted file.

0.1-prestable
Adam Frisby 2007-04-07 16:48:38 +00:00
parent 55aaf8060f
commit c18cf96824
1 changed files with 27 additions and 0 deletions

View File

@ -20,6 +20,10 @@ namespace OpenSim.Terrain
}
/// <summary>
/// Converts the heightmap to a 65536 value 1D floating point array
/// </summary>
/// <returns>A float[65536] array containing the heightmap</returns>
public float[] getHeights1D()
{
float[] heights = new float[w*h];
@ -30,6 +34,10 @@ namespace OpenSim.Terrain
return heights;
}
/// <summary>
/// Imports a 1D floating point array into the 2D heightmap array
/// </summary>
/// <param name="heights">The array to import (must have 65536 members)</param>
public void setHeights1D(float[] heights)
{
int i;
@ -39,6 +47,25 @@ namespace OpenSim.Terrain
}
}
/// <summary>
/// Loads a file consisting of 256x256 doubles and imports it as an array into the map.
/// </summary>
/// <param name="filename">The filename of the double array to import</param>
public void loadFromFileF64(string filename)
{
System.IO.FileInfo file = new System.IO.FileInfo(filename);
System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read);
System.IO.BinaryReader bs = new System.IO.BinaryReader(s);
int x, y;
for (x = 0; x < w; x++)
{
for (y = 0; y < h; y++)
{
map[x, y] = (float)bs.ReadDouble();
}
}
}
/// <summary>
/// Swaps the references between the height and water buffers to allow you to edit the water heightmap. Remember to swap back when you are done.
/// </summary>