aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs281
1 files changed, 0 insertions, 281 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
deleted file mode 100644
index 82b0cfd..0000000
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
+++ /dev/null
@@ -1,281 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29
30namespace libTerrain
31{
32 partial class Channel
33 {
34 /// <summary>
35 /// Generates a series of spheres which are then either max()'d or added together. Inspired by suggestion from jh.
36 /// </summary>
37 /// <remarks>3-Clause BSD Licensed</remarks>
38 /// <param name="number">The number of hills to generate</param>
39 /// <param name="scale_min">The minimum size of each hill</param>
40 /// <param name="scale_range">The maximum size of each hill</param>
41 /// <param name="island">Whether to bias hills towards the center of the map</param>
42 /// <param name="additive">Whether to add hills together or to pick the largest value</param>
43 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param>
44 public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive,
45 bool noisy)
46 {
47 SetDiff();
48
49 Random random = new Random(seed);
50
51 int x, y;
52 int i;
53
54 for (i = 0; i < number; i++)
55 {
56 double rx = Math.Min(255.0, random.NextDouble()*w);
57 double ry = Math.Min(255.0, random.NextDouble()*h);
58 double rand = random.NextDouble();
59
60 if (island)
61 {
62 // Move everything towards the center
63 rx -= w/2;
64 rx /= 2;
65 rx += w/2;
66
67 ry -= h/2;
68 ry /= 2;
69 ry += h/2;
70 }
71
72 for (x = 0; x < w; x++)
73 {
74 for (y = 0; y < h; y++)
75 {
76 if (noisy)
77 rand = random.NextDouble();
78
79 double z = (scale_min + (scale_range*rand));
80 z *= z;
81 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
82
83 if (z < 0)
84 z = 0;
85
86 if (additive)
87 {
88 map[x, y] += z;
89 }
90 else
91 {
92 map[x, y] = Math.Max(map[x, y], z);
93 }
94 }
95 }
96 }
97
98 Normalise();
99 }
100
101 /// <summary>
102 /// Generates a series of cones which are then either max()'d or added together. Inspired by suggestion from jh.
103 /// </summary>
104 /// <remarks>3-Clause BSD Licensed</remarks>
105 /// <param name="number">The number of hills to generate</param>
106 /// <param name="scale_min">The minimum size of each hill</param>
107 /// <param name="scale_range">The maximum size of each hill</param>
108 /// <param name="island">Whether to bias hills towards the center of the map</param>
109 /// <param name="additive">Whether to add hills together or to pick the largest value</param>
110 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param>
111 public void HillsCones(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
112 {
113 SetDiff();
114
115 Random random = new Random(seed);
116
117 int x, y;
118 int i;
119
120 for (i = 0; i < number; i++)
121 {
122 double rx = Math.Min(255.0, random.NextDouble()*w);
123 double ry = Math.Min(255.0, random.NextDouble()*h);
124 double rand = random.NextDouble();
125
126 if (island)
127 {
128 // Move everything towards the center
129 rx -= w/2;
130 rx /= 2;
131 rx += w/2;
132
133 ry -= h/2;
134 ry /= 2;
135 ry += h/2;
136 }
137
138 for (x = 0; x < w; x++)
139 {
140 for (y = 0; y < h; y++)
141 {
142 if (noisy)
143 rand = random.NextDouble();
144
145 double z = (scale_min + (scale_range*rand));
146 z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry)));
147
148 if (z < 0)
149 z = 0;
150
151 if (additive)
152 {
153 map[x, y] += z;
154 }
155 else
156 {
157 map[x, y] = Math.Max(map[x, y], z);
158 }
159 }
160 }
161 }
162
163 Normalise();
164 }
165
166 public void HillsBlocks(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
167 {
168 SetDiff();
169
170 Random random = new Random(seed);
171
172 int x, y;
173 int i;
174
175 for (i = 0; i < number; i++)
176 {
177 double rx = Math.Min(255.0, random.NextDouble()*w);
178 double ry = Math.Min(255.0, random.NextDouble()*h);
179 double rand = random.NextDouble();
180
181 if (island)
182 {
183 // Move everything towards the center
184 rx -= w/2;
185 rx /= 2;
186 rx += w/2;
187
188 ry -= h/2;
189 ry /= 2;
190 ry += h/2;
191 }
192
193 for (x = 0; x < w; x++)
194 {
195 for (y = 0; y < h; y++)
196 {
197 if (noisy)
198 rand = random.NextDouble();
199
200 double z = (scale_min + (scale_range*rand));
201 z -= Math.Abs(x - rx) + Math.Abs(y - ry);
202 //z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
203
204 if (z < 0)
205 z = 0;
206
207 if (additive)
208 {
209 map[x, y] += z;
210 }
211 else
212 {
213 map[x, y] = Math.Max(map[x, y], z);
214 }
215 }
216 }
217 }
218
219 Normalise();
220 }
221
222 public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive,
223 bool noisy)
224 {
225 SetDiff();
226
227 Random random = new Random(seed);
228
229 int x, y;
230 int i;
231
232 for (i = 0; i < number; i++)
233 {
234 double rx = Math.Min(255.0, random.NextDouble()*w);
235 double ry = Math.Min(255.0, random.NextDouble()*h);
236 double rand = random.NextDouble();
237
238 if (island)
239 {
240 // Move everything towards the center
241 rx -= w/2;
242 rx /= 2;
243 rx += w/2;
244
245 ry -= h/2;
246 ry /= 2;
247 ry += h/2;
248 }
249
250 for (x = 0; x < w; x++)
251 {
252 for (y = 0; y < h; y++)
253 {
254 if (noisy)
255 rand = random.NextDouble();
256
257 double z = (scale_min + (scale_range*rand));
258 z *= z*z*z;
259 double dx = Math.Abs(x - rx);
260 double dy = Math.Abs(y - ry);
261 z -= (dx*dx*dx*dx) + (dy*dy*dy*dy);
262
263 if (z < 0)
264 z = 0;
265
266 if (additive)
267 {
268 map[x, y] += z;
269 }
270 else
271 {
272 map[x, y] = Math.Max(map[x, y], z);
273 }
274 }
275 }
276 }
277
278 Normalise();
279 }
280 }
281}