From c18cf96824c94493263baf1cba23aa3253e6e0c9 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Sat, 7 Apr 2007 16:48:38 +0000
Subject: Terrain can now import from a specially formatted file.
---
OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
(limited to 'OpenSim.Terrain.BasicTerrain/TerrainEngine.cs')
diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
index cbc99bc..45da742 100644
--- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
@@ -20,6 +20,10 @@ namespace OpenSim.Terrain
}
+ ///
+ /// Converts the heightmap to a 65536 value 1D floating point array
+ ///
+ /// A float[65536] array containing the heightmap
public float[] getHeights1D()
{
float[] heights = new float[w*h];
@@ -30,6 +34,10 @@ namespace OpenSim.Terrain
return heights;
}
+ ///
+ /// Imports a 1D floating point array into the 2D heightmap array
+ ///
+ /// The array to import (must have 65536 members)
public void setHeights1D(float[] heights)
{
int i;
@@ -40,6 +48,25 @@ namespace OpenSim.Terrain
}
///
+ /// Loads a file consisting of 256x256 doubles and imports it as an array into the map.
+ ///
+ /// The filename of the double array to import
+ 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();
+ }
+ }
+ }
+
+ ///
/// 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.
///
public void swapWaterBuffer()
--
cgit v1.1