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/Editing | |
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 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs | 141 | ||||
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs | 191 |
2 files changed, 0 insertions, 332 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs deleted file mode 100644 index 7162758..0000000 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs +++ /dev/null | |||
@@ -1,141 +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 | /// <summary> | ||
33 | /// Flattens the area underneath rx,ry by moving it to the average of the area. Uses a spherical mask provided by the raise() function. | ||
34 | /// </summary> | ||
35 | /// <param name="rx">The X coordinate of the terrain mask</param> | ||
36 | /// <param name="ry">The Y coordinate of the terrain mask</param> | ||
37 | /// <param name="size">The size of the terrain mask</param> | ||
38 | /// <param name="amount">The scale of the terrain mask</param> | ||
39 | public void Flatten(double rx, double ry, double size, double amount) | ||
40 | { | ||
41 | FlattenSlow(rx, ry, size, amount); | ||
42 | } | ||
43 | |||
44 | private void FlattenSlow(double rx, double ry, double size, double amount) | ||
45 | { | ||
46 | // Generate the mask | ||
47 | Channel temp = new Channel(w, h); | ||
48 | temp.Fill(0); | ||
49 | temp.Raise(rx, ry, size, amount); | ||
50 | temp.Normalise(); | ||
51 | double total_mod = temp.Sum(); | ||
52 | |||
53 | // Establish the average height under the area | ||
54 | Channel newmap = new Channel(w, h); | ||
55 | newmap.map = (double[,]) map.Clone(); | ||
56 | |||
57 | newmap *= temp; | ||
58 | |||
59 | double total_terrain = newmap.Sum(); | ||
60 | double avg_height = total_terrain/total_mod; | ||
61 | |||
62 | // Create a flat terrain using the average height | ||
63 | Channel flat = new Channel(w, h); | ||
64 | flat.Fill(avg_height); | ||
65 | |||
66 | // Blend the current terrain with the average height terrain | ||
67 | // using the "raised" empty terrain as a mask | ||
68 | Blend(flat, temp); | ||
69 | } | ||
70 | |||
71 | // TODO: unused | ||
72 | // private void FlattenFast(double rx, double ry, double size, double amount) | ||
73 | // { | ||
74 | // int x, y; | ||
75 | // double avg = 0; | ||
76 | // double div = 0; | ||
77 | |||
78 | // int minX = Math.Max(0, (int) (rx - (size + 1))); | ||
79 | // int maxX = Math.Min(w, (int) (rx + (size + 1))); | ||
80 | // int minY = Math.Max(0, (int) (ry - (size + 1))); | ||
81 | // int maxY = Math.Min(h, (int) (ry + (size + 1))); | ||
82 | |||
83 | // for (x = minX; x < maxX; x++) | ||
84 | // { | ||
85 | // for (y = minY; y < maxY; y++) | ||
86 | // { | ||
87 | // double z = size; | ||
88 | // z *= z; | ||
89 | // z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry)); | ||
90 | |||
91 | // if (z < 0) | ||
92 | // z = 0; | ||
93 | |||
94 | // avg += z*amount; | ||
95 | // div += z; | ||
96 | // } | ||
97 | // } | ||
98 | |||
99 | // double height = avg/div; | ||
100 | |||
101 | // for (x = minX; x < maxX; x++) | ||
102 | // { | ||
103 | // for (y = minY; y < maxY; y++) | ||
104 | // { | ||
105 | // double z = size; | ||
106 | // z *= z; | ||
107 | // z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry)); | ||
108 | |||
109 | // if (z > 0.0) | ||
110 | // Set(x, y, Tools.LinearInterpolate(map[x, y], height, z)); | ||
111 | // } | ||
112 | // } | ||
113 | // } | ||
114 | |||
115 | public void Flatten(Channel mask, double amount) | ||
116 | { | ||
117 | // Generate the mask | ||
118 | Channel temp = mask*amount; | ||
119 | temp.Clip(0, 1); // Cut off out-of-bounds values | ||
120 | |||
121 | double total_mod = temp.Sum(); | ||
122 | |||
123 | // Establish the average height under the area | ||
124 | Channel map = new Channel(w, h); | ||
125 | map.map = (double[,]) this.map.Clone(); | ||
126 | |||
127 | map *= temp; | ||
128 | |||
129 | double total_terrain = map.Sum(); | ||
130 | double avg_height = total_terrain/total_mod; | ||
131 | |||
132 | // Create a flat terrain using the average height | ||
133 | Channel flat = new Channel(w, h); | ||
134 | flat.Fill(avg_height); | ||
135 | |||
136 | // Blend the current terrain with the average height terrain | ||
137 | // using the "raised" empty terrain as a mask | ||
138 | Blend(flat, temp); | ||
139 | } | ||
140 | } | ||
141 | } | ||
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 | |||
28 | using System; | ||
29 | |||
30 | namespace 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 | } | ||