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/Grid.cs | |
parent | * Get rid of missing texture notification drop messages for now - obscuring t... (diff) | |
download | opensim-SC-7c897043bab19bf748ac3078a05a74969c409fa7.zip opensim-SC-7c897043bab19bf748ac3078a05a74969c409fa7.tar.gz opensim-SC-7c897043bab19bf748ac3078a05a74969c409fa7.tar.bz2 opensim-SC-7c897043bab19bf748ac3078a05a74969c409fa7.tar.xz |
* Removing old libTerrainBSD and associated Plugin & Project.
* Updated prebuild.xml accordingly.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs | 376 |
1 files changed, 0 insertions, 376 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs deleted file mode 100644 index a3e24a2..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs +++ /dev/null | |||
@@ -1,376 +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 | public Channel Normalise() | ||
35 | { | ||
36 | SetDiff(); | ||
37 | |||
38 | double max = FindMax(); | ||
39 | double min = FindMin(); | ||
40 | |||
41 | int x, y; | ||
42 | |||
43 | if (max != min) | ||
44 | { | ||
45 | for (x = 0; x < w; x++) | ||
46 | { | ||
47 | for (y = 0; y < h; y++) | ||
48 | { | ||
49 | map[x, y] = (map[x, y] - min)*(1.0/(max - min)); | ||
50 | } | ||
51 | } | ||
52 | } | ||
53 | else | ||
54 | { | ||
55 | Fill(0.5); | ||
56 | } | ||
57 | |||
58 | return this; | ||
59 | } | ||
60 | |||
61 | public Channel Normalise(double minv, double maxv) | ||
62 | { | ||
63 | SetDiff(); | ||
64 | |||
65 | if (minv == maxv) | ||
66 | { | ||
67 | Fill(minv); | ||
68 | return this; | ||
69 | } | ||
70 | |||
71 | double max = FindMax(); | ||
72 | double min = FindMin(); | ||
73 | |||
74 | int x, y; | ||
75 | |||
76 | for (x = 0; x < w; x++) | ||
77 | { | ||
78 | for (y = 0; y < h; y++) | ||
79 | { | ||
80 | if (min != max) | ||
81 | { | ||
82 | double val = (map[x, y] - min)*(1.0/(max - min)); | ||
83 | val *= maxv - minv; | ||
84 | val += minv; | ||
85 | |||
86 | map[x, y] = val; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | map[x, y] = 0.5; | ||
91 | } | ||
92 | } | ||
93 | } | ||
94 | |||
95 | return this; | ||
96 | } | ||
97 | |||
98 | public Channel Elevate(double meters) | ||
99 | { | ||
100 | SetDiff(); | ||
101 | |||
102 | int x, y; | ||
103 | |||
104 | for (x = 0; x < w; x++) | ||
105 | { | ||
106 | for (y = 0; y < h; y++) | ||
107 | { | ||
108 | map[x, y] += meters; | ||
109 | } | ||
110 | } | ||
111 | |||
112 | return this; | ||
113 | } | ||
114 | |||
115 | |||
116 | public Channel Clip() | ||
117 | { | ||
118 | int x, y; | ||
119 | |||
120 | for (x = 0; x < w; x++) | ||
121 | { | ||
122 | for (y = 0; y < h; y++) | ||
123 | { | ||
124 | SetClip(x, y, map[x, y]); | ||
125 | } | ||
126 | } | ||
127 | |||
128 | return this; | ||
129 | } | ||
130 | |||
131 | public Channel Clip(double min, double max) | ||
132 | { | ||
133 | int x, y; | ||
134 | for (x = 0; x < w; x++) | ||
135 | { | ||
136 | for (y = 0; y < h; y++) | ||
137 | { | ||
138 | double val = map[x, y]; | ||
139 | if (val > max) val = max; | ||
140 | if (val < min) val = min; | ||
141 | |||
142 | Set(x, y, val); | ||
143 | } | ||
144 | } | ||
145 | return this; | ||
146 | } | ||
147 | |||
148 | public Channel Crop(int x1, int y1, int x2, int y2) | ||
149 | { | ||
150 | int width = x1 - x2 + 1; | ||
151 | int height = y1 - y2 + 1; | ||
152 | Channel chan = new Channel(width, height); | ||
153 | |||
154 | int x, y; | ||
155 | int nx, ny; | ||
156 | |||
157 | nx = 0; | ||
158 | for (x = x1; x < x2; x++) | ||
159 | { | ||
160 | ny = 0; | ||
161 | for (y = y1; y < y2; y++) | ||
162 | { | ||
163 | chan.map[nx, ny] = map[x, y]; | ||
164 | |||
165 | ny++; | ||
166 | } | ||
167 | nx++; | ||
168 | } | ||
169 | |||
170 | return this; | ||
171 | } | ||
172 | |||
173 | public Channel AddClip(Channel other) | ||
174 | { | ||
175 | SetDiff(); | ||
176 | |||
177 | int x, y; | ||
178 | for (x = 0; x < w; x++) | ||
179 | { | ||
180 | for (y = 0; y < h; y++) | ||
181 | { | ||
182 | map[x, y] = other.map[x, y]; | ||
183 | if (map[x, y] > 1) | ||
184 | map[x, y] = 1; | ||
185 | if (map[x, y] < 0) | ||
186 | map[x, y] = 0; | ||
187 | } | ||
188 | } | ||
189 | return this; | ||
190 | } | ||
191 | |||
192 | public void Smooth(double amount) | ||
193 | { | ||
194 | SetDiff(); | ||
195 | |||
196 | double area = amount; | ||
197 | double step = amount/4.0; | ||
198 | |||
199 | double[,] manipulate = new double[w,h]; | ||
200 | int x, y; | ||
201 | double n, l; | ||
202 | for (x = 0; x < w; x++) | ||
203 | { | ||
204 | for (y = 0; y < h; y++) | ||
205 | { | ||
206 | double average = 0.0; | ||
207 | int avgsteps = 0; | ||
208 | |||
209 | for (n = 0.0 - area; n < area; n += step) | ||
210 | { | ||
211 | for (l = 0.0 - area; l < area; l += step) | ||
212 | { | ||
213 | avgsteps++; | ||
214 | average += GetBilinearInterpolate(x + n, y + l); | ||
215 | } | ||
216 | } | ||
217 | |||
218 | manipulate[x, y] = average/avgsteps; | ||
219 | } | ||
220 | } | ||
221 | map = manipulate; | ||
222 | } | ||
223 | |||
224 | public void Pertubation(double amount) | ||
225 | { | ||
226 | SetDiff(); | ||
227 | |||
228 | // Simple pertubation filter | ||
229 | double[,] manipulated = new double[w,h]; | ||
230 | Random generator = new Random(seed); // Seeds FTW! | ||
231 | //double amount = 8.0; | ||
232 | |||
233 | int x, y; | ||
234 | for (x = 0; x < w; x++) | ||
235 | { | ||
236 | for (y = 0; y < h; y++) | ||
237 | { | ||
238 | double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0); | ||
239 | double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0); | ||
240 | double p = GetBilinearInterpolate(offset_x, offset_y); | ||
241 | manipulated[x, y] = p; | ||
242 | } | ||
243 | } | ||
244 | map = manipulated; | ||
245 | } | ||
246 | |||
247 | public void PertubationMask(Channel mask) | ||
248 | { | ||
249 | // Simple pertubation filter | ||
250 | double[,] manipulated = new double[w,h]; | ||
251 | Random generator = new Random(seed); // Seeds FTW! | ||
252 | //double amount = 8.0; | ||
253 | |||
254 | double amount; | ||
255 | |||
256 | int x, y; | ||
257 | for (x = 0; x < w; x++) | ||
258 | { | ||
259 | for (y = 0; y < h; y++) | ||
260 | { | ||
261 | amount = mask.map[x, y]; | ||
262 | double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0); | ||
263 | double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0); | ||
264 | |||
265 | if (offset_x > w) | ||
266 | offset_x = w - 1; | ||
267 | if (offset_y > h) | ||
268 | offset_y = h - 1; | ||
269 | if (offset_y < 0) | ||
270 | offset_y = 0; | ||
271 | if (offset_x < 0) | ||
272 | offset_x = 0; | ||
273 | |||
274 | double p = GetBilinearInterpolate(offset_x, offset_y); | ||
275 | manipulated[x, y] = p; | ||
276 | SetDiff(x, y); | ||
277 | } | ||
278 | } | ||
279 | map = manipulated; | ||
280 | } | ||
281 | |||
282 | public void Distort(Channel mask, double str) | ||
283 | { | ||
284 | // Simple pertubation filter | ||
285 | double[,] manipulated = new double[w,h]; | ||
286 | |||
287 | double amount; | ||
288 | |||
289 | int x, y; | ||
290 | for (x = 0; x < w; x++) | ||
291 | { | ||
292 | for (y = 0; y < h; y++) | ||
293 | { | ||
294 | amount = mask.map[x, y]; | ||
295 | double offset_x = (double) x + (amount*str) - (0.5*str); | ||
296 | double offset_y = (double) y + (amount*str) - (0.5*str); | ||
297 | |||
298 | if (offset_x > w) | ||
299 | offset_x = w - 1; | ||
300 | if (offset_y > h) | ||
301 | offset_y = h - 1; | ||
302 | if (offset_y < 0) | ||
303 | offset_y = 0; | ||
304 | if (offset_x < 0) | ||
305 | offset_x = 0; | ||
306 | |||
307 | double p = GetBilinearInterpolate(offset_x, offset_y); | ||
308 | manipulated[x, y] = p; | ||
309 | SetDiff(x, y); | ||
310 | } | ||
311 | } | ||
312 | map = manipulated; | ||
313 | } | ||
314 | |||
315 | public void Distort(Channel mask, Channel mask2, double str) | ||
316 | { | ||
317 | // Simple pertubation filter | ||
318 | double[,] manipulated = new double[w,h]; | ||
319 | |||
320 | double amountX; | ||
321 | double amountY; | ||
322 | |||
323 | int x, y; | ||
324 | for (x = 0; x < w; x++) | ||
325 | { | ||
326 | for (y = 0; y < h; y++) | ||
327 | { | ||
328 | amountX = mask.map[x, y]; | ||
329 | amountY = mask2.map[x, y]; | ||
330 | double offset_x = (double) x + (amountX*str) - (0.5*str); | ||
331 | double offset_y = (double) y + (amountY*str) - (0.5*str); | ||
332 | |||
333 | if (offset_x > w) | ||
334 | offset_x = w - 1; | ||
335 | if (offset_y > h) | ||
336 | offset_y = h - 1; | ||
337 | if (offset_y < 0) | ||
338 | offset_y = 0; | ||
339 | if (offset_x < 0) | ||
340 | offset_x = 0; | ||
341 | |||
342 | double p = GetBilinearInterpolate(offset_x, offset_y); | ||
343 | manipulated[x, y] = p; | ||
344 | SetDiff(x, y); | ||
345 | } | ||
346 | } | ||
347 | map = manipulated; | ||
348 | } | ||
349 | |||
350 | public Channel Blend(Channel other, double amount) | ||
351 | { | ||
352 | int x, y; | ||
353 | for (x = 0; x < w; x++) | ||
354 | { | ||
355 | for (y = 0; y < h; y++) | ||
356 | { | ||
357 | Set(x, y, Tools.LinearInterpolate(map[x, y], other.map[x, y], amount)); | ||
358 | } | ||
359 | } | ||
360 | return this; | ||
361 | } | ||
362 | |||
363 | public Channel Blend(Channel other, Channel amount) | ||
364 | { | ||
365 | int x, y; | ||
366 | for (x = 0; x < w; x++) | ||
367 | { | ||
368 | for (y = 0; y < h; y++) | ||
369 | { | ||
370 | Set(x, y, Tools.LinearInterpolate(map[x, y], other.map[x, y], amount.map[x, y])); | ||
371 | } | ||
372 | } | ||
373 | return this; | ||
374 | } | ||
375 | } | ||
376 | } | ||