diff options
author | Adam Frisby | 2008-04-23 10:55:04 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-23 10:55:04 +0000 |
commit | 7c897043bab19bf748ac3078a05a74969c409fa7 (patch) | |
tree | f3f89972edbdebd9678025e754734f6aeb8b2952 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators | |
parent | * Get rid of missing texture notification drop messages for now - obscuring t... (diff) | |
download | opensim-SC_OLD-7c897043bab19bf748ac3078a05a74969c409fa7.zip opensim-SC_OLD-7c897043bab19bf748ac3078a05a74969c409fa7.tar.gz opensim-SC_OLD-7c897043bab19bf748ac3078a05a74969c409fa7.tar.bz2 opensim-SC_OLD-7c897043bab19bf748ac3078a05a74969c409fa7.tar.xz |
* Removing old libTerrainBSD and associated Plugin & Project.
* Updated prebuild.xml accordingly.
Diffstat (limited to '')
10 files changed, 0 insertions, 1058 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Cellular.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Cellular.cs deleted file mode 100644 index 06e7e3c..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Cellular.cs +++ /dev/null | |||
@@ -1,28 +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 | |||
28 | /* TODO: Needs BSD rewrite */ | ||
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs deleted file mode 100644 index 3e1c34c..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs +++ /dev/null | |||
@@ -1,142 +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 | |||
28 | using System; | ||
29 | |||
30 | namespace libTerrain | ||
31 | { | ||
32 | partial class Channel | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Produces a set of coordinates defined by an edge point. Eg - 0 = 0,0. 256 = 0,256. 512 = 256,256 | ||
36 | /// Assumes a 256^2 heightmap. This needs fixing for input values of w,h | ||
37 | /// </summary> | ||
38 | /// <param name="val"></param> | ||
39 | /// <param name="w"></param> | ||
40 | /// <param name="h"></param> | ||
41 | /// <returns></returns> | ||
42 | private int[] RadialEdge256(int val) | ||
43 | { | ||
44 | // Four cases: | ||
45 | // 1. 000..255 return 0,val | ||
46 | // 2. 256..511 return val - 256,255 | ||
47 | // 3. 512..767 return 255, val - 511 | ||
48 | // 4. 768..1023 return val - 768,0 | ||
49 | |||
50 | int[] ret = new int[2]; | ||
51 | |||
52 | if (val < 256) | ||
53 | { | ||
54 | ret[0] = 0; | ||
55 | ret[1] = val; | ||
56 | return ret; | ||
57 | } | ||
58 | if (val < 512) | ||
59 | { | ||
60 | ret[0] = (val%256); | ||
61 | ret[1] = 255; | ||
62 | return ret; | ||
63 | } | ||
64 | if (val < 768) | ||
65 | { | ||
66 | ret[0] = 255; | ||
67 | ret[1] = 255 - (val%256); | ||
68 | return ret; | ||
69 | } | ||
70 | if (val < 1024) | ||
71 | { | ||
72 | ret[0] = 255 - (val%256); | ||
73 | ret[1] = 255; | ||
74 | return ret; | ||
75 | } | ||
76 | |||
77 | throw new Exception("Out of bounds parameter (val)"); | ||
78 | } | ||
79 | |||
80 | public void Fracture(int number, double scalemin, double scalemax) | ||
81 | { | ||
82 | SetDiff(); | ||
83 | |||
84 | Random rand = new Random(seed); | ||
85 | |||
86 | for (int i = 0; i < number; i++) | ||
87 | { | ||
88 | int[] a, b; | ||
89 | |||
90 | a = RadialEdge256(rand.Next(1023)); // TODO: Broken | ||
91 | b = RadialEdge256(rand.Next(1023)); // TODO: Broken | ||
92 | double z = rand.NextDouble(); | ||
93 | double u = rand.NextDouble(); | ||
94 | double v = rand.NextDouble(); | ||
95 | |||
96 | for (int x = 0; x < w; x++) | ||
97 | { | ||
98 | for (int y = 0; y < h; y++) | ||
99 | { | ||
100 | double miny = Tools.LinearInterpolate(a[1], b[1], (double) x/(double) w); | ||
101 | |||
102 | if (v >= 0.5) | ||
103 | { | ||
104 | if (u >= 0.5) | ||
105 | { | ||
106 | if (y > miny) | ||
107 | { | ||
108 | map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z); | ||
109 | } | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | if (y < miny) | ||
114 | { | ||
115 | map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z); | ||
116 | } | ||
117 | } | ||
118 | } | ||
119 | else | ||
120 | { | ||
121 | if (u >= 0.5) | ||
122 | { | ||
123 | if (x > miny) | ||
124 | { | ||
125 | map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z); | ||
126 | } | ||
127 | } | ||
128 | else | ||
129 | { | ||
130 | if (x < miny) | ||
131 | { | ||
132 | map[x, y] += Tools.LinearInterpolate(scalemin, scalemax, z); | ||
133 | } | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | } | ||
138 | } | ||
139 | Normalise(); | ||
140 | } | ||
141 | } | ||
142 | } | ||
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs deleted file mode 100644 index afe0877..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs +++ /dev/null | |||
@@ -1,60 +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 | |||
28 | namespace libTerrain | ||
29 | { | ||
30 | partial class Channel | ||
31 | { | ||
32 | public void GradientCube() | ||
33 | { | ||
34 | SetDiff(); | ||
35 | |||
36 | int x, y; | ||
37 | for (x = 0; x < w; x++) | ||
38 | { | ||
39 | for (y = 0; y < h; y++) | ||
40 | { | ||
41 | map[x, y] = x*y; | ||
42 | } | ||
43 | } | ||
44 | Normalise(); | ||
45 | } | ||
46 | |||
47 | public void GradientStripe() | ||
48 | { | ||
49 | int x, y; | ||
50 | for (x = 0; x < w; x++) | ||
51 | { | ||
52 | for (y = 0; y < h; y++) | ||
53 | { | ||
54 | map[x, y] = x; | ||
55 | } | ||
56 | } | ||
57 | Normalise(); | ||
58 | } | ||
59 | } | ||
60 | } | ||
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 | |||
28 | using System; | ||
29 | |||
30 | namespace 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 | } | ||
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Midpoint.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Midpoint.cs deleted file mode 100644 index 06e7e3c..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Midpoint.cs +++ /dev/null | |||
@@ -1,28 +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 | |||
28 | /* TODO: Needs BSD rewrite */ | ||
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Mountain.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Mountain.cs deleted file mode 100644 index 06e7e3c..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Mountain.cs +++ /dev/null | |||
@@ -1,28 +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 | |||
28 | /* TODO: Needs BSD rewrite */ | ||
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs deleted file mode 100644 index 10e8160..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs +++ /dev/null | |||
@@ -1,53 +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 | |||
28 | using System; | ||
29 | |||
30 | namespace libTerrain | ||
31 | { | ||
32 | partial class Channel | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Fills a channel with 0..1 noise | ||
36 | /// </summary> | ||
37 | /// <remarks>3-Clause BSD Licensed</remarks> | ||
38 | public void Noise() | ||
39 | { | ||
40 | SetDiff(); | ||
41 | |||
42 | Random rand = new Random(seed); | ||
43 | int x, y; | ||
44 | for (x = 0; x < w; x++) | ||
45 | { | ||
46 | for (y = 0; y < h; y++) | ||
47 | { | ||
48 | map[x, y] = rand.NextDouble(); | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | } | ||
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs deleted file mode 100644 index a516d8d..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs +++ /dev/null | |||
@@ -1,156 +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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | namespace libTerrain | ||
32 | { | ||
33 | partial class Channel | ||
34 | { | ||
35 | private double[] CoordinatesToPolar(int x, int y) | ||
36 | { | ||
37 | double theta = Math.Atan2(x - (w/2), y - (h/2)); | ||
38 | double rx = (double) x - ((double) w/2); | ||
39 | double ry = (double) y - ((double) h/2); | ||
40 | double r = Math.Sqrt((rx*rx) + (ry*ry)); | ||
41 | |||
42 | double[] coords = new double[2]; | ||
43 | coords[0] = r; | ||
44 | coords[1] = theta; | ||
45 | return coords; | ||
46 | } | ||
47 | |||
48 | public int[] PolarToCoordinates(double r, double theta) | ||
49 | { | ||
50 | double nx; | ||
51 | double ny; | ||
52 | |||
53 | nx = (double) r*Math.Cos(theta); | ||
54 | ny = (double) r*Math.Sin(theta); | ||
55 | |||
56 | nx += w/2; | ||
57 | ny += h/2; | ||
58 | |||
59 | if (nx >= w) | ||
60 | nx = w - 1; | ||
61 | |||
62 | if (ny >= h) | ||
63 | ny = h - 1; | ||
64 | |||
65 | if (nx < 0) | ||
66 | nx = 0; | ||
67 | |||
68 | if (ny < 0) | ||
69 | ny = 0; | ||
70 | |||
71 | int[] coords = new int[2]; | ||
72 | coords[0] = (int) nx; | ||
73 | coords[1] = (int) ny; | ||
74 | return coords; | ||
75 | } | ||
76 | |||
77 | public void Polar() | ||
78 | { | ||
79 | SetDiff(); | ||
80 | |||
81 | Channel n = Copy(); | ||
82 | |||
83 | int x, y; | ||
84 | for (x = 0; x < w; x++) | ||
85 | { | ||
86 | for (y = 0; y < h; y++) | ||
87 | { | ||
88 | double[] coords = CoordinatesToPolar(x, y); | ||
89 | |||
90 | coords[0] += w/2.0; | ||
91 | coords[1] += h/2.0; | ||
92 | |||
93 | map[x, y] = n.map[(int) coords[0]%n.w, (int) coords[1]%n.h]; | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public void SpiralPlanter(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle) | ||
99 | { | ||
100 | SetDiff(); | ||
101 | |||
102 | int i; | ||
103 | double r = offsetRadius; | ||
104 | double theta = offsetAngle; | ||
105 | for (i = 0; i < steps; i++) | ||
106 | { | ||
107 | r += incRadius; | ||
108 | theta += incAngle; | ||
109 | |||
110 | int[] coords = PolarToCoordinates(r, theta); | ||
111 | Raise(coords[0], coords[1], 20, 1); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, | ||
116 | double[] c) | ||
117 | { | ||
118 | SetDiff(); | ||
119 | |||
120 | List<Point2D> points = new List<Point2D>(); | ||
121 | |||
122 | int i; | ||
123 | double r = offsetRadius; | ||
124 | double theta = offsetAngle; | ||
125 | for (i = 0; i < steps; i++) | ||
126 | { | ||
127 | r += incRadius; | ||
128 | theta += incAngle; | ||
129 | |||
130 | int[] coords = PolarToCoordinates(r, theta); | ||
131 | points.Add(new Point2D(coords[0], coords[1])); | ||
132 | } | ||
133 | |||
134 | VoronoiDiagram(points, c); | ||
135 | } | ||
136 | |||
137 | public void Spiral(double wid, double hig, double offset) | ||
138 | { | ||
139 | SetDiff(); | ||
140 | |||
141 | int x, y, z; | ||
142 | z = 0; | ||
143 | for (x = 0; x < w; x++) | ||
144 | { | ||
145 | for (y = 0; y < h; y++) | ||
146 | { | ||
147 | z++; | ||
148 | double dx = Math.Abs((w/2) - x); | ||
149 | double dy = Math.Abs((h/2) - y); | ||
150 | map[x, y] += Math.Sin(dx/wid) + Math.Cos(dy/hig); | ||
151 | } | ||
152 | } | ||
153 | Normalise(); | ||
154 | } | ||
155 | } | ||
156 | } | ||
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs deleted file mode 100644 index a4966a4..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs +++ /dev/null | |||
@@ -1,211 +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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | |||
31 | namespace libTerrain | ||
32 | { | ||
33 | partial class Channel | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Generates a Voronoi diagram (sort of a stained glass effect) which will fill the entire channel | ||
37 | /// </summary> | ||
38 | /// <remarks>3-Clause BSD Licensed</remarks> | ||
39 | /// <param name="pointsPerBlock">The number of generator points in each block</param> | ||
40 | /// <param name="blockSize">A multiple of the channel width and height which will have voronoi points generated in it. | ||
41 | /// <para>This is to ensure a more even distribution of the points than pure random allocation.</para></param> | ||
42 | /// <param name="c">The Voronoi diagram type. Usually an array with values consisting of [-1,1]. Experiment with the chain, you can have as many values as you like.</param> | ||
43 | public void VoronoiDiagram(int pointsPerBlock, int blockSize, double[] c) | ||
44 | { | ||
45 | SetDiff(); | ||
46 | |||
47 | List<Point2D> points = new List<Point2D>(); | ||
48 | Random generator = new Random(seed); | ||
49 | |||
50 | // Generate the emitter points | ||
51 | int x, y, i; | ||
52 | for (x = -blockSize; x < w + blockSize; x += blockSize) | ||
53 | { | ||
54 | for (y = -blockSize; y < h + blockSize; y += blockSize) | ||
55 | { | ||
56 | for (i = 0; i < pointsPerBlock; i++) | ||
57 | { | ||
58 | double pX = x + (generator.NextDouble()*(double) blockSize); | ||
59 | double pY = y + (generator.NextDouble()*(double) blockSize); | ||
60 | |||
61 | points.Add(new Point2D(pX, pY)); | ||
62 | } | ||
63 | } | ||
64 | } | ||
65 | |||
66 | double[] distances = new double[points.Count]; | ||
67 | |||
68 | // Calculate the distance each pixel is from an emitter | ||
69 | for (x = 0; x < w; x++) | ||
70 | { | ||
71 | for (y = 0; y < h; y++) | ||
72 | { | ||
73 | for (i = 0; i < points.Count; i++) | ||
74 | { | ||
75 | double dx, dy; | ||
76 | dx = Math.Abs((double) x - points[i].x); | ||
77 | dy = Math.Abs((double) y - points[i].y); | ||
78 | |||
79 | distances[i] = (dx*dx + dy*dy); | ||
80 | } | ||
81 | |||
82 | Array.Sort(distances); | ||
83 | |||
84 | double f = 0.0; | ||
85 | |||
86 | // Multiply the distances with their 'c' counterpart | ||
87 | // ordering the distances descending | ||
88 | for (i = 0; i < c.Length; i++) | ||
89 | { | ||
90 | if (i >= points.Count) | ||
91 | break; | ||
92 | |||
93 | f += c[i]*distances[i]; | ||
94 | } | ||
95 | |||
96 | map[x, y] = f; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | // Normalise the result | ||
101 | Normalise(); | ||
102 | } | ||
103 | |||
104 | public void VoronoiDiagram(List<Point2D> points, double[] c) | ||
105 | { | ||
106 | SetDiff(); | ||
107 | |||
108 | int x, y, i; | ||
109 | double[] distances = new double[points.Count]; | ||
110 | |||
111 | // Calculate the distance each pixel is from an emitter | ||
112 | for (x = 0; x < w; x++) | ||
113 | { | ||
114 | for (y = 0; y < h; y++) | ||
115 | { | ||
116 | for (i = 0; i < points.Count; i++) | ||
117 | { | ||
118 | double dx, dy; | ||
119 | dx = Math.Abs((double) x - points[i].x); | ||
120 | dy = Math.Abs((double) y - points[i].y); | ||
121 | |||
122 | distances[i] = (dx*dx + dy*dy); | ||
123 | } | ||
124 | |||
125 | Array.Sort(distances); | ||
126 | |||
127 | double f = 0.0; | ||
128 | |||
129 | // Multiply the distances with their 'c' counterpart | ||
130 | // ordering the distances descending | ||
131 | for (i = 0; i < c.Length; i++) | ||
132 | { | ||
133 | if (i >= points.Count) | ||
134 | break; | ||
135 | |||
136 | f += c[i]*distances[i]; | ||
137 | } | ||
138 | |||
139 | map[x, y] = f; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | // Normalise the result | ||
144 | Normalise(); | ||
145 | } | ||
146 | |||
147 | public void VoroflatDiagram(int pointsPerBlock, int blockSize) | ||
148 | { | ||
149 | SetDiff(); | ||
150 | |||
151 | List<Point2D> points = new List<Point2D>(); | ||
152 | Random generator = new Random(seed); | ||
153 | |||
154 | // Generate the emitter points | ||
155 | int x, y, i; | ||
156 | for (x = -blockSize; x < w + blockSize; x += blockSize) | ||
157 | { | ||
158 | for (y = -blockSize; y < h + blockSize; y += blockSize) | ||
159 | { | ||
160 | for (i = 0; i < pointsPerBlock; i++) | ||
161 | { | ||
162 | double pX = x + (generator.NextDouble()*(double) blockSize); | ||
163 | double pY = y + (generator.NextDouble()*(double) blockSize); | ||
164 | |||
165 | points.Add(new Point2D(pX, pY)); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | |||
170 | double[] distances = new double[points.Count]; | ||
171 | |||
172 | // Calculate the distance each pixel is from an emitter | ||
173 | for (x = 0; x < w; x++) | ||
174 | { | ||
175 | for (y = 0; y < h; y++) | ||
176 | { | ||
177 | for (i = 0; i < points.Count; i++) | ||
178 | { | ||
179 | double dx, dy; | ||
180 | dx = Math.Abs((double) x - points[i].x); | ||
181 | dy = Math.Abs((double) y - points[i].y); | ||
182 | |||
183 | distances[i] = (dx*dx + dy*dy); | ||
184 | } | ||
185 | |||
186 | //Array.Sort(distances); | ||
187 | |||
188 | double f = 0.0; | ||
189 | |||
190 | double min = double.MaxValue; | ||
191 | for (int j = 0; j < distances.Length; j++) | ||
192 | { | ||
193 | if (distances[j] < min) | ||
194 | { | ||
195 | min = distances[j]; | ||
196 | f = j; | ||
197 | } | ||
198 | } | ||
199 | |||
200 | // Multiply the distances with their 'c' counterpart | ||
201 | // ordering the distances descending | ||
202 | |||
203 | map[x, y] = f; | ||
204 | } | ||
205 | } | ||
206 | |||
207 | // Normalise the result | ||
208 | Normalise(); | ||
209 | } | ||
210 | } | ||
211 | } | ||
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs deleted file mode 100644 index d9f0990..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs +++ /dev/null | |||
@@ -1,71 +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 | |||
28 | using System; | ||
29 | |||
30 | namespace libTerrain | ||
31 | { | ||
32 | partial class Channel | ||
33 | { | ||
34 | /// <summary> | ||
35 | /// Generates 'number' of worms which navigate randomly around the landscape creating terrain as they go. | ||
36 | /// </summary> | ||
37 | /// <param name="number">The number of worms which will traverse the map</param> | ||
38 | /// <param name="rounds">The number of steps each worm will traverse</param> | ||
39 | /// <param name="movement">The maximum distance each worm will move each step</param> | ||
40 | /// <param name="size">The size of the area around the worm modified</param> | ||
41 | /// <param name="centerspawn">Do worms start in the middle, or randomly?</param> | ||
42 | public void Worms(int number, int rounds, double movement, double size, bool centerspawn) | ||
43 | { | ||
44 | SetDiff(); | ||
45 | |||
46 | Random random = new Random(seed); | ||
47 | int i, j; | ||
48 | |||
49 | for (i = 0; i < number; i++) | ||
50 | { | ||
51 | double rx, ry; | ||
52 | if (centerspawn) | ||
53 | { | ||
54 | rx = w/2.0; | ||
55 | ry = h/2.0; | ||
56 | } | ||
57 | else | ||
58 | { | ||
59 | rx = random.NextDouble()*(w - 1); | ||
60 | ry = random.NextDouble()*(h - 1); | ||
61 | } | ||
62 | for (j = 0; j < rounds; j++) | ||
63 | { | ||
64 | rx += (random.NextDouble()*movement) - (movement/2.0); | ||
65 | ry += (random.NextDouble()*movement) - (movement/2.0); | ||
66 | Raise(rx, ry, size, 1.0); | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | } | ||