diff options
author | Adam Frisby | 2008-04-22 07:53:32 +0000 |
---|---|---|
committer | Adam Frisby | 2008-04-22 07:53:32 +0000 |
commit | c8eb8d66fdedebbbb82348a9a60cd47fb0955305 (patch) | |
tree | 24572c1d599a1b9e249b190070e1cebbcbc29583 /OpenSim/Region/Modules/Terrain/Extensions | |
parent | * Added missing reference to OpenSim.Framework.Communications to RemoteAdminP... (diff) | |
download | opensim-SC_OLD-c8eb8d66fdedebbbb82348a9a60cd47fb0955305.zip opensim-SC_OLD-c8eb8d66fdedebbbb82348a9a60cd47fb0955305.tar.gz opensim-SC_OLD-c8eb8d66fdedebbbb82348a9a60cd47fb0955305.tar.bz2 opensim-SC_OLD-c8eb8d66fdedebbbb82348a9a60cd47fb0955305.tar.xz |
* Committing new terrain plugin effects system. Loads DLLs in /bin/Terrain/ as terrain module extensions. Committing sample plugin library.
* prebuild.xml changes.
Diffstat (limited to 'OpenSim/Region/Modules/Terrain/Extensions')
-rw-r--r-- | OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs b/OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs new file mode 100644 index 0000000..2f2c04e --- /dev/null +++ b/OpenSim/Region/Modules/Terrain/Extensions/DefaultEffects/Effects/ChannelDigger.cs | |||
@@ -0,0 +1,80 @@ | |||
1 | using System; | ||
2 | using OpenSim.Region.Environment.Interfaces; | ||
3 | using OpenSim.Region.Environment.Modules.Terrain; | ||
4 | using OpenSim.Region.Environment.Modules.Terrain.FloodBrushes; | ||
5 | |||
6 | namespace OpenSim.Region.Modules.Terrain.Extensions.DefaultEffects.Effects | ||
7 | { | ||
8 | public class ChannelDigger : ITerrainEffect | ||
9 | { | ||
10 | private readonly int num_h = 4; | ||
11 | private readonly int num_w = 4; | ||
12 | |||
13 | private readonly ITerrainFloodEffect raiseFunction = new RaiseArea(); | ||
14 | private readonly ITerrainFloodEffect smoothFunction = new SmoothArea(); | ||
15 | |||
16 | #region ITerrainEffect Members | ||
17 | |||
18 | public void RunEffect(ITerrainChannel map) | ||
19 | { | ||
20 | FillMap(map, 15); | ||
21 | BuildTiles(map, 7); | ||
22 | SmoothMap(map, 3); | ||
23 | } | ||
24 | |||
25 | #endregion | ||
26 | |||
27 | private void SmoothMap(ITerrainChannel map, int rounds) | ||
28 | { | ||
29 | Boolean[,] bitmap = new bool[map.Width,map.Height]; | ||
30 | for (int x = 0; x < map.Width; x++) | ||
31 | { | ||
32 | for (int y = 0; y < map.Height; y++) | ||
33 | { | ||
34 | bitmap[x, y] = true; | ||
35 | } | ||
36 | } | ||
37 | |||
38 | for (int i = 0; i < rounds; i++) | ||
39 | { | ||
40 | smoothFunction.FloodEffect(map, bitmap, 1.0); | ||
41 | } | ||
42 | } | ||
43 | |||
44 | private void FillMap(ITerrainChannel map, double val) | ||
45 | { | ||
46 | for (int x = 0; x < map.Width; x++) | ||
47 | for (int y = 0; y < map.Height; y++) | ||
48 | map[x, y] = val; | ||
49 | } | ||
50 | |||
51 | private void BuildTiles(ITerrainChannel map, double height) | ||
52 | { | ||
53 | int channelWidth = (int) Math.Floor((map.Width / num_w) * 0.8); | ||
54 | int channelHeight = (int) Math.Floor((map.Height / num_h) * 0.8); | ||
55 | int channelXOffset = (map.Width / num_w) - channelWidth; | ||
56 | int channelYOffset = (map.Height / num_h) - channelHeight; | ||
57 | |||
58 | for (int x = 0; x < num_w; x++) | ||
59 | { | ||
60 | for (int y = 0; y < num_h; y++) | ||
61 | { | ||
62 | int xoff = ((channelXOffset + channelWidth) * x) + (channelXOffset / 2); | ||
63 | int yoff = ((channelYOffset + channelHeight) * y) + (channelYOffset / 2); | ||
64 | |||
65 | Boolean[,] bitmap = new bool[map.Width,map.Height]; | ||
66 | |||
67 | for (int dx = 0; dx < channelWidth; dx++) | ||
68 | { | ||
69 | for (int dy = 0; dy < channelHeight; dy++) | ||
70 | { | ||
71 | bitmap[dx + xoff, dy + yoff] = true; | ||
72 | } | ||
73 | } | ||
74 | |||
75 | raiseFunction.FloodEffect(map, bitmap, height); | ||
76 | } | ||
77 | } | ||
78 | } | ||
79 | } | ||
80 | } \ No newline at end of file | ||