aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Terrain.BasicTerrain
diff options
context:
space:
mode:
authorAdam Frisby2007-04-20 05:39:01 +0000
committerAdam Frisby2007-04-20 05:39:01 +0000
commit258e62679aca6fa74a20a5275cb0f172402352e8 (patch)
treef0e6c267e11078b8e2e03ca9bf7ca67513208438 /OpenSim.Terrain.BasicTerrain
parent(no commit message) (diff)
downloadopensim-SC_OLD-258e62679aca6fa74a20a5275cb0f172402352e8.zip
opensim-SC_OLD-258e62679aca6fa74a20a5275cb0f172402352e8.tar.gz
opensim-SC_OLD-258e62679aca6fa74a20a5275cb0f172402352e8.tar.bz2
opensim-SC_OLD-258e62679aca6fa74a20a5275cb0f172402352e8.tar.xz
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
Diffstat (limited to 'OpenSim.Terrain.BasicTerrain')
-rw-r--r--OpenSim.Terrain.BasicTerrain/TerrainEngine.cs57
1 files changed, 57 insertions, 0 deletions
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
103 } 103 }
104 104
105 /// <summary> 105 /// <summary>
106 /// Loads a file consisting of 256x256 floats and imports it as an array into the map.
107 /// </summary>
108 /// <remarks>TODO: Move this to libTerrain itself</remarks>
109 /// <param name="filename">The filename of the float array to import</param>
110 public void loadFromFileF32(string filename)
111 {
112 System.IO.FileInfo file = new System.IO.FileInfo(filename);
113 System.IO.FileStream s = file.Open(System.IO.FileMode.Open, System.IO.FileAccess.Read);
114 System.IO.BinaryReader bs = new System.IO.BinaryReader(s);
115 int x, y;
116 for (x = 0; x < w; x++)
117 {
118 for (y = 0; y < h; y++)
119 {
120 heightmap.map[x, y] = (double)bs.ReadSingle();
121 }
122 }
123 }
124
125 public void writeToFileF64(string filename)
126 {
127 System.IO.FileInfo file = new System.IO.FileInfo(filename);
128 System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
129 System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s);
130
131 int x, y;
132 for (x = 0; x < w; x++)
133 {
134 for (y = 0; y < h; y++)
135 {
136 bs.Write(heightmap.get(x,y));
137 }
138 }
139 }
140
141 public void writeToFileF32(string filename)
142 {
143 System.IO.FileInfo file = new System.IO.FileInfo(filename);
144 System.IO.FileStream s = file.Open(System.IO.FileMode.CreateNew, System.IO.FileAccess.Write);
145 System.IO.BinaryWriter bs = new System.IO.BinaryWriter(s);
146
147 int x, y;
148 for (x = 0; x < w; x++)
149 {
150 for (y = 0; y < h; y++)
151 {
152 bs.Write((float)heightmap.get(x, y));
153 }
154 }
155 }
156
157 public void setSeed(int val)
158 {
159 heightmap.seed = val;
160 }
161
162 /// <summary>
106 /// Raises land in a sphere around the specified coordinates 163 /// Raises land in a sphere around the specified coordinates
107 /// </summary> 164 /// </summary>
108 /// <param name="rx">Center of the sphere on the X axis</param> 165 /// <param name="rx">Center of the sphere on the X axis</param>