aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment
diff options
context:
space:
mode:
authorAdam Frisby2008-03-03 08:35:59 +0000
committerAdam Frisby2008-03-03 08:35:59 +0000
commitc5d1f87cd202663f2f26ca90a973d9763070dda3 (patch)
treeb1941867d13d1d3b29b46483e6b58cba536c72ca /OpenSim/Region/Environment
parent* Applying Ahzz's profile patch. Thanks Ahzz! (diff)
downloadopensim-SC_OLD-c5d1f87cd202663f2f26ca90a973d9763070dda3.zip
opensim-SC_OLD-c5d1f87cd202663f2f26ca90a973d9763070dda3.tar.gz
opensim-SC_OLD-c5d1f87cd202663f2f26ca90a973d9763070dda3.tar.bz2
opensim-SC_OLD-c5d1f87cd202663f2f26ca90a973d9763070dda3.tar.xz
* Removed and sorted using clauses in a number of files.
* Cleaned up ITerrainChannel * Implemented Raise, Lower, Smooth, Flatten, Noise Terrain Paint Brushes * Implemented Raise, Lower, Smooth, Flatten, Noise Terrain Fill Brushes * Implemented Export functionality for RAW32 terrain loader * Implemented Import/Export for SLRAW terrain loader * Implemented Export for JPEG terrain loader
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r--OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs1
-rw-r--r--OpenSim/Region/Environment/Modules/AgentAssetsTransactions.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/AssetDownloadModule.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/ChatModule.cs1
-rw-r--r--OpenSim/Region/Environment/Modules/FriendsModule.cs9
-rw-r--r--OpenSim/Region/Environment/Modules/GroupsModule.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/InstantMessageModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/SunModule.cs1
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs79
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs132
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs50
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs36
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs73
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs53
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs57
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs31
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs107
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs125
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs65
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs73
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs32
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs130
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs79
-rw-r--r--OpenSim/Region/Environment/Modules/TextureDownloadModule.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/TextureNotFoundSender.cs3
-rw-r--r--OpenSim/Region/Environment/Modules/VoiceChat/VoiceChatServer.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs4
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs11
31 files changed, 1112 insertions, 69 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs
index cc02268..f0d600a 100644
--- a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs
+++ b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs
@@ -26,7 +26,6 @@
26* 26*
27*/ 27*/
28 28
29using System;
30namespace OpenSim.Region.Environment.Interfaces 29namespace OpenSim.Region.Environment.Interfaces
31{ 30{
32 public interface ITerrainChannel 31 public interface ITerrainChannel
@@ -34,5 +33,6 @@ namespace OpenSim.Region.Environment.Interfaces
34 int Height { get; } 33 int Height { get; }
35 double this[int x, int y] { get; set; } 34 double this[int x, int y] { get; set; }
36 int Width { get; } 35 int Width { get; }
36 float[] GetFloatsSerialised();
37 } 37 }
38} 38}
diff --git a/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs
index 99d6db1..492e7b5 100644
--- a/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs
+++ b/OpenSim/Region/Environment/Modules/AgentAssetTransactionModule.cs
@@ -28,7 +28,6 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32using libsecondlife; 31using libsecondlife;
33using Nini.Config; 32using Nini.Config;
34using OpenSim.Framework; 33using OpenSim.Framework;
diff --git a/OpenSim/Region/Environment/Modules/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/AgentAssetsTransactions.cs
index bfca1a2..097fa3e 100644
--- a/OpenSim/Region/Environment/Modules/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/Environment/Modules/AgentAssetsTransactions.cs
@@ -28,11 +28,9 @@
28 28
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Text;
32using System.IO; 31using System.IO;
33using libsecondlife; 32using libsecondlife;
34using libsecondlife.Packets; 33using libsecondlife.Packets;
35using OpenSim.Framework.Servers;
36using OpenSim.Framework; 34using OpenSim.Framework;
37using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
38 36
diff --git a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
index 33c0ce2..74102c2 100644
--- a/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/AssetDownloadModule.cs
@@ -29,12 +29,12 @@
29using System; 29using System;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Threading; 31using System.Threading;
32using libsecondlife;
33using libsecondlife.Packets;
32using Nini.Config; 34using Nini.Config;
33using OpenSim.Framework; 35using OpenSim.Framework;
34using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
36using libsecondlife;
37using libsecondlife.Packets;
38 38
39namespace OpenSim.Region.Environment.Modules 39namespace OpenSim.Region.Environment.Modules
40{ 40{
diff --git a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
index 1551707..7b54634 100644
--- a/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/AvatarFactoryModule.cs
@@ -33,10 +33,9 @@ using libsecondlife;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Data;
37using OpenSim.Region.Environment.Interfaces; 37using OpenSim.Region.Environment.Interfaces;
38using OpenSim.Region.Environment.Scenes; 38using OpenSim.Region.Environment.Scenes;
39using OpenSim.Framework.Data;
40using OpenSim.Framework.Data.Base; 39using OpenSim.Framework.Data.Base;
41 40
42namespace OpenSim.Region.Environment.Modules 41namespace OpenSim.Region.Environment.Modules
diff --git a/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs b/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs
index 649b80e..d53083f 100644
--- a/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs
+++ b/OpenSim/Region/Environment/Modules/BetaGridLikeMoneyModule.cs
@@ -26,15 +26,13 @@
26* 26*
27*/ 27*/
28 28
29using Nini.Config;
30using System; 29using System;
31using System.Collections;
32using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife;
32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
37using libsecondlife;
38using MoneyTransferArgs = OpenSim.Region.Environment.Scenes.EventManager.MoneyTransferArgs; 36using MoneyTransferArgs = OpenSim.Region.Environment.Scenes.EventManager.MoneyTransferArgs;
39 37
40namespace OpenSim.Region.Environment.Modules 38namespace OpenSim.Region.Environment.Modules
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs
index a21aefe..e8d480c 100644
--- a/OpenSim/Region/Environment/Modules/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/ChatModule.cs
@@ -35,7 +35,6 @@ using System.Threading;
35using libsecondlife; 35using libsecondlife;
36using Nini.Config; 36using Nini.Config;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Console;
39using OpenSim.Region.Environment.Interfaces; 38using OpenSim.Region.Environment.Interfaces;
40using OpenSim.Region.Environment.Scenes; 39using OpenSim.Region.Environment.Scenes;
41 40
diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs
index 4d06750..a681bb9 100644
--- a/OpenSim/Region/Environment/Modules/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs
@@ -26,16 +26,13 @@
26* 26*
27*/ 27*/
28 28
29using Nini.Config;
30using System;
31using System.Collections;
32using System.Collections.Generic; 29using System.Collections.Generic;
30using libsecondlife;
31using Nini.Config;
32using Nwc.XmlRpc;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
37using libsecondlife;
38using Nwc.XmlRpc;
39 36
40namespace OpenSim.Region.Environment.Modules 37namespace OpenSim.Region.Environment.Modules
41{ 38{
diff --git a/OpenSim/Region/Environment/Modules/GroupsModule.cs b/OpenSim/Region/Environment/Modules/GroupsModule.cs
index 2d8efce..b8980a0 100644
--- a/OpenSim/Region/Environment/Modules/GroupsModule.cs
+++ b/OpenSim/Region/Environment/Modules/GroupsModule.cs
@@ -26,15 +26,13 @@
26* 26*
27*/ 27*/
28 28
29using Nini.Config;
30using System; 29using System;
31using System.Collections;
32using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife;
32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
37using libsecondlife;
38 36
39namespace OpenSim.Region.Environment.Modules 37namespace OpenSim.Region.Environment.Modules
40{ 38{
diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
index 70f3d99..425e275 100644
--- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
+++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
@@ -30,9 +30,7 @@ using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife; 31using libsecondlife;
32using Nini.Config; 32using Nini.Config;
33using Nwc.XmlRpc;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
38 36
diff --git a/OpenSim/Region/Environment/Modules/SunModule.cs b/OpenSim/Region/Environment/Modules/SunModule.cs
index fb80f68..4895a0f 100644
--- a/OpenSim/Region/Environment/Modules/SunModule.cs
+++ b/OpenSim/Region/Environment/Modules/SunModule.cs
@@ -31,7 +31,6 @@ using System.Collections.Generic;
31using libsecondlife; 31using libsecondlife;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
37 36
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs
new file mode 100644
index 0000000..57e6cd8
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/JPEG.cs
@@ -0,0 +1,79 @@
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*/
28using System;
29using System.IO;
30using System.Drawing;
31using OpenSim.Region.Environment.Interfaces;
32
33namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
34{
35 public class JPEG : ITerrainLoader
36 {
37 #region ITerrainLoader Members
38
39 public ITerrainChannel LoadFile(string filename)
40 {
41 throw new NotImplementedException();
42 }
43
44 private Bitmap CreateBitmapFromMap(ITerrainChannel map)
45 {
46 Bitmap gradientmapLd = new Bitmap("defaultstripe.png");
47
48 int pallete = gradientmapLd.Height;
49
50 Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
51 Color[] colours = new Color[pallete];
52
53 for (int i = 0; i < pallete; i++)
54 {
55 colours[i] = gradientmapLd.GetPixel(0, i);
56 }
57
58 for (int y = 0; y < copy.h; y++)
59 {
60 for (int x = 0; x < copy.w; x++)
61 {
62 // 512 is the largest possible height before colours clamp
63 int colorindex = (int)(Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1));
64 bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]);
65 }
66 }
67 return bmp;
68 }
69
70 public void SaveFile(string filename, ITerrainChannel map)
71 {
72 Bitmap colours = CreateBitmapFromMap(map);
73
74 colours.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg);
75 }
76
77 #endregion
78 }
79} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs
new file mode 100644
index 0000000..58dc6c7
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/LLRAW.cs
@@ -0,0 +1,132 @@
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*/
28using System;
29using System.IO;
30using OpenSim.Region.Environment.Interfaces;
31
32namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
33{
34 public class LLRAW : ITerrainLoader
35 {
36 #region ITerrainLoader Members
37
38 public ITerrainChannel LoadFile(string filename)
39 {
40 TerrainChannel retval = new TerrainChannel();
41
42 FileInfo file = new FileInfo(filename);
43 FileStream s = file.Open(FileMode.Open, FileAccess.Read);
44 BinaryReader bs = new BinaryReader(s);
45 int x, y;
46 for (y = 0; y < retval.Height; y++)
47 {
48 for (x = 0; x < retval.Width; x++)
49 {
50 retval[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0);
51 bs.ReadBytes(11); // Advance the stream to next bytes.
52 }
53 }
54
55 bs.Close();
56 s.Close();
57
58 return retval;
59 }
60
61 public void SaveFile(string filename, ITerrainChannel map)
62 {
63 FileInfo file = new FileInfo(filename);
64 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
65 BinaryWriter binStream = new BinaryWriter(s);
66
67 // Generate a smegging big lookup table to speed the operation up (it needs it)
68 double[] lookupHeightTable = new double[65536];
69 int i, j, x, y;
70 for (i = 0; i < 256; i++)
71 {
72 for (j = 0; j < 256; j++)
73 {
74 lookupHeightTable[i + (j * 256)] = ((double)i * ((double)j / 127.0));
75 }
76 }
77
78 // Output the calculated raw
79 for (y = 0; y < map.Height; y++)
80 {
81 for (x = 0; x < map.Width; x++)
82 {
83 double t = map[x, y];
84 double min = double.MaxValue;
85 int index = 0;
86
87 for (i = 0; i < 65536; i++)
88 {
89 if (Math.Abs(t - lookupHeightTable[i]) < min)
90 {
91 min = Math.Abs(t - lookupHeightTable[i]);
92 index = i;
93 }
94 }
95
96 byte red = (byte)(index & 0xFF);
97 byte green = (byte)((index >> 8) & 0xFF);
98 byte blue = 20;
99 byte alpha1 = 0; // Land Parcels
100 byte alpha2 = 0; // For Sale Land
101 byte alpha3 = 0; // Public Edit Object
102 byte alpha4 = 0; // Public Edit Land
103 byte alpha5 = 255; // Safe Land
104 byte alpha6 = 255; // Flying Allowed
105 byte alpha7 = 255; // Create Landmark
106 byte alpha8 = 255; // Outside Scripts
107 byte alpha9 = red;
108 byte alpha10 = green;
109
110 binStream.Write(red);
111 binStream.Write(green);
112 binStream.Write(blue);
113 binStream.Write(alpha1);
114 binStream.Write(alpha2);
115 binStream.Write(alpha3);
116 binStream.Write(alpha4);
117 binStream.Write(alpha5);
118 binStream.Write(alpha6);
119 binStream.Write(alpha7);
120 binStream.Write(alpha8);
121 binStream.Write(alpha9);
122 binStream.Write(alpha10);
123 }
124 }
125
126 binStream.Close();
127 s.Close();
128 }
129
130 #endregion
131 }
132}
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs
index bf716c5..d69d62a 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/RAW32.cs
@@ -1,8 +1,32 @@
1using System; 1/*
2using System.Collections.Generic; 2* Copyright (c) Contributors, http://opensimulator.org/
3using System.Text; 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*/
28using System;
4using System.IO; 29using System.IO;
5using OpenSim.Region.Environment.Modules.Terrain;
6using OpenSim.Region.Environment.Interfaces; 30using OpenSim.Region.Environment.Interfaces;
7 31
8namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders 32namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
@@ -33,9 +57,23 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
33 return retval; 57 return retval;
34 } 58 }
35 59
36 public void SaveFile(string filename) 60 public void SaveFile(string filename, ITerrainChannel map)
37 { 61 {
38 throw new NotImplementedException(); 62 FileInfo file = new FileInfo(filename);
63 FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
64 BinaryWriter bs = new BinaryWriter(s);
65
66 int x, y;
67 for (y = 0; y < h; y++)
68 {
69 for (x = 0; x < w; x++)
70 {
71 bs.Write((float)map[x, y]);
72 }
73 }
74
75 bs.Close();
76 s.Close();
39 } 77 }
40 78
41 #endregion 79 #endregion
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs
index b12d99f..d93400f 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FileLoaders/Terragen.cs
@@ -1,8 +1,33 @@
1using System; 1/*
2using System.Collections.Generic; 2* Copyright (c) Contributors, http://opensimulator.org/
3using System.Text; 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*/
28using System;
4using System.IO; 29using System.IO;
5using OpenSim.Region.Environment.Modules.Terrain; 30using System.Text;
6using OpenSim.Region.Environment.Interfaces; 31using OpenSim.Region.Environment.Interfaces;
7 32
8namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders 33namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
@@ -79,8 +104,9 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
79 return retval; 104 return retval;
80 } 105 }
81 106
82 public void SaveFile(string filename) 107 public void SaveFile(string filename, ITerrainChannel map)
83 { 108 {
109 char[] header = "TERRAGENTERRAIN".ToCharArray();
84 throw new NotImplementedException(); 110 throw new NotImplementedException();
85 } 111 }
86 112
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs
new file mode 100644
index 0000000..d022fbe
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs
@@ -0,0 +1,73 @@
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*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Region.Environment.Modules.Terrain;
32using OpenSim.Region.Environment.Interfaces;
33
34namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
35{
36 public class FlattenArea : ITerrainFloodEffect
37 {
38 #region ITerrainFloodEffect Members
39
40 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
41 {
42 double sum = 0.0;
43 double steps = 0.0;
44 double avg = 0.0;
45
46 int x, y;
47 for (x = 0; x < map.Width; x++)
48 {
49 for (y = 0; y < map.Height; y++)
50 {
51 if (fillArea[x, y] == true)
52 {
53 sum += map[x, y];
54 steps += 1.0;
55 }
56 }
57 }
58
59 avg = sum / steps;
60
61 for (x = 0; x < map.Width; x++)
62 {
63 for (y = 0; y < map.Height; y++)
64 {
65 if (fillArea[x, y] == true)
66 map[x, y] = avg;
67 }
68 }
69 }
70
71 #endregion
72 }
73}
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs
new file mode 100644
index 0000000..1706575
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs
@@ -0,0 +1,53 @@
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*/
28using OpenSim.Region.Environment.Interfaces;
29
30namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
31{
32 public class LowerArea : ITerrainFloodEffect
33 {
34 #region ITerrainFloodEffect Members
35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
37 {
38 int x, y;
39 for (x = 0; x < map.Width; x++)
40 {
41 for (y = 0; y < map.Height; y++)
42 {
43 if (fillArea[x, y] == true)
44 {
45 map[x, y] -= strength;
46 }
47 }
48 }
49 }
50
51 #endregion
52 }
53}
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs
new file mode 100644
index 0000000..690ca53
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs
@@ -0,0 +1,57 @@
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*/
28using OpenSim.Region.Environment.Interfaces;
29
30namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
31{
32 public class NoiseArea : ITerrainFloodEffect
33 {
34 #region ITerrainFloodEffect Members
35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
37 {
38 int x, y;
39 for (x = 0; x < map.Width; x++)
40 {
41 for (y = 0; y < map.Height; y++)
42 {
43 if (fillArea[x, y] == true)
44 {
45 lock (OpenSim.Framework.Util.RandomClass)
46 {
47 double noise = OpenSim.Framework.Util.RandomClass.NextDouble();
48 map[x, y] += (noise - 0.5) * strength;
49 }
50 }
51 }
52 }
53 }
54
55 #endregion
56 }
57}
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs
index 258b363..aad7aa4 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs
@@ -1,7 +1,30 @@
1using System; 1/*
2using System.Collections.Generic; 2* Copyright (c) Contributors, http://opensimulator.org/
3using System.Text; 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4using OpenSim.Region.Environment.Modules.Terrain; 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*/
5using OpenSim.Region.Environment.Interfaces; 28using OpenSim.Region.Environment.Interfaces;
6 29
7namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes 30namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs
new file mode 100644
index 0000000..aa685e4
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs
@@ -0,0 +1,107 @@
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*/
28using OpenSim.Region.Environment.Interfaces;
29
30namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
31{
32 public class SmoothArea : ITerrainFloodEffect
33 {
34 private double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
35 {
36 int w = map.Width;
37 int h = map.Height;
38
39 if (x > w - 2.0)
40 x = w - 2.0;
41 if (y > h - 2.0)
42 y = h - 2.0;
43 if (x < 0.0)
44 x = 0.0;
45 if (y < 0.0)
46 y = 0.0;
47
48 int stepSize = 1;
49 double h00 = map[(int)x, (int)y];
50 double h10 = map[(int)x + stepSize, (int)y];
51 double h01 = map[(int)x, (int)y + stepSize];
52 double h11 = map[(int)x + stepSize, (int)y + stepSize];
53 double h1 = h00;
54 double h2 = h10;
55 double h3 = h01;
56 double h4 = h11;
57 double a00 = h1;
58 double a10 = h2 - h1;
59 double a01 = h3 - h1;
60 double a11 = h1 - h2 - h3 + h4;
61 double partialx = x - (int)x;
62 double partialz = y - (int)y;
63 double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
64 return hi;
65 }
66
67 #region ITerrainFloodEffect Members
68
69 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
70 {
71 double area = strength;
72 double step = strength / 4.0;
73
74 double[,] manipulate = new double[map.Width, map.Height];
75 int x, y;
76 double n, l;
77 for (x = 0; x < map.Width; x++)
78 {
79 for (y = 0; y < map.Height; y++)
80 {
81 double average = 0.0;
82 int avgsteps = 0;
83
84 for (n = 0.0 - area; n < area; n += step)
85 {
86 for (l = 0.0 - area; l < area; l += step)
87 {
88 avgsteps++;
89 average += GetBilinearInterpolate(x + n, y + l, map);
90 }
91 }
92
93 manipulate[x, y] = average / avgsteps;
94 }
95 }
96 for (x = 0; x < map.Width; x++)
97 {
98 for (y = 0; y < map.Height; y++)
99 {
100 map[x, y] = manipulate[x, y];
101 }
102 }
103 }
104
105 #endregion
106 }
107} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs
new file mode 100644
index 0000000..d2cf1bc
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/FlattenSphere.cs
@@ -0,0 +1,125 @@
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*/
28using OpenSim.Region.Environment.Interfaces;
29
30namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
31{
32 public class FlattenSphere : ITerrainPaintableEffect
33 {
34 private double SphericalFactor(double x, double y, double rx, double ry, double size)
35 {
36 double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry));
37 return z;
38 }
39
40 private double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
41 {
42 int w = map.Width;
43 int h = map.Height;
44
45 if (x > w - 2.0)
46 x = w - 2.0;
47 if (y > h - 2.0)
48 y = h - 2.0;
49 if (x < 0.0)
50 x = 0.0;
51 if (y < 0.0)
52 y = 0.0;
53
54 int stepSize = 1;
55 double h00 = map[(int)x, (int)y];
56 double h10 = map[(int)x + stepSize, (int)y];
57 double h01 = map[(int)x, (int)y + stepSize];
58 double h11 = map[(int)x + stepSize, (int)y + stepSize];
59 double h1 = h00;
60 double h2 = h10;
61 double h3 = h01;
62 double h4 = h11;
63 double a00 = h1;
64 double a10 = h2 - h1;
65 double a01 = h3 - h1;
66 double a11 = h1 - h2 - h3 + h4;
67 double partialx = x - (int)x;
68 double partialz = y - (int)y;
69 double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
70 return hi;
71 }
72
73 #region ITerrainPaintableEffect Members
74
75 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
76 {
77 int x, y;
78 double[,] tweak = new double[map.Width, map.Height];
79
80 double n, l;
81 double area = strength;
82 double step = strength / 4.0;
83
84 double sum = 0.0;
85 double step2 = 0.0;
86 double avg = 0.0;
87
88 // compute delta map
89 for (x = 0; x < map.Width; x++)
90 {
91 for (y = 0; y < map.Height; y++)
92 {
93 double z = SphericalFactor(x, y, rx, ry, strength);
94
95 if (z > 0) // add in non-zero amount
96 {
97 sum += map[x, y] * z;
98 step2 += z;
99 }
100 }
101 }
102
103 avg = sum / step2;
104
105 // blend in map
106 for (x = 0; x < map.Width; x++)
107 {
108 for (y = 0; y < map.Height; y++)
109 {
110 double z = SphericalFactor(x, y, rx, ry, strength);
111
112 if (z > 0) // add in non-zero amount
113 {
114 if (z > 1.0)
115 z = 1.0;
116
117 map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z);
118 }
119 }
120 }
121 }
122
123 #endregion
124 }
125} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs
new file mode 100644
index 0000000..4a05e76
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/LowerSphere.cs
@@ -0,0 +1,65 @@
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*/
28using System;
29using OpenSim.Region.Environment.Interfaces;
30
31namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
32{
33 public class LowerSphere : ITerrainPaintableEffect
34 {
35 #region ITerrainPaintableEffect Members
36
37 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
38 {
39 int x, y;
40 for (x = 0; x < map.Width; x++)
41 {
42 // Skip everything unlikely to be affected
43 if (Math.Abs(x - rx) > strength * 1.1)
44 continue;
45
46 for (y = 0; y < map.Height; y++)
47 {
48 // Skip everything unlikely to be affected
49 if (Math.Abs(y - ry) > strength * 1.1)
50 continue;
51
52 // Calculate a sphere and add it to the heighmap
53 double z = strength;
54 z *= z;
55 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
56
57 if (z > 0.0)
58 map[x, y] -= z;
59 }
60 }
61 }
62
63 #endregion
64 }
65}
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs
new file mode 100644
index 0000000..226bd3e
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/NoiseSphere.cs
@@ -0,0 +1,73 @@
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*/
28using System;
29using OpenSim.Framework;
30using OpenSim.Region.Environment.Interfaces;
31
32namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
33{
34 public class NoiseSphere : ITerrainPaintableEffect
35 {
36 #region ITerrainPaintableEffect Members
37
38 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
39 {
40 int x, y;
41 for (x = 0; x < map.Width; x++)
42 {
43 // Skip everything unlikely to be affected
44 if (Math.Abs(x - rx) > strength * 1.1)
45 continue;
46
47 for (y = 0; y < map.Height; y++)
48 {
49 // Skip everything unlikely to be affected
50 if (Math.Abs(y - ry) > strength * 1.1)
51 continue;
52
53 // Calculate a sphere and add it to the heighmap
54 double z = strength;
55 z *= z;
56 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
57
58 double noise;
59
60 lock (Util.RandomClass)
61 {
62 noise = Util.RandomClass.NextDouble();
63 }
64
65 if (z > 0.0)
66 map[x, y] += (noise - 0.5) * z;
67 }
68 }
69 }
70
71 #endregion
72 }
73}
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs
index ff7ec0b..fad5b11 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RaiseSphere.cs
@@ -1,7 +1,31 @@
1using System; 1/*
2using System.Collections.Generic; 2* Copyright (c) Contributors, http://opensimulator.org/
3using System.Text; 3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4using OpenSim.Region.Environment.Modules.Terrain; 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*/
28using System;
5using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
6 30
7namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes 31namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs
new file mode 100644
index 0000000..076b3cc
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/SmoothSphere.cs
@@ -0,0 +1,130 @@
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*/
28using OpenSim.Region.Environment.Interfaces;
29
30namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
31{
32 public class SmoothSphere : ITerrainPaintableEffect
33 {
34 private double SphericalFactor(double x, double y, double rx, double ry, double size)
35 {
36 double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry));
37 return z;
38 }
39
40 private double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
41 {
42 int w = map.Width;
43 int h = map.Height;
44
45 if (x > w - 2.0)
46 x = w - 2.0;
47 if (y > h - 2.0)
48 y = h - 2.0;
49 if (x < 0.0)
50 x = 0.0;
51 if (y < 0.0)
52 y = 0.0;
53
54 int stepSize = 1;
55 double h00 = map[(int)x, (int)y];
56 double h10 = map[(int)x + stepSize, (int)y];
57 double h01 = map[(int)x, (int)y + stepSize];
58 double h11 = map[(int)x + stepSize, (int)y + stepSize];
59 double h1 = h00;
60 double h2 = h10;
61 double h3 = h01;
62 double h4 = h11;
63 double a00 = h1;
64 double a10 = h2 - h1;
65 double a01 = h3 - h1;
66 double a11 = h1 - h2 - h3 + h4;
67 double partialx = x - (int)x;
68 double partialz = y - (int)y;
69 double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
70 return hi;
71 }
72
73 #region ITerrainPaintableEffect Members
74
75 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
76 {
77 int x, y;
78 double[,] tweak = new double[map.Width, map.Height];
79
80 double n, l;
81 double area = strength;
82 double step = strength / 4.0;
83
84 // compute delta map
85 for (x = 0; x < map.Width; x++)
86 {
87 for (y = 0; y < map.Height; y++)
88 {
89 double z = SphericalFactor(x, y, rx, ry, strength);
90
91 if (z > 0) // add in non-zero amount
92 {
93 double average = 0.0;
94 int avgsteps = 0;
95
96 for (n = 0.0 - area; n < area; n += step)
97 {
98 for (l = 0.0 - area; l < area; l += step)
99 {
100 avgsteps++;
101 average += GetBilinearInterpolate(x + n, y + l, map);
102 }
103 }
104 tweak[x, y] = average / avgsteps;
105 }
106 }
107 }
108 // blend in map
109 for (x = 0; x < map.Width; x++)
110 {
111 for (y = 0; y < map.Height; y++)
112 {
113 double z = SphericalFactor(x, y, rx, ry, strength);
114
115 if (z > 0) // add in non-zero amount
116 {
117 double da = z;
118 double a = (map[x, y] - tweak[x, y]) * da;
119 double newz = map[x, y] - a;
120
121 if (newz > 0.0)
122 map[x, y] = newz;
123 }
124 }
125 }
126 }
127
128 #endregion
129 }
130} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
index 22b5fd9..1542230 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
@@ -26,16 +26,13 @@
26* 26*
27*/ 27*/
28 28
29using Nini.Config;
30using System; 29using System;
31using System.Collections;
32using System.Collections.Generic; 30using System.Collections.Generic;
31using libsecondlife;
32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Console;
35using OpenSim.Region.Environment.Modules;
36using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
38using libsecondlife;
39 36
40namespace OpenSim.Region.Environment.Modules.Terrain 37namespace OpenSim.Region.Environment.Modules.Terrain
41{ 38{
@@ -57,7 +54,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
57 public interface ITerrainLoader 54 public interface ITerrainLoader
58 { 55 {
59 ITerrainChannel LoadFile(string filename); 56 ITerrainChannel LoadFile(string filename);
60 void SaveFile(string filename); 57 void SaveFile(string filename, ITerrainChannel map);
61 } 58 }
62 59
63 /// <summary> 60 /// <summary>
@@ -85,6 +82,19 @@ namespace OpenSim.Region.Environment.Modules.Terrain
85 return copy; 82 return copy;
86 } 83 }
87 84
85 public float[] GetFloatsSerialised()
86 {
87 float[] heights = new float[Width * Height];
88 int i;
89
90 for (i = 0; i < Width * Height; i++)
91 {
92 heights[i] = (float)map[i % Width, i / Width];
93 }
94
95 return heights;
96 }
97
88 public double this[int x, int y] 98 public double this[int x, int y]
89 { 99 {
90 get 100 get
@@ -102,6 +112,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain
102 map = new double[Constants.RegionSize, Constants.RegionSize]; 112 map = new double[Constants.RegionSize, Constants.RegionSize];
103 } 113 }
104 114
115 public TerrainChannel(double[,] import)
116 {
117 map = import;
118 }
119
105 public TerrainChannel(bool createMap) 120 public TerrainChannel(bool createMap)
106 { 121 {
107 if (createMap) 122 if (createMap)
@@ -139,13 +154,27 @@ namespace OpenSim.Region.Environment.Modules.Terrain
139 154
140 private void InstallDefaultEffects() 155 private void InstallDefaultEffects()
141 { 156 {
142 m_painteffects[StandardTerrainEffects.Raise] = new PaintBrushes.RaiseSphere(); 157 // Draggable Paint Brush Effects
143 m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea(); 158 m_painteffects[StandardTerrainEffects.Raise] = new PaintBrushes.RaiseSphere();
144 159 m_painteffects[StandardTerrainEffects.Lower] = new PaintBrushes.LowerSphere();
145 // Float[256,256] array format (RAW32) 160 m_painteffects[StandardTerrainEffects.Smooth] = new PaintBrushes.SmoothSphere();
161 m_painteffects[StandardTerrainEffects.Noise] = new PaintBrushes.NoiseSphere();
162 m_painteffects[StandardTerrainEffects.Flatten] = new PaintBrushes.FlattenSphere();
163
164 // Area of effect selection effects
165 m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea();
166 m_floodeffects[StandardTerrainEffects.Lower] = new FloodBrushes.LowerArea();
167 m_floodeffects[StandardTerrainEffects.Smooth] = new FloodBrushes.SmoothArea();
168 m_floodeffects[StandardTerrainEffects.Noise] = new FloodBrushes.NoiseArea();
169 m_floodeffects[StandardTerrainEffects.Flatten] = new FloodBrushes.FlattenArea();
170
171 // Filesystem load/save loaders
146 m_loaders[".r32"] = new FileLoaders.RAW32(); 172 m_loaders[".r32"] = new FileLoaders.RAW32();
147 m_loaders[".f32"] = m_loaders[".r32"]; 173 m_loaders[".f32"] = m_loaders[".r32"];
148 m_loaders[".ter"] = new FileLoaders.Terragen(); 174 m_loaders[".ter"] = new FileLoaders.Terragen();
175 m_loaders[".raw"] = new FileLoaders.LLRAW();
176 m_loaders[".jpg"] = new FileLoaders.JPEG();
177 m_loaders[".jpeg"] = m_loaders[".jpg"];
149 } 178 }
150 179
151 public void LoadFromFile(string filename) 180 public void LoadFromFile(string filename)
@@ -162,14 +191,21 @@ namespace OpenSim.Region.Environment.Modules.Terrain
162 191
163 public void SaveToFile(string filename) 192 public void SaveToFile(string filename)
164 { 193 {
165 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) 194 try
166 { 195 {
167 if (filename.EndsWith(loader.Key)) 196 foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
168 { 197 {
169 loader.Value.SaveFile(filename); 198 if (filename.EndsWith(loader.Key))
170 return; 199 {
200 loader.Value.SaveFile(filename, m_channel);
201 return;
202 }
171 } 203 }
172 } 204 }
205 catch (NotImplementedException)
206 {
207 m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented.");
208 }
173 } 209 }
174 210
175 public void Initialise(Scene scene, IConfigSource config) 211 public void Initialise(Scene scene, IConfigSource config)
@@ -177,7 +213,20 @@ namespace OpenSim.Region.Environment.Modules.Terrain
177 m_scene = scene; 213 m_scene = scene;
178 m_gConfig = config; 214 m_gConfig = config;
179 215
180 m_channel = new TerrainChannel(); 216 // Install terrain module in the simulator
217 if (m_scene.Heightmap == null)
218 {
219 lock (m_scene)
220 {
221 m_channel = new TerrainChannel();
222 m_scene.Heightmap = m_channel;
223 }
224 }
225 else
226 {
227 m_channel = m_scene.Heightmap;
228 }
229
181 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 230 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
182 } 231 }
183 232
diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
index 2b2ac42..a015b5d 100644
--- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs
@@ -29,10 +29,8 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading; 30using System.Threading;
31using libsecondlife; 31using libsecondlife;
32using libsecondlife.Packets;
33using Nini.Config; 32using Nini.Config;
34using OpenSim.Framework; 33using OpenSim.Framework;
35using OpenSim.Framework.Console;
36using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
38 36
diff --git a/OpenSim/Region/Environment/Modules/TextureNotFoundSender.cs b/OpenSim/Region/Environment/Modules/TextureNotFoundSender.cs
index f85e900..7d39c0d 100644
--- a/OpenSim/Region/Environment/Modules/TextureNotFoundSender.cs
+++ b/OpenSim/Region/Environment/Modules/TextureNotFoundSender.cs
@@ -7,11 +7,8 @@
7 * To change this template use Tools | Options | Coding | Edit Standard Headers. 7 * To change this template use Tools | Options | Coding | Edit Standard Headers.
8 */ 8 */
9 9
10using System;
11
12using libsecondlife; 10using libsecondlife;
13using libsecondlife.Packets; 11using libsecondlife.Packets;
14
15using OpenSim.Framework; 12using OpenSim.Framework;
16using OpenSim.Region.Environment.Interfaces; 13using OpenSim.Region.Environment.Interfaces;
17 14
diff --git a/OpenSim/Region/Environment/Modules/VoiceChat/VoiceChatServer.cs b/OpenSim/Region/Environment/Modules/VoiceChat/VoiceChatServer.cs
index 5ec0ca8..3ace5fc 100644
--- a/OpenSim/Region/Environment/Modules/VoiceChat/VoiceChatServer.cs
+++ b/OpenSim/Region/Environment/Modules/VoiceChat/VoiceChatServer.cs
@@ -261,7 +261,7 @@ namespace OpenSim.Region.Environment.Modules.VoiceChat
261 } 261 }
262 } 262 }
263 } 263 }
264 catch(ObjectDisposedException e) 264 catch(ObjectDisposedException)
265 { 265 {
266 m_log.Warn("[VOICECHAT]: Connection has been already closed"); 266 m_log.Warn("[VOICECHAT]: Connection has been already closed");
267 } 267 }
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index a20e466..845de22 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -31,14 +31,12 @@ using System.Drawing;
31using System.Drawing.Imaging; 31using System.Drawing.Imaging;
32using System.Threading; 32using System.Threading;
33using System.Timers; 33using System.Timers;
34using Axiom.Math;
35using libsecondlife; 34using libsecondlife;
36using libsecondlife.Packets; 35using libsecondlife.Packets;
37using OpenJPEGNet; 36using OpenJPEGNet;
38using OpenSim.Framework; 37using OpenSim.Framework;
39using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Cache; 39using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Console;
42using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
43using OpenSim.Region.Environment.Interfaces; 41using OpenSim.Region.Environment.Interfaces;
44using OpenSim.Region.Environment.LandManagement; 42using OpenSim.Region.Environment.LandManagement;
@@ -1002,6 +1000,8 @@ namespace OpenSim.Region.Environment.Scenes
1002 } 1000 }
1003 else 1001 else
1004 { 1002 {
1003 // TODO: Install 'GetDefaultTerrainProvider' method here?
1004 Heightmap = new Modules.Terrain.TerrainChannel(map);
1005 Terrain.SetHeights2D(map); 1005 Terrain.SetHeights2D(map);
1006 } 1006 }
1007 1007
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index 3f7edfb..2a2dea1 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -112,7 +112,16 @@ namespace OpenSim.Region.Environment.Scenes
112 /// <param name="RemoteClient">Client to send to</param> 112 /// <param name="RemoteClient">Client to send to</param>
113 public virtual void SendLayerData(IClientAPI RemoteClient) 113 public virtual void SendLayerData(IClientAPI RemoteClient)
114 { 114 {
115 RemoteClient.SendLayerData(Terrain.GetHeights1D()); 115 bool usingTerrainModule = false;
116
117 if (usingTerrainModule)
118 {
119 RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised());
120 }
121 else
122 {
123 RemoteClient.SendLayerData(Terrain.GetHeights1D());
124 }
116 } 125 }
117 126
118 #endregion 127 #endregion