Updated svn properties.

0.6.0-stable
Jeff Ames 2008-03-03 09:29:21 +00:00
parent a88f93389c
commit d50eb9d2b3
10 changed files with 890 additions and 890 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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