From 258e62679aca6fa74a20a5275cb0f172402352e8 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Fri, 20 Apr 2007 05:39:01 +0000
Subject: Console: * Reorganised and added default handlers to main functions *
Removed "regenerate" command, use "terrain regenerate" instead. * Added new
"terrain seed" command to set the random seed * Added new "terrain load"
command to load a terrain from disk * Added new "terrain save" command to
save a terrain to disk Terrain: * Added new export and import functions for
some common formats * Added new setSeed function to allow customising the
random seed
---
OpenSim.Terrain.BasicTerrain/TerrainEngine.cs | 57 +++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
(limited to 'OpenSim.Terrain.BasicTerrain')
diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
index 65e267a..080671b 100644
--- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
@@ -103,6 +103,63 @@ namespace OpenSim.Terrain
}
///
+ /// Loads a file consisting of 256x256 floats and imports it as an array into the map.
+ ///
+ /// TODO: Move this to libTerrain itself
+ /// The filename of the float array to import
+ public void loadFromFileF32(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++)
+ {
+ heightmap.map[x, y] = (double)bs.ReadSingle();
+ }
+ }
+ }
+
+ public void writeToFileF64(string filename)
+ {
+ System.IO.FileInfo file = new System.IO.FileInfo(filename);
+ System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
+ System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s);
+
+ int x, y;
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ bs.Write(heightmap.get(x,y));
+ }
+ }
+ }
+
+ public void writeToFileF32(string filename)
+ {
+ System.IO.FileInfo file = new System.IO.FileInfo(filename);
+ System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
+ System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s);
+
+ int x, y;
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ bs.Write((float)heightmap.get(x, y));
+ }
+ }
+ }
+
+ public void setSeed(int val)
+ {
+ heightmap.seed = val;
+ }
+
+ ///
/// Raises land in a sphere around the specified coordinates
///
/// Center of the sphere on the X axis
--
cgit v1.1