diff options
author | Adam Frisby | 2007-04-06 18:48:23 +0000 |
---|---|---|
committer | Adam Frisby | 2007-04-06 18:48:23 +0000 |
commit | fb0dffbf13a79aabe9537f16b7bb151af62c75bf (patch) | |
tree | 28a8d468e5499a7af1e33eec7bbdeb9e82ae8732 /OpenSim.Terrain.BasicTerrain/RaiseLower.cs | |
parent | And now for some solution files... (diff) | |
download | opensim-SC_OLD-fb0dffbf13a79aabe9537f16b7bb151af62c75bf.zip opensim-SC_OLD-fb0dffbf13a79aabe9537f16b7bb151af62c75bf.tar.gz opensim-SC_OLD-fb0dffbf13a79aabe9537f16b7bb151af62c75bf.tar.bz2 opensim-SC_OLD-fb0dffbf13a79aabe9537f16b7bb151af62c75bf.tar.xz |
**BREAKING CHANGE** Changing the way terrain is stored and used internally.
Diffstat (limited to 'OpenSim.Terrain.BasicTerrain/RaiseLower.cs')
-rw-r--r-- | OpenSim.Terrain.BasicTerrain/RaiseLower.cs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/OpenSim.Terrain.BasicTerrain/RaiseLower.cs b/OpenSim.Terrain.BasicTerrain/RaiseLower.cs new file mode 100644 index 0000000..384bcc0 --- /dev/null +++ b/OpenSim.Terrain.BasicTerrain/RaiseLower.cs | |||
@@ -0,0 +1,91 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | |||
5 | namespace OpenSim.Terrain.BasicTerrain | ||
6 | { | ||
7 | static class RaiseLower | ||
8 | { | ||
9 | /// <summary> | ||
10 | /// Raises land around the selection | ||
11 | /// </summary> | ||
12 | /// <param name="rx">The center the X coordinate of where you wish to raise the land</param> | ||
13 | /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param> | ||
14 | /// <param name="size">The radius of the dimple</param> | ||
15 | /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param> | ||
16 | public static void raise(float[,] map, double rx, double ry, double size, double amount) | ||
17 | { | ||
18 | raiseSphere(map, rx, ry, size, amount); | ||
19 | } | ||
20 | |||
21 | /// <summary> | ||
22 | /// Raises land in a sphere around the selection | ||
23 | /// </summary> | ||
24 | /// <param name="rx">The center the X coordinate of where you wish to raise the land</param> | ||
25 | /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param> | ||
26 | /// <param name="size">The radius of the sphere dimple</param> | ||
27 | /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param> | ||
28 | public static void raiseSphere(float[,] map, double rx, double ry, double size, double amount) | ||
29 | { | ||
30 | int x, y; | ||
31 | int w = map.GetLength(0); | ||
32 | int h = map.GetLength(1); | ||
33 | |||
34 | for (x = 0; x < w; x++) | ||
35 | { | ||
36 | for (y = 0; y < h; y++) | ||
37 | { | ||
38 | double z = size; | ||
39 | z *= z; | ||
40 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | ||
41 | |||
42 | if (z < 0) | ||
43 | z = 0; | ||
44 | |||
45 | map[x, y] += (float)(z * amount); | ||
46 | } | ||
47 | } | ||
48 | } | ||
49 | |||
50 | /// <summary> | ||
51 | /// Lowers land in a sphere around the selection | ||
52 | /// </summary> | ||
53 | /// <param name="rx">The center the X coordinate of where you wish to lower the land</param> | ||
54 | /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param> | ||
55 | /// <param name="size">The radius of the sphere dimple</param> | ||
56 | /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param> | ||
57 | public static void lower(float[,] map, double rx, double ry, double size, double amount) | ||
58 | { | ||
59 | lowerSphere(map, rx, ry, size, amount); | ||
60 | } | ||
61 | |||
62 | /// <summary> | ||
63 | /// Lowers land in a sphere around the selection | ||
64 | /// </summary> | ||
65 | /// <param name="rx">The center the X coordinate of where you wish to lower the land</param> | ||
66 | /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param> | ||
67 | /// <param name="size">The radius of the sphere dimple</param> | ||
68 | /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param> | ||
69 | public static void lowerSphere(float[,] map, double rx, double ry, double size, double amount) | ||
70 | { | ||
71 | int x, y; | ||
72 | int w = map.GetLength(0); | ||
73 | int h = map.GetLength(1); | ||
74 | |||
75 | for (x = 0; x < w; x++) | ||
76 | { | ||
77 | for (y = 0; y < h; y++) | ||
78 | { | ||
79 | double z = size; | ||
80 | z *= z; | ||
81 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | ||
82 | |||
83 | if (z < 0) | ||
84 | z = 0; | ||
85 | |||
86 | map[x, y] -= (float)(z * amount); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | } | ||
91 | } | ||