aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs191
1 files changed, 0 insertions, 191 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
deleted file mode 100644
index 465005a..0000000
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
+++ /dev/null
@@ -1,191 +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 /// Raises land around the selection
36 /// </summary>
37 /// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
38 /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
39 /// <param name="size">The radius of the dimple</param>
40 /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
41 public void Raise(double rx, double ry, double size, double amount)
42 {
43 RaiseSphere(rx, ry, size, amount);
44 }
45
46 /// <summary>
47 /// Raises land in a sphere around the selection
48 /// </summary>
49 /// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
50 /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
51 /// <param name="size">The radius of the sphere dimple</param>
52 /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
53 public void RaiseSphere(double rx, double ry, double size, double amount)
54 {
55 int x, y;
56 for (x = 0; x < w; x++)
57 {
58 for (y = 0; y < h; y++)
59 {
60 double z = size;
61 z *= z;
62 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
63
64 if (z > 0.0)
65 Set(x, y, map[x, y] + (z * amount));
66 }
67 }
68 }
69
70 /// <summary>
71 /// Raises land in a cone around the selection
72 /// </summary>
73 /// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
74 /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
75 /// <param name="size">The radius of the cone</param>
76 /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
77 public void RaiseCone(double rx, double ry, double size, double amount)
78 {
79 int x, y;
80 for (x = 0; x < w; x++)
81 {
82 for (y = 0; y < h; y++)
83 {
84 double z = size;
85 z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry)));
86
87 if (z > 0.0)
88 Set(x, y, map[x, y] + (z * amount));
89 }
90 }
91 }
92
93 /// <summary>
94 /// Lowers land in a sphere around the selection
95 /// </summary>
96 /// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
97 /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
98 /// <param name="size">The radius of the sphere dimple</param>
99 /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
100 public void Lower(double rx, double ry, double size, double amount)
101 {
102 LowerSphere(rx, ry, size, amount);
103 }
104
105 /// <summary>
106 /// Lowers land in a sphere around the selection
107 /// </summary>
108 /// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
109 /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
110 /// <param name="size">The radius of the sphere dimple</param>
111 /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
112 public void LowerSphere(double rx, double ry, double size, double amount)
113 {
114 int x, y;
115 for (x = 0; x < w; x++)
116 {
117 for (y = 0; y < h; y++)
118 {
119 double z = size;
120 z *= z;
121 z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
122
123 if (z > 0.0)
124 Set(x, y, map[x, y] - (z * amount));
125 }
126 }
127 }
128
129 public double SphericalFactor(double x, double y, double rx, double ry, double size)
130 {
131 double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry));
132 return z;
133 }
134
135 public void SmoothRegion(double rx, double ry, double size, double amount)
136 {
137 int x, y;
138 double[,] tweak = new double[w, h];
139
140 double n, l;
141 double area = size;
142 double step = size / 4.0;
143
144 // compute delta map
145 for (x = 0; x < w; x++)
146 {
147 for (y = 0; y < h; y++)
148 {
149 double z = SphericalFactor(x, y, rx, ry, size);
150
151 if (z > 0) // add in non-zero amount
152 {
153 double average = 0.0;
154 int avgsteps = 0;
155
156 for (n = 0.0 - area; n < area; n += step)
157 {
158 for (l = 0.0 - area; l < area; l += step)
159 {
160 avgsteps++;
161 average += GetBilinearInterpolate(x + n, y + l);
162 }
163 }
164 tweak[x, y] = average / avgsteps;
165 //if (x == rx && y == ry)
166 // Console.WriteLine("tweak[ " + x + " , " + y + " ] = " + tweak[x, y]);
167 }
168 }
169 }
170 // blend in map
171 for (x = 0; x < w; x++)
172 {
173 for (y = 0; y < h; y++)
174 {
175 double z = SphericalFactor(x, y, rx, ry, size);
176
177 if (z > 0) // add in non-zero amount
178 {
179 double da = z * amount;
180 double a = (map[x, y] - tweak[x, y]) * da;
181 double newz = map[x, y] - a;
182 //if (rx == x || ry == y)
183 // Console.WriteLine("map[ " + x + " , " + y + " ] = " + map[x, y] + " tweak, a , da, z, size, amount = " + tweak[x, y] + " " + a + " " + da + " " + z + " " + size + " " + amount);
184 if (newz > 0.0)
185 Set(x, y, newz);
186 }
187 }
188 }
189 }
190 }
191}