* 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
0.6.0-stable
Adam Frisby 2008-03-03 08:35:59 +00:00
parent fe49c96ee0
commit c5d1f87cd2
31 changed files with 1111 additions and 68 deletions

View File

@ -26,7 +26,6 @@
* *
*/ */
using System;
namespace OpenSim.Region.Environment.Interfaces namespace OpenSim.Region.Environment.Interfaces
{ {
public interface ITerrainChannel public interface ITerrainChannel
@ -34,5 +33,6 @@ namespace OpenSim.Region.Environment.Interfaces
int Height { get; } int Height { get; }
double this[int x, int y] { get; set; } double this[int x, int y] { get; set; }
int Width { get; } int Width { get; }
float[] GetFloatsSerialised();
} }
} }

View File

@ -28,7 +28,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;

View File

@ -28,11 +28,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text;
using System.IO; using System.IO;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework.Servers;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;

View File

@ -29,12 +29,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using libsecondlife;
using libsecondlife.Packets;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using libsecondlife;
using libsecondlife.Packets;
namespace OpenSim.Region.Environment.Modules namespace OpenSim.Region.Environment.Modules
{ {

View File

@ -33,10 +33,9 @@ using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console; using OpenSim.Framework.Data;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using OpenSim.Framework.Data;
using OpenSim.Framework.Data.Base; using OpenSim.Framework.Data.Base;
namespace OpenSim.Region.Environment.Modules namespace OpenSim.Region.Environment.Modules

View File

@ -26,15 +26,13 @@
* *
*/ */
using Nini.Config;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using libsecondlife;
using MoneyTransferArgs = OpenSim.Region.Environment.Scenes.EventManager.MoneyTransferArgs; using MoneyTransferArgs = OpenSim.Region.Environment.Scenes.EventManager.MoneyTransferArgs;
namespace OpenSim.Region.Environment.Modules namespace OpenSim.Region.Environment.Modules

View File

@ -35,7 +35,6 @@ using System.Threading;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;

View File

@ -26,16 +26,13 @@
* *
*/ */
using Nini.Config;
using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife;
using Nini.Config;
using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using libsecondlife;
using Nwc.XmlRpc;
namespace OpenSim.Region.Environment.Modules namespace OpenSim.Region.Environment.Modules
{ {

View File

@ -26,15 +26,13 @@
* *
*/ */
using Nini.Config;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using libsecondlife;
namespace OpenSim.Region.Environment.Modules namespace OpenSim.Region.Environment.Modules
{ {

View File

@ -30,9 +30,7 @@ using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using Nwc.XmlRpc;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;

View File

@ -31,7 +31,6 @@ using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;

View File

@ -0,0 +1,79 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
using System.Drawing;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
{
public class JPEG : ITerrainLoader
{
#region ITerrainLoader Members
public ITerrainChannel LoadFile(string filename)
{
throw new NotImplementedException();
}
private Bitmap CreateBitmapFromMap(ITerrainChannel map)
{
Bitmap gradientmapLd = new Bitmap("defaultstripe.png");
int pallete = gradientmapLd.Height;
Bitmap bmp = new Bitmap(heightmap.w, heightmap.h);
Color[] colours = new Color[pallete];
for (int i = 0; i < pallete; i++)
{
colours[i] = gradientmapLd.GetPixel(0, i);
}
for (int y = 0; y < copy.h; y++)
{
for (int x = 0; x < copy.w; x++)
{
// 512 is the largest possible height before colours clamp
int colorindex = (int)(Math.Max(Math.Min(1.0, map[x, y] / 512.0), 0.0) * (pallete - 1));
bmp.SetPixel(x, map.Height - y - 1, colours[colorindex]);
}
}
return bmp;
}
public void SaveFile(string filename, ITerrainChannel map)
{
Bitmap colours = CreateBitmapFromMap(map);
colours.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg);
}
#endregion
}
}

View File

@ -0,0 +1,132 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
{
public class LLRAW : ITerrainLoader
{
#region ITerrainLoader Members
public ITerrainChannel LoadFile(string filename)
{
TerrainChannel retval = new TerrainChannel();
FileInfo file = new FileInfo(filename);
FileStream s = file.Open(FileMode.Open, FileAccess.Read);
BinaryReader bs = new BinaryReader(s);
int x, y;
for (y = 0; y < retval.Height; y++)
{
for (x = 0; x < retval.Width; x++)
{
retval[x, y] = (double)bs.ReadByte() * ((double)bs.ReadByte() / 127.0);
bs.ReadBytes(11); // Advance the stream to next bytes.
}
}
bs.Close();
s.Close();
return retval;
}
public void SaveFile(string filename, ITerrainChannel map)
{
FileInfo file = new FileInfo(filename);
FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
BinaryWriter binStream = new BinaryWriter(s);
// Generate a smegging big lookup table to speed the operation up (it needs it)
double[] lookupHeightTable = new double[65536];
int i, j, x, y;
for (i = 0; i < 256; i++)
{
for (j = 0; j < 256; j++)
{
lookupHeightTable[i + (j * 256)] = ((double)i * ((double)j / 127.0));
}
}
// Output the calculated raw
for (y = 0; y < map.Height; y++)
{
for (x = 0; x < map.Width; x++)
{
double t = map[x, y];
double min = double.MaxValue;
int index = 0;
for (i = 0; i < 65536; i++)
{
if (Math.Abs(t - lookupHeightTable[i]) < min)
{
min = Math.Abs(t - lookupHeightTable[i]);
index = i;
}
}
byte red = (byte)(index & 0xFF);
byte green = (byte)((index >> 8) & 0xFF);
byte blue = 20;
byte alpha1 = 0; // Land Parcels
byte alpha2 = 0; // For Sale Land
byte alpha3 = 0; // Public Edit Object
byte alpha4 = 0; // Public Edit Land
byte alpha5 = 255; // Safe Land
byte alpha6 = 255; // Flying Allowed
byte alpha7 = 255; // Create Landmark
byte alpha8 = 255; // Outside Scripts
byte alpha9 = red;
byte alpha10 = green;
binStream.Write(red);
binStream.Write(green);
binStream.Write(blue);
binStream.Write(alpha1);
binStream.Write(alpha2);
binStream.Write(alpha3);
binStream.Write(alpha4);
binStream.Write(alpha5);
binStream.Write(alpha6);
binStream.Write(alpha7);
binStream.Write(alpha8);
binStream.Write(alpha9);
binStream.Write(alpha10);
}
}
binStream.Close();
s.Close();
}
#endregion
}
}

View File

@ -1,8 +1,32 @@
using System; /*
using System.Collections.Generic; * Copyright (c) Contributors, http://opensimulator.org/
using System.Text; * See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO; using System.IO;
using OpenSim.Region.Environment.Modules.Terrain;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
@ -33,9 +57,23 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
return retval; return retval;
} }
public void SaveFile(string filename) public void SaveFile(string filename, ITerrainChannel map)
{ {
throw new NotImplementedException(); FileInfo file = new FileInfo(filename);
FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write);
BinaryWriter bs = new BinaryWriter(s);
int x, y;
for (y = 0; y < h; y++)
{
for (x = 0; x < w; x++)
{
bs.Write((float)map[x, y]);
}
}
bs.Close();
s.Close();
} }
#endregion #endregion

View File

@ -1,8 +1,33 @@
using System; /*
using System.Collections.Generic; * Copyright (c) Contributors, http://opensimulator.org/
using System.Text; * See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.IO; using System.IO;
using OpenSim.Region.Environment.Modules.Terrain; using System.Text;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
@ -79,8 +104,9 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FileLoaders
return retval; return retval;
} }
public void SaveFile(string filename) public void SaveFile(string filename, ITerrainChannel map)
{ {
char[] header = "TERRAGENTERRAIN".ToCharArray();
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Environment.Modules.Terrain;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
{
public class FlattenArea : ITerrainFloodEffect
{
#region ITerrainFloodEffect Members
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
{
double sum = 0.0;
double steps = 0.0;
double avg = 0.0;
int x, y;
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
if (fillArea[x, y] == true)
{
sum += map[x, y];
steps += 1.0;
}
}
}
avg = sum / steps;
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
if (fillArea[x, y] == true)
map[x, y] = avg;
}
}
}
#endregion
}
}

View File

@ -0,0 +1,53 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
{
public class LowerArea : ITerrainFloodEffect
{
#region ITerrainFloodEffect Members
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
{
int x, y;
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
if (fillArea[x, y] == true)
{
map[x, y] -= strength;
}
}
}
}
#endregion
}
}

View File

@ -0,0 +1,57 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
{
public class NoiseArea : ITerrainFloodEffect
{
#region ITerrainFloodEffect Members
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
{
int x, y;
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
if (fillArea[x, y] == true)
{
lock (OpenSim.Framework.Util.RandomClass)
{
double noise = OpenSim.Framework.Util.RandomClass.NextDouble();
map[x, y] += (noise - 0.5) * strength;
}
}
}
}
}
#endregion
}
}

View File

@ -1,7 +1,30 @@
using System; /*
using System.Collections.Generic; * Copyright (c) Contributors, http://opensimulator.org/
using System.Text; * See CONTRIBUTORS.TXT for a full list of copyright holders.
using OpenSim.Region.Environment.Modules.Terrain; *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes

View File

@ -0,0 +1,107 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
{
public class SmoothArea : ITerrainFloodEffect
{
private double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
{
int w = map.Width;
int h = map.Height;
if (x > w - 2.0)
x = w - 2.0;
if (y > h - 2.0)
y = h - 2.0;
if (x < 0.0)
x = 0.0;
if (y < 0.0)
y = 0.0;
int stepSize = 1;
double h00 = map[(int)x, (int)y];
double h10 = map[(int)x + stepSize, (int)y];
double h01 = map[(int)x, (int)y + stepSize];
double h11 = map[(int)x + stepSize, (int)y + stepSize];
double h1 = h00;
double h2 = h10;
double h3 = h01;
double h4 = h11;
double a00 = h1;
double a10 = h2 - h1;
double a01 = h3 - h1;
double a11 = h1 - h2 - h3 + h4;
double partialx = x - (int)x;
double partialz = y - (int)y;
double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
return hi;
}
#region ITerrainFloodEffect Members
public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
{
double area = strength;
double step = strength / 4.0;
double[,] manipulate = new double[map.Width, map.Height];
int x, y;
double n, l;
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
double average = 0.0;
int avgsteps = 0;
for (n = 0.0 - area; n < area; n += step)
{
for (l = 0.0 - area; l < area; l += step)
{
avgsteps++;
average += GetBilinearInterpolate(x + n, y + l, map);
}
}
manipulate[x, y] = average / avgsteps;
}
}
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
map[x, y] = manipulate[x, y];
}
}
}
#endregion
}
}

View File

@ -0,0 +1,125 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{
public class FlattenSphere : ITerrainPaintableEffect
{
private double SphericalFactor(double x, double y, double rx, double ry, double size)
{
double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry));
return z;
}
private double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
{
int w = map.Width;
int h = map.Height;
if (x > w - 2.0)
x = w - 2.0;
if (y > h - 2.0)
y = h - 2.0;
if (x < 0.0)
x = 0.0;
if (y < 0.0)
y = 0.0;
int stepSize = 1;
double h00 = map[(int)x, (int)y];
double h10 = map[(int)x + stepSize, (int)y];
double h01 = map[(int)x, (int)y + stepSize];
double h11 = map[(int)x + stepSize, (int)y + stepSize];
double h1 = h00;
double h2 = h10;
double h3 = h01;
double h4 = h11;
double a00 = h1;
double a10 = h2 - h1;
double a01 = h3 - h1;
double a11 = h1 - h2 - h3 + h4;
double partialx = x - (int)x;
double partialz = y - (int)y;
double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
return hi;
}
#region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
{
int x, y;
double[,] tweak = new double[map.Width, map.Height];
double n, l;
double area = strength;
double step = strength / 4.0;
double sum = 0.0;
double step2 = 0.0;
double avg = 0.0;
// compute delta map
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
double z = SphericalFactor(x, y, rx, ry, strength);
if (z > 0) // add in non-zero amount
{
sum += map[x, y] * z;
step2 += z;
}
}
}
avg = sum / step2;
// blend in map
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
double z = SphericalFactor(x, y, rx, ry, strength);
if (z > 0) // add in non-zero amount
{
if (z > 1.0)
z = 1.0;
map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z);
}
}
}
}
#endregion
}
}

View File

@ -0,0 +1,65 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{
public class LowerSphere : ITerrainPaintableEffect
{
#region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
{
int x, y;
for (x = 0; x < map.Width; x++)
{
// Skip everything unlikely to be affected
if (Math.Abs(x - rx) > strength * 1.1)
continue;
for (y = 0; y < map.Height; y++)
{
// Skip everything unlikely to be affected
if (Math.Abs(y - ry) > strength * 1.1)
continue;
// Calculate a sphere and add it to the heighmap
double z = strength;
z *= z;
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
if (z > 0.0)
map[x, y] -= z;
}
}
}
#endregion
}
}

View File

@ -0,0 +1,73 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{
public class NoiseSphere : ITerrainPaintableEffect
{
#region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
{
int x, y;
for (x = 0; x < map.Width; x++)
{
// Skip everything unlikely to be affected
if (Math.Abs(x - rx) > strength * 1.1)
continue;
for (y = 0; y < map.Height; y++)
{
// Skip everything unlikely to be affected
if (Math.Abs(y - ry) > strength * 1.1)
continue;
// Calculate a sphere and add it to the heighmap
double z = strength;
z *= z;
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
double noise;
lock (Util.RandomClass)
{
noise = Util.RandomClass.NextDouble();
}
if (z > 0.0)
map[x, y] += (noise - 0.5) * z;
}
}
}
#endregion
}
}

View File

@ -1,7 +1,31 @@
using System; /*
using System.Collections.Generic; * Copyright (c) Contributors, http://opensimulator.org/
using System.Text; * See CONTRIBUTORS.TXT for a full list of copyright holders.
using OpenSim.Region.Environment.Modules.Terrain; *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using System;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes

View File

@ -0,0 +1,130 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
using OpenSim.Region.Environment.Interfaces;
namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
{
public class SmoothSphere : ITerrainPaintableEffect
{
private double SphericalFactor(double x, double y, double rx, double ry, double size)
{
double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry));
return z;
}
private double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
{
int w = map.Width;
int h = map.Height;
if (x > w - 2.0)
x = w - 2.0;
if (y > h - 2.0)
y = h - 2.0;
if (x < 0.0)
x = 0.0;
if (y < 0.0)
y = 0.0;
int stepSize = 1;
double h00 = map[(int)x, (int)y];
double h10 = map[(int)x + stepSize, (int)y];
double h01 = map[(int)x, (int)y + stepSize];
double h11 = map[(int)x + stepSize, (int)y + stepSize];
double h1 = h00;
double h2 = h10;
double h3 = h01;
double h4 = h11;
double a00 = h1;
double a10 = h2 - h1;
double a01 = h3 - h1;
double a11 = h1 - h2 - h3 + h4;
double partialx = x - (int)x;
double partialz = y - (int)y;
double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
return hi;
}
#region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength)
{
int x, y;
double[,] tweak = new double[map.Width, map.Height];
double n, l;
double area = strength;
double step = strength / 4.0;
// compute delta map
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
double z = SphericalFactor(x, y, rx, ry, strength);
if (z > 0) // add in non-zero amount
{
double average = 0.0;
int avgsteps = 0;
for (n = 0.0 - area; n < area; n += step)
{
for (l = 0.0 - area; l < area; l += step)
{
avgsteps++;
average += GetBilinearInterpolate(x + n, y + l, map);
}
}
tweak[x, y] = average / avgsteps;
}
}
}
// blend in map
for (x = 0; x < map.Width; x++)
{
for (y = 0; y < map.Height; y++)
{
double z = SphericalFactor(x, y, rx, ry, strength);
if (z > 0) // add in non-zero amount
{
double da = z;
double a = (map[x, y] - tweak[x, y]) * da;
double newz = map[x, y] - a;
if (newz > 0.0)
map[x, y] = newz;
}
}
}
}
#endregion
}
}

View File

@ -26,16 +26,13 @@
* *
*/ */
using Nini.Config;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife;
using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Modules;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;
using libsecondlife;
namespace OpenSim.Region.Environment.Modules.Terrain namespace OpenSim.Region.Environment.Modules.Terrain
{ {
@ -57,7 +54,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
public interface ITerrainLoader public interface ITerrainLoader
{ {
ITerrainChannel LoadFile(string filename); ITerrainChannel LoadFile(string filename);
void SaveFile(string filename); void SaveFile(string filename, ITerrainChannel map);
} }
/// <summary> /// <summary>
@ -85,6 +82,19 @@ namespace OpenSim.Region.Environment.Modules.Terrain
return copy; return copy;
} }
public float[] GetFloatsSerialised()
{
float[] heights = new float[Width * Height];
int i;
for (i = 0; i < Width * Height; i++)
{
heights[i] = (float)map[i % Width, i / Width];
}
return heights;
}
public double this[int x, int y] public double this[int x, int y]
{ {
get get
@ -102,6 +112,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain
map = new double[Constants.RegionSize, Constants.RegionSize]; map = new double[Constants.RegionSize, Constants.RegionSize];
} }
public TerrainChannel(double[,] import)
{
map = import;
}
public TerrainChannel(bool createMap) public TerrainChannel(bool createMap)
{ {
if (createMap) if (createMap)
@ -139,13 +154,27 @@ namespace OpenSim.Region.Environment.Modules.Terrain
private void InstallDefaultEffects() private void InstallDefaultEffects()
{ {
// Draggable Paint Brush Effects
m_painteffects[StandardTerrainEffects.Raise] = new PaintBrushes.RaiseSphere(); m_painteffects[StandardTerrainEffects.Raise] = new PaintBrushes.RaiseSphere();
m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea(); m_painteffects[StandardTerrainEffects.Lower] = new PaintBrushes.LowerSphere();
m_painteffects[StandardTerrainEffects.Smooth] = new PaintBrushes.SmoothSphere();
m_painteffects[StandardTerrainEffects.Noise] = new PaintBrushes.NoiseSphere();
m_painteffects[StandardTerrainEffects.Flatten] = new PaintBrushes.FlattenSphere();
// Float[256,256] array format (RAW32) // Area of effect selection effects
m_floodeffects[StandardTerrainEffects.Raise] = new FloodBrushes.RaiseArea();
m_floodeffects[StandardTerrainEffects.Lower] = new FloodBrushes.LowerArea();
m_floodeffects[StandardTerrainEffects.Smooth] = new FloodBrushes.SmoothArea();
m_floodeffects[StandardTerrainEffects.Noise] = new FloodBrushes.NoiseArea();
m_floodeffects[StandardTerrainEffects.Flatten] = new FloodBrushes.FlattenArea();
// Filesystem load/save loaders
m_loaders[".r32"] = new FileLoaders.RAW32(); m_loaders[".r32"] = new FileLoaders.RAW32();
m_loaders[".f32"] = m_loaders[".r32"]; m_loaders[".f32"] = m_loaders[".r32"];
m_loaders[".ter"] = new FileLoaders.Terragen(); m_loaders[".ter"] = new FileLoaders.Terragen();
m_loaders[".raw"] = new FileLoaders.LLRAW();
m_loaders[".jpg"] = new FileLoaders.JPEG();
m_loaders[".jpeg"] = m_loaders[".jpg"];
} }
public void LoadFromFile(string filename) public void LoadFromFile(string filename)
@ -161,23 +190,43 @@ namespace OpenSim.Region.Environment.Modules.Terrain
} }
public void SaveToFile(string filename) public void SaveToFile(string filename)
{
try
{ {
foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders) foreach (KeyValuePair<string, ITerrainLoader> loader in m_loaders)
{ {
if (filename.EndsWith(loader.Key)) if (filename.EndsWith(loader.Key))
{ {
loader.Value.SaveFile(filename); loader.Value.SaveFile(filename, m_channel);
return; return;
} }
} }
} }
catch (NotImplementedException)
{
m_log.Error("Unable to save to " + filename + ", saving of this file format has not been implemented.");
}
}
public void Initialise(Scene scene, IConfigSource config) public void Initialise(Scene scene, IConfigSource config)
{ {
m_scene = scene; m_scene = scene;
m_gConfig = config; m_gConfig = config;
// Install terrain module in the simulator
if (m_scene.Heightmap == null)
{
lock (m_scene)
{
m_channel = new TerrainChannel(); m_channel = new TerrainChannel();
m_scene.Heightmap = m_channel;
}
}
else
{
m_channel = m_scene.Heightmap;
}
m_scene.EventManager.OnNewClient += EventManager_OnNewClient; m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
} }

View File

@ -29,10 +29,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Scenes;

View File

@ -7,11 +7,8 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers. * To change this template use Tools | Options | Coding | Edit Standard Headers.
*/ */
using System;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;

View File

@ -261,7 +261,7 @@ namespace OpenSim.Region.Environment.Modules.VoiceChat
} }
} }
} }
catch(ObjectDisposedException e) catch(ObjectDisposedException)
{ {
m_log.Warn("[VOICECHAT]: Connection has been already closed"); m_log.Warn("[VOICECHAT]: Connection has been already closed");
} }

View File

@ -31,14 +31,12 @@ using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Threading; using System.Threading;
using System.Timers; using System.Timers;
using Axiom.Math;
using libsecondlife; using libsecondlife;
using libsecondlife.Packets; using libsecondlife.Packets;
using OpenJPEGNet; using OpenJPEGNet;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Console;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment.LandManagement;
@ -1002,6 +1000,8 @@ namespace OpenSim.Region.Environment.Scenes
} }
else else
{ {
// TODO: Install 'GetDefaultTerrainProvider' method here?
Heightmap = new Modules.Terrain.TerrainChannel(map);
Terrain.SetHeights2D(map); Terrain.SetHeights2D(map);
} }

View File

@ -111,9 +111,18 @@ namespace OpenSim.Region.Environment.Scenes
/// </summary> /// </summary>
/// <param name="RemoteClient">Client to send to</param> /// <param name="RemoteClient">Client to send to</param>
public virtual void SendLayerData(IClientAPI RemoteClient) public virtual void SendLayerData(IClientAPI RemoteClient)
{
bool usingTerrainModule = false;
if (usingTerrainModule)
{
RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised());
}
else
{ {
RemoteClient.SendLayerData(Terrain.GetHeights1D()); RemoteClient.SendLayerData(Terrain.GetHeights1D());
} }
}
#endregion #endregion