aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAdam Frisby2007-04-07 16:48:38 +0000
committerAdam Frisby2007-04-07 16:48:38 +0000
commitc18cf96824c94493263baf1cba23aa3253e6e0c9 (patch)
treed1b904e21e83172d8bbabc7af23166d1fd597c1d
parentAdded setHeights1D to allow importing from a 1D array (diff)
downloadopensim-SC-c18cf96824c94493263baf1cba23aa3253e6e0c9.zip
opensim-SC-c18cf96824c94493263baf1cba23aa3253e6e0c9.tar.gz
opensim-SC-c18cf96824c94493263baf1cba23aa3253e6e0c9.tar.bz2
opensim-SC-c18cf96824c94493263baf1cba23aa3253e6e0c9.tar.xz
Terrain can now import from a specially formatted file.
Diffstat (limited to '')
-rw-r--r--OpenSim.Terrain.BasicTerrain/TerrainEngine.cs27
1 files changed, 27 insertions, 0 deletions
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
20 20
21 } 21 }
22 22
23 /// <summary>
24 /// Converts the heightmap to a 65536 value 1D floating point array
25 /// </summary>
26 /// <returns>A float[65536] array containing the heightmap</returns>
23 public float[] getHeights1D() 27 public float[] getHeights1D()
24 { 28 {
25 float[] heights = new float[w*h]; 29 float[] heights = new float[w*h];
@@ -30,6 +34,10 @@ namespace OpenSim.Terrain
30 return heights; 34 return heights;
31 } 35 }
32 36
37 /// <summary>
38 /// Imports a 1D floating point array into the 2D heightmap array
39 /// </summary>
40 /// <param name="heights">The array to import (must have 65536 members)</param>
33 public void setHeights1D(float[] heights) 41 public void setHeights1D(float[] heights)
34 { 42 {
35 int i; 43 int i;
@@ -40,6 +48,25 @@ namespace OpenSim.Terrain
40 } 48 }
41 49
42 /// <summary> 50 /// <summary>
51 /// Loads a file consisting of 256x256 doubles and imports it as an array into the map.
52 /// </summary>
53 /// <param name="filename">The filename of the double array to import</param>
54 public void loadFromFileF64(string filename)
55 {
56 System.IO.FileInfo file = new System.IO.FileInfo(filename);
57 System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read);
58 System.IO.BinaryReader bs = new System.IO.BinaryReader(s);
59 int x, y;
60 for (x = 0; x < w; x++)
61 {
62 for (y = 0; y < h; y++)
63 {
64 map[x, y] = (float)bs.ReadDouble();
65 }
66 }
67 }
68
69 /// <summary>
43 /// 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. 70 /// 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.
44 /// </summary> 71 /// </summary>
45 public void swapWaterBuffer() 72 public void swapWaterBuffer()