diff options
Start of the OpenSim library , for now only contains a few textures.
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs | 296 | ||||
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs | 276 |
2 files changed, 286 insertions, 286 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs index 48f02e8..713ae23 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs | |||
@@ -1,149 +1,149 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | using System; | 30 | using System; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Text; | 32 | using System.Text; |
33 | 33 | ||
34 | namespace libTerrain | 34 | namespace libTerrain |
35 | { | 35 | { |
36 | partial class Channel | 36 | partial class Channel |
37 | { | 37 | { |
38 | /// <summary> | 38 | /// <summary> |
39 | /// Flattens the area underneath rx,ry by moving it to the average of the area. Uses a spherical mask provided by the raise() function. | 39 | /// Flattens the area underneath rx,ry by moving it to the average of the area. Uses a spherical mask provided by the raise() function. |
40 | /// </summary> | 40 | /// </summary> |
41 | /// <param name="rx">The X coordinate of the terrain mask</param> | 41 | /// <param name="rx">The X coordinate of the terrain mask</param> |
42 | /// <param name="ry">The Y coordinate of the terrain mask</param> | 42 | /// <param name="ry">The Y coordinate of the terrain mask</param> |
43 | /// <param name="size">The size of the terrain mask</param> | 43 | /// <param name="size">The size of the terrain mask</param> |
44 | /// <param name="amount">The scale of the terrain mask</param> | 44 | /// <param name="amount">The scale of the terrain mask</param> |
45 | public void Flatten(double rx, double ry, double size, double amount) | 45 | public void Flatten(double rx, double ry, double size, double amount) |
46 | { | 46 | { |
47 | FlattenSlow(rx, ry, size, amount); | 47 | FlattenSlow(rx, ry, size, amount); |
48 | } | 48 | } |
49 | 49 | ||
50 | private void FlattenSlow(double rx, double ry, double size, double amount) | 50 | private void FlattenSlow(double rx, double ry, double size, double amount) |
51 | { | 51 | { |
52 | // Generate the mask | 52 | // Generate the mask |
53 | Channel temp = new Channel(w, h); | 53 | Channel temp = new Channel(w, h); |
54 | temp.Fill(0); | 54 | temp.Fill(0); |
55 | temp.Raise(rx, ry, size, amount); | 55 | temp.Raise(rx, ry, size, amount); |
56 | temp.Normalise(); | 56 | temp.Normalise(); |
57 | double total_mod = temp.Sum(); | 57 | double total_mod = temp.Sum(); |
58 | 58 | ||
59 | // Establish the average height under the area | 59 | // Establish the average height under the area |
60 | Channel newmap = new Channel(w, h); | 60 | Channel newmap = new Channel(w, h); |
61 | newmap.map = (double[,])map.Clone(); | 61 | newmap.map = (double[,])map.Clone(); |
62 | 62 | ||
63 | newmap *= temp; | 63 | newmap *= temp; |
64 | 64 | ||
65 | double total_terrain = newmap.Sum(); | 65 | double total_terrain = newmap.Sum(); |
66 | double avg_height = total_terrain / total_mod; | 66 | double avg_height = total_terrain / total_mod; |
67 | 67 | ||
68 | // Create a flat terrain using the average height | 68 | // Create a flat terrain using the average height |
69 | Channel flat = new Channel(w, h); | 69 | Channel flat = new Channel(w, h); |
70 | flat.Fill(avg_height); | 70 | flat.Fill(avg_height); |
71 | 71 | ||
72 | // Blend the current terrain with the average height terrain | 72 | // Blend the current terrain with the average height terrain |
73 | // using the "raised" empty terrain as a mask | 73 | // using the "raised" empty terrain as a mask |
74 | Blend(flat, temp); | 74 | Blend(flat, temp); |
75 | 75 | ||
76 | } | 76 | } |
77 | 77 | ||
78 | private void FlattenFast(double rx, double ry, double size, double amount) | 78 | private void FlattenFast(double rx, double ry, double size, double amount) |
79 | { | 79 | { |
80 | int x, y; | 80 | int x, y; |
81 | double avg = 0; | 81 | double avg = 0; |
82 | double div = 0; | 82 | double div = 0; |
83 | 83 | ||
84 | int minX = Math.Max(0, (int)(rx - (size + 1))); | 84 | int minX = Math.Max(0, (int)(rx - (size + 1))); |
85 | int maxX = Math.Min(w, (int)(rx + (size + 1))); | 85 | int maxX = Math.Min(w, (int)(rx + (size + 1))); |
86 | int minY = Math.Max(0, (int)(ry - (size + 1))); | 86 | int minY = Math.Max(0, (int)(ry - (size + 1))); |
87 | int maxY = Math.Min(h, (int)(ry + (size + 1))); | 87 | int maxY = Math.Min(h, (int)(ry + (size + 1))); |
88 | 88 | ||
89 | for (x = minX; x < maxX; x++) | 89 | for (x = minX; x < maxX; x++) |
90 | { | 90 | { |
91 | for (y = minY; y < maxY; y++) | 91 | for (y = minY; y < maxY; y++) |
92 | { | 92 | { |
93 | double z = size; | 93 | double z = size; |
94 | z *= z; | 94 | z *= z; |
95 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 95 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
96 | 96 | ||
97 | if (z < 0) | 97 | if (z < 0) |
98 | z = 0; | 98 | z = 0; |
99 | 99 | ||
100 | avg += z * amount; | 100 | avg += z * amount; |
101 | div += z; | 101 | div += z; |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | double height = avg / div; | 105 | double height = avg / div; |
106 | 106 | ||
107 | for (x = minX; x < maxX; x++) | 107 | for (x = minX; x < maxX; x++) |
108 | { | 108 | { |
109 | for (y = minY; y < maxY; y++) | 109 | for (y = minY; y < maxY; y++) |
110 | { | 110 | { |
111 | double z = size; | 111 | double z = size; |
112 | z *= z; | 112 | z *= z; |
113 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 113 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
114 | 114 | ||
115 | if (z < 0) | 115 | if (z < 0) |
116 | z = 0; | 116 | z = 0; |
117 | 117 | ||
118 | Set(x, y, Tools.linearInterpolate(map[x, y], height, z)); | 118 | Set(x, y, Tools.linearInterpolate(map[x, y], height, z)); |
119 | } | 119 | } |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | public void Flatten(Channel mask, double amount) | 123 | public void Flatten(Channel mask, double amount) |
124 | { | 124 | { |
125 | // Generate the mask | 125 | // Generate the mask |
126 | Channel temp = mask * amount; | 126 | Channel temp = mask * amount; |
127 | temp.Clip(0, 1); // Cut off out-of-bounds values | 127 | temp.Clip(0, 1); // Cut off out-of-bounds values |
128 | 128 | ||
129 | double total_mod = temp.Sum(); | 129 | double total_mod = temp.Sum(); |
130 | 130 | ||
131 | // Establish the average height under the area | 131 | // Establish the average height under the area |
132 | Channel map = new Channel(w, h); | 132 | Channel map = new Channel(w, h); |
133 | map.map = (double[,])this.map.Clone(); | 133 | map.map = (double[,])this.map.Clone(); |
134 | 134 | ||
135 | map *= temp; | 135 | map *= temp; |
136 | 136 | ||
137 | double total_terrain = map.Sum(); | 137 | double total_terrain = map.Sum(); |
138 | double avg_height = total_terrain / total_mod; | 138 | double avg_height = total_terrain / total_mod; |
139 | 139 | ||
140 | // Create a flat terrain using the average height | 140 | // Create a flat terrain using the average height |
141 | Channel flat = new Channel(w, h); | 141 | Channel flat = new Channel(w, h); |
142 | flat.Fill(avg_height); | 142 | flat.Fill(avg_height); |
143 | 143 | ||
144 | // Blend the current terrain with the average height terrain | 144 | // Blend the current terrain with the average height terrain |
145 | // using the "raised" empty terrain as a mask | 145 | // using the "raised" empty terrain as a mask |
146 | Blend(flat, temp); | 146 | Blend(flat, temp); |
147 | } | 147 | } |
148 | } | 148 | } |
149 | } \ No newline at end of file | 149 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs index 1d04a4f..64d175c 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs | |||
@@ -1,139 +1,139 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | 2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | 29 | ||
30 | using System; | 30 | using System; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Text; | 32 | using System.Text; |
33 | 33 | ||
34 | namespace libTerrain | 34 | namespace libTerrain |
35 | { | 35 | { |
36 | partial class Channel | 36 | partial class Channel |
37 | { | 37 | { |
38 | /// <summary> | 38 | /// <summary> |
39 | /// Raises land around the selection | 39 | /// Raises land around the selection |
40 | /// </summary> | 40 | /// </summary> |
41 | /// <param name="rx">The center the X coordinate of where you wish to raise the land</param> | 41 | /// <param name="rx">The center the X coordinate of where you wish to raise the land</param> |
42 | /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param> | 42 | /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param> |
43 | /// <param name="size">The radius of the dimple</param> | 43 | /// <param name="size">The radius of the dimple</param> |
44 | /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param> | 44 | /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param> |
45 | public void Raise(double rx, double ry, double size, double amount) | 45 | public void Raise(double rx, double ry, double size, double amount) |
46 | { | 46 | { |
47 | RaiseSphere(rx, ry, size, amount); | 47 | RaiseSphere(rx, ry, size, amount); |
48 | } | 48 | } |
49 | 49 | ||
50 | /// <summary> | 50 | /// <summary> |
51 | /// Raises land in a sphere around the selection | 51 | /// Raises land in a sphere around the selection |
52 | /// </summary> | 52 | /// </summary> |
53 | /// <param name="rx">The center the X coordinate of where you wish to raise the land</param> | 53 | /// <param name="rx">The center the X coordinate of where you wish to raise the land</param> |
54 | /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param> | 54 | /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param> |
55 | /// <param name="size">The radius of the sphere dimple</param> | 55 | /// <param name="size">The radius of the sphere dimple</param> |
56 | /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param> | 56 | /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param> |
57 | public void RaiseSphere(double rx, double ry, double size, double amount) | 57 | public void RaiseSphere(double rx, double ry, double size, double amount) |
58 | { | 58 | { |
59 | int x, y; | 59 | int x, y; |
60 | for (x = 0; x < w; x++) | 60 | for (x = 0; x < w; x++) |
61 | { | 61 | { |
62 | for (y = 0; y < h; y++) | 62 | for (y = 0; y < h; y++) |
63 | { | 63 | { |
64 | double z = size; | 64 | double z = size; |
65 | z *= z; | 65 | z *= z; |
66 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 66 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
67 | 67 | ||
68 | if (z < 0) | 68 | if (z < 0) |
69 | z = 0; | 69 | z = 0; |
70 | 70 | ||
71 | Set(x, y, map[x, y] + (z * amount)); | 71 | Set(x, y, map[x, y] + (z * amount)); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | /// <summary> | 76 | /// <summary> |
77 | /// Raises land in a cone around the selection | 77 | /// Raises land in a cone around the selection |
78 | /// </summary> | 78 | /// </summary> |
79 | /// <param name="rx">The center the X coordinate of where you wish to raise the land</param> | 79 | /// <param name="rx">The center the X coordinate of where you wish to raise the land</param> |
80 | /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param> | 80 | /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param> |
81 | /// <param name="size">The radius of the cone</param> | 81 | /// <param name="size">The radius of the cone</param> |
82 | /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param> | 82 | /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param> |
83 | public void RaiseCone(double rx, double ry, double size, double amount) | 83 | public void RaiseCone(double rx, double ry, double size, double amount) |
84 | { | 84 | { |
85 | int x, y; | 85 | int x, y; |
86 | for (x = 0; x < w; x++) | 86 | for (x = 0; x < w; x++) |
87 | { | 87 | { |
88 | for (y = 0; y < h; y++) | 88 | for (y = 0; y < h; y++) |
89 | { | 89 | { |
90 | double z = size; | 90 | double z = size; |
91 | z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); | 91 | z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); |
92 | 92 | ||
93 | if (z < 0) | 93 | if (z < 0) |
94 | z = 0; | 94 | z = 0; |
95 | 95 | ||
96 | Set(x, y, map[x, y] + (z * amount)); | 96 | Set(x, y, map[x, y] + (z * amount)); |
97 | } | 97 | } |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | /// <summary> | 101 | /// <summary> |
102 | /// Lowers land in a sphere around the selection | 102 | /// Lowers land in a sphere around the selection |
103 | /// </summary> | 103 | /// </summary> |
104 | /// <param name="rx">The center the X coordinate of where you wish to lower the land</param> | 104 | /// <param name="rx">The center the X coordinate of where you wish to lower the land</param> |
105 | /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param> | 105 | /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param> |
106 | /// <param name="size">The radius of the sphere dimple</param> | 106 | /// <param name="size">The radius of the sphere dimple</param> |
107 | /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param> | 107 | /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param> |
108 | public void Lower(double rx, double ry, double size, double amount) | 108 | public void Lower(double rx, double ry, double size, double amount) |
109 | { | 109 | { |
110 | LowerSphere(rx, ry, size, amount); | 110 | LowerSphere(rx, ry, size, amount); |
111 | } | 111 | } |
112 | 112 | ||
113 | /// <summary> | 113 | /// <summary> |
114 | /// Lowers land in a sphere around the selection | 114 | /// Lowers land in a sphere around the selection |
115 | /// </summary> | 115 | /// </summary> |
116 | /// <param name="rx">The center the X coordinate of where you wish to lower the land</param> | 116 | /// <param name="rx">The center the X coordinate of where you wish to lower the land</param> |
117 | /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param> | 117 | /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param> |
118 | /// <param name="size">The radius of the sphere dimple</param> | 118 | /// <param name="size">The radius of the sphere dimple</param> |
119 | /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param> | 119 | /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param> |
120 | public void LowerSphere(double rx, double ry, double size, double amount) | 120 | public void LowerSphere(double rx, double ry, double size, double amount) |
121 | { | 121 | { |
122 | int x, y; | 122 | int x, y; |
123 | for (x = 0; x < w; x++) | 123 | for (x = 0; x < w; x++) |
124 | { | 124 | { |
125 | for (y = 0; y < h; y++) | 125 | for (y = 0; y < h; y++) |
126 | { | 126 | { |
127 | double z = size; | 127 | double z = size; |
128 | z *= z; | 128 | z *= z; |
129 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 129 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
130 | 130 | ||
131 | if (z < 0) | 131 | if (z < 0) |
132 | z = 0; | 132 | z = 0; |
133 | 133 | ||
134 | Set(x, y, map[x, y] - (z * amount)); | 134 | Set(x, y, map[x, y] - (z * amount)); |
135 | } | 135 | } |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | } \ No newline at end of file | 139 | } \ No newline at end of file |