aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs142
1 files changed, 142 insertions, 0 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
new file mode 100644
index 0000000..21d2645
--- /dev/null
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
@@ -0,0 +1,142 @@
1/*
2Redistribution and use in source and binary forms, with or without
3modification, are permitted provided that the following conditions are
4met:
5
6 * Redistributions of source code must retain the above copyright
7 notice, this list of conditions and the following disclaimer.
8
9 * Redistributions in binary form must reproduce the above
10 copyright notice, this list of conditions and the following
11 disclaimer in the documentation and/or other materials provided
12 with the distribution.
13
14 * Neither the name of libTerrain nor the names of
15 its contributors may be used to endorse or promote products
16 derived from this software without specific prior written
17 permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30*/
31
32
33using System;
34using System.Collections.Generic;
35using System.Text;
36
37namespace libTerrain
38{
39 partial class Channel
40 {
41 /// <summary>
42 /// Raises land around the selection
43 /// </summary>
44 /// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
45 /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
46 /// <param name="size">The radius of the dimple</param>
47 /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
48 public void raise(double rx, double ry, double size, double amount)
49 {
50 raiseSphere(rx, ry, size, amount);
51 }
52
53 /// <summary>
54 /// Raises land in a sphere around the selection
55 /// </summary>
56 /// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
57 /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
58 /// <param name="size">The radius of the sphere dimple</param>
59 /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
60 public void raiseSphere(double rx, double ry, double size, double amount)
61 {
62 int x, y;
63 for (x = 0; x < w; x++)
64 {
65 for (y = 0; y < h; y++)
66 {
67 double z = size;
68 z *= z;
69 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
70
71 if (z < 0)
72 z = 0;
73
74 map[x, y] += z * amount;
75 }
76 }
77 }
78
79 /// <summary>
80 /// Raises land in a cone around the selection
81 /// </summary>
82 /// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
83 /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
84 /// <param name="size">The radius of the cone</param>
85 /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
86 public void raiseCone(double rx, double ry, double size, double amount)
87 {
88 int x, y;
89 for (x = 0; x < w; x++)
90 {
91 for (y = 0; y < h; y++)
92 {
93 double z = size;
94 z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
95
96 if (z < 0)
97 z = 0;
98
99 map[x, y] += z * amount;
100 }
101 }
102 }
103
104 /// <summary>
105 /// Lowers land in a sphere around the selection
106 /// </summary>
107 /// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
108 /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
109 /// <param name="size">The radius of the sphere dimple</param>
110 /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
111 public void lower(double rx, double ry, double size, double amount)
112 {
113 lowerSphere(rx, ry, size, amount);
114 }
115
116 /// <summary>
117 /// Lowers land in a sphere around the selection
118 /// </summary>
119 /// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
120 /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
121 /// <param name="size">The radius of the sphere dimple</param>
122 /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
123 public void lowerSphere(double rx, double ry, double size, double amount)
124 {
125 int x, y;
126 for (x = 0; x < w; x++)
127 {
128 for (y = 0; y < h; y++)
129 {
130 double z = size;
131 z *= z;
132 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
133
134 if (z < 0)
135 z = 0;
136
137 map[x, y] -= z * amount;
138 }
139 }
140 }
141 }
142} \ No newline at end of file