* Rex merge, Region/Terrain
parent
642ced53d1
commit
9559c3f6e6
|
@ -1,65 +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.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly : AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")]
|
||||
[assembly : AssemblyDescription("")]
|
||||
[assembly : AssemblyConfiguration("")]
|
||||
[assembly : AssemblyCompany("")]
|
||||
[assembly : AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")]
|
||||
[assembly : AssemblyCopyright("Copyright © 2007")]
|
||||
[assembly : AssemblyTrademark("")]
|
||||
[assembly : AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
|
||||
[assembly : ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
||||
[assembly : Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly : AssemblyVersion("1.0.0.0")]
|
||||
[assembly : AssemblyFileVersion("1.0.0.0")]
|
||||
/*
|
||||
* 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.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly : AssemblyTitle("OpenSim.Region.Terrain.BasicTerrain")]
|
||||
[assembly : AssemblyDescription("")]
|
||||
[assembly : AssemblyConfiguration("")]
|
||||
[assembly : AssemblyCompany("")]
|
||||
[assembly : AssemblyProduct("OpenSim.Region.Terrain.BasicTerrain")]
|
||||
[assembly : AssemblyCopyright("Copyright © OpenSimulator.org Developers 2007-2008")]
|
||||
[assembly : AssemblyTrademark("")]
|
||||
[assembly : AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
|
||||
[assembly : ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
||||
[assembly : Guid("3263f5b5-0a41-4ed5-91a2-9baaaeecc849")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly : AssemblyVersion("1.0.0.0")]
|
||||
[assembly : AssemblyFileVersion("1.0.0.0")]
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,146 +1,144 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
partial class Channel
|
||||
{
|
||||
/// <summary>
|
||||
/// Flattens the area underneath rx,ry by moving it to the average of the area. Uses a spherical mask provided by the raise() function.
|
||||
/// </summary>
|
||||
/// <param name="rx">The X coordinate of the terrain mask</param>
|
||||
/// <param name="ry">The Y coordinate of the terrain mask</param>
|
||||
/// <param name="size">The size of the terrain mask</param>
|
||||
/// <param name="amount">The scale of the terrain mask</param>
|
||||
public void Flatten(double rx, double ry, double size, double amount)
|
||||
{
|
||||
FlattenSlow(rx, ry, size, amount);
|
||||
}
|
||||
|
||||
private void FlattenSlow(double rx, double ry, double size, double amount)
|
||||
{
|
||||
// Generate the mask
|
||||
Channel temp = new Channel(w, h);
|
||||
temp.Fill(0);
|
||||
temp.Raise(rx, ry, size, amount);
|
||||
temp.Normalise();
|
||||
double total_mod = temp.Sum();
|
||||
|
||||
// Establish the average height under the area
|
||||
Channel newmap = new Channel(w, h);
|
||||
newmap.map = (double[,]) map.Clone();
|
||||
|
||||
newmap *= temp;
|
||||
|
||||
double total_terrain = newmap.Sum();
|
||||
double avg_height = total_terrain/total_mod;
|
||||
|
||||
// Create a flat terrain using the average height
|
||||
Channel flat = new Channel(w, h);
|
||||
flat.Fill(avg_height);
|
||||
|
||||
// Blend the current terrain with the average height terrain
|
||||
// using the "raised" empty terrain as a mask
|
||||
Blend(flat, temp);
|
||||
}
|
||||
|
||||
private void FlattenFast(double rx, double ry, double size, double amount)
|
||||
{
|
||||
int x, y;
|
||||
double avg = 0;
|
||||
double div = 0;
|
||||
|
||||
int minX = Math.Max(0, (int) (rx - (size + 1)));
|
||||
int maxX = Math.Min(w, (int) (rx + (size + 1)));
|
||||
int minY = Math.Max(0, (int) (ry - (size + 1)));
|
||||
int maxY = Math.Min(h, (int) (ry + (size + 1)));
|
||||
|
||||
for (x = minX; x < maxX; x++)
|
||||
{
|
||||
for (y = minY; y < maxY; y++)
|
||||
{
|
||||
double z = size;
|
||||
z *= z;
|
||||
z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
|
||||
|
||||
if (z < 0)
|
||||
z = 0;
|
||||
|
||||
avg += z*amount;
|
||||
div += z;
|
||||
}
|
||||
}
|
||||
|
||||
double height = avg/div;
|
||||
|
||||
for (x = minX; x < maxX; x++)
|
||||
{
|
||||
for (y = minY; y < maxY; y++)
|
||||
{
|
||||
double z = size;
|
||||
z *= z;
|
||||
z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
|
||||
|
||||
if (z < 0)
|
||||
z = 0;
|
||||
|
||||
Set(x, y, Tools.LinearInterpolate(map[x, y], height, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Flatten(Channel mask, double amount)
|
||||
{
|
||||
// Generate the mask
|
||||
Channel temp = mask*amount;
|
||||
temp.Clip(0, 1); // Cut off out-of-bounds values
|
||||
|
||||
double total_mod = temp.Sum();
|
||||
|
||||
// Establish the average height under the area
|
||||
Channel map = new Channel(w, h);
|
||||
map.map = (double[,]) this.map.Clone();
|
||||
|
||||
map *= temp;
|
||||
|
||||
double total_terrain = map.Sum();
|
||||
double avg_height = total_terrain/total_mod;
|
||||
|
||||
// Create a flat terrain using the average height
|
||||
Channel flat = new Channel(w, h);
|
||||
flat.Fill(avg_height);
|
||||
|
||||
// Blend the current terrain with the average height terrain
|
||||
// using the "raised" empty terrain as a mask
|
||||
Blend(flat, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
partial class Channel
|
||||
{
|
||||
/// <summary>
|
||||
/// Flattens the area underneath rx,ry by moving it to the average of the area. Uses a spherical mask provided by the raise() function.
|
||||
/// </summary>
|
||||
/// <param name="rx">The X coordinate of the terrain mask</param>
|
||||
/// <param name="ry">The Y coordinate of the terrain mask</param>
|
||||
/// <param name="size">The size of the terrain mask</param>
|
||||
/// <param name="amount">The scale of the terrain mask</param>
|
||||
public void Flatten(double rx, double ry, double size, double amount)
|
||||
{
|
||||
FlattenSlow(rx, ry, size, amount);
|
||||
}
|
||||
|
||||
private void FlattenSlow(double rx, double ry, double size, double amount)
|
||||
{
|
||||
// Generate the mask
|
||||
Channel temp = new Channel(w, h);
|
||||
temp.Fill(0);
|
||||
temp.Raise(rx, ry, size, amount);
|
||||
temp.Normalise();
|
||||
double total_mod = temp.Sum();
|
||||
|
||||
// Establish the average height under the area
|
||||
Channel newmap = new Channel(w, h);
|
||||
newmap.map = (double[,]) map.Clone();
|
||||
|
||||
newmap *= temp;
|
||||
|
||||
double total_terrain = newmap.Sum();
|
||||
double avg_height = total_terrain/total_mod;
|
||||
|
||||
// Create a flat terrain using the average height
|
||||
Channel flat = new Channel(w, h);
|
||||
flat.Fill(avg_height);
|
||||
|
||||
// Blend the current terrain with the average height terrain
|
||||
// using the "raised" empty terrain as a mask
|
||||
Blend(flat, temp);
|
||||
}
|
||||
|
||||
private void FlattenFast(double rx, double ry, double size, double amount)
|
||||
{
|
||||
int x, y;
|
||||
double avg = 0;
|
||||
double div = 0;
|
||||
|
||||
int minX = Math.Max(0, (int) (rx - (size + 1)));
|
||||
int maxX = Math.Min(w, (int) (rx + (size + 1)));
|
||||
int minY = Math.Max(0, (int) (ry - (size + 1)));
|
||||
int maxY = Math.Min(h, (int) (ry + (size + 1)));
|
||||
|
||||
for (x = minX; x < maxX; x++)
|
||||
{
|
||||
for (y = minY; y < maxY; y++)
|
||||
{
|
||||
double z = size;
|
||||
z *= z;
|
||||
z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
|
||||
|
||||
if (z < 0)
|
||||
z = 0;
|
||||
|
||||
avg += z*amount;
|
||||
div += z;
|
||||
}
|
||||
}
|
||||
|
||||
double height = avg/div;
|
||||
|
||||
for (x = minX; x < maxX; x++)
|
||||
{
|
||||
for (y = minY; y < maxY; y++)
|
||||
{
|
||||
double z = size;
|
||||
z *= z;
|
||||
z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
|
||||
|
||||
if (z > 0.0)
|
||||
Set(x, y, Tools.LinearInterpolate(map[x, y], height, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Flatten(Channel mask, double amount)
|
||||
{
|
||||
// Generate the mask
|
||||
Channel temp = mask*amount;
|
||||
temp.Clip(0, 1); // Cut off out-of-bounds values
|
||||
|
||||
double total_mod = temp.Sum();
|
||||
|
||||
// Establish the average height under the area
|
||||
Channel map = new Channel(w, h);
|
||||
map.map = (double[,]) this.map.Clone();
|
||||
|
||||
map *= temp;
|
||||
|
||||
double total_terrain = map.Sum();
|
||||
double avg_height = total_terrain/total_mod;
|
||||
|
||||
// Create a flat terrain using the average height
|
||||
Channel flat = new Channel(w, h);
|
||||
flat.Fill(avg_height);
|
||||
|
||||
// Blend the current terrain with the average height terrain
|
||||
// using the "raised" empty terrain as a mask
|
||||
Blend(flat, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,137 +1,131 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
partial class Channel
|
||||
{
|
||||
/// <summary>
|
||||
/// Raises land around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
|
||||
/// <param name="size">The radius of the dimple</param>
|
||||
/// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
|
||||
public void Raise(double rx, double ry, double size, double amount)
|
||||
{
|
||||
RaiseSphere(rx, ry, size, amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises land in a sphere around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
|
||||
/// <param name="size">The radius of the sphere dimple</param>
|
||||
/// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
|
||||
public void RaiseSphere(double rx, double ry, double size, double amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double z = size;
|
||||
z *= z;
|
||||
z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
|
||||
|
||||
if (z < 0)
|
||||
z = 0;
|
||||
|
||||
Set(x, y, map[x, y] + (z*amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises land in a cone around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
|
||||
/// <param name="size">The radius of the cone</param>
|
||||
/// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
|
||||
public void RaiseCone(double rx, double ry, double size, double amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double z = size;
|
||||
z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry)));
|
||||
|
||||
if (z < 0)
|
||||
z = 0;
|
||||
|
||||
Set(x, y, map[x, y] + (z*amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lowers land in a sphere around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
|
||||
/// <param name="size">The radius of the sphere dimple</param>
|
||||
/// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
|
||||
public void Lower(double rx, double ry, double size, double amount)
|
||||
{
|
||||
LowerSphere(rx, ry, size, amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lowers land in a sphere around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
|
||||
/// <param name="size">The radius of the sphere dimple</param>
|
||||
/// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
|
||||
public void LowerSphere(double rx, double ry, double size, double amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double z = size;
|
||||
z *= z;
|
||||
z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
|
||||
|
||||
if (z < 0)
|
||||
z = 0;
|
||||
|
||||
Set(x, y, map[x, y] - (z*amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
partial class Channel
|
||||
{
|
||||
/// <summary>
|
||||
/// Raises land around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
|
||||
/// <param name="size">The radius of the dimple</param>
|
||||
/// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
|
||||
public void Raise(double rx, double ry, double size, double amount)
|
||||
{
|
||||
RaiseSphere(rx, ry, size, amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises land in a sphere around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
|
||||
/// <param name="size">The radius of the sphere dimple</param>
|
||||
/// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
|
||||
public void RaiseSphere(double rx, double ry, double size, double amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double z = size;
|
||||
z *= z;
|
||||
z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
|
||||
|
||||
if (z > 0.0)
|
||||
Set(x, y, map[x, y] + (z * amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises land in a cone around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
|
||||
/// <param name="size">The radius of the cone</param>
|
||||
/// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
|
||||
public void RaiseCone(double rx, double ry, double size, double amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double z = size;
|
||||
z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry)));
|
||||
|
||||
if (z > 0.0)
|
||||
Set(x, y, map[x, y] + (z * amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lowers land in a sphere around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
|
||||
/// <param name="size">The radius of the sphere dimple</param>
|
||||
/// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
|
||||
public void Lower(double rx, double ry, double size, double amount)
|
||||
{
|
||||
LowerSphere(rx, ry, size, amount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lowers land in a sphere around the selection
|
||||
/// </summary>
|
||||
/// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
|
||||
/// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
|
||||
/// <param name="size">The radius of the sphere dimple</param>
|
||||
/// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
|
||||
public void LowerSphere(double rx, double ry, double size, double amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double z = size;
|
||||
z *= z;
|
||||
z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry));
|
||||
|
||||
if (z > 0.0)
|
||||
Set(x, y, map[x, y] - (z * amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Needs BSD rewrite */
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Needs BSD rewrite */
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Needs BSD rewrite */
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Needs BSD rewrite */
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Needs BSD rewrite */
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Needs BSD rewrite */
|
||||
|
|
|
@ -1,359 +1,377 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
partial class Channel
|
||||
{
|
||||
public Channel Normalise()
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
double max = FindMax();
|
||||
double min = FindMin();
|
||||
|
||||
int x, y;
|
||||
|
||||
if (max != min)
|
||||
{
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
map[x, y] = (map[x, y] - min)*(1.0/(max - min));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Fill(0.5);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Normalise(double minv, double maxv)
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
if (minv == maxv)
|
||||
{
|
||||
Fill(minv);
|
||||
return this;
|
||||
}
|
||||
|
||||
double max = FindMax();
|
||||
double min = FindMin();
|
||||
|
||||
int x, y;
|
||||
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
if (min != max)
|
||||
{
|
||||
double val = (map[x, y] - min)*(1.0/(max - min));
|
||||
val *= maxv - minv;
|
||||
val += minv;
|
||||
|
||||
map[x, y] = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
map[x, y] = 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Clip()
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
SetClip(x, y, map[x, y]);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Clip(double min, double max)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double val = map[x, y];
|
||||
if (val > max) val = max;
|
||||
if (val < min) val = min;
|
||||
|
||||
Set(x, y, val);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Crop(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int width = x1 - x2 + 1;
|
||||
int height = y1 - y2 + 1;
|
||||
Channel chan = new Channel(width, height);
|
||||
|
||||
int x, y;
|
||||
int nx, ny;
|
||||
|
||||
nx = 0;
|
||||
for (x = x1; x < x2; x++)
|
||||
{
|
||||
ny = 0;
|
||||
for (y = y1; y < y2; y++)
|
||||
{
|
||||
chan.map[nx, ny] = map[x, y];
|
||||
|
||||
ny++;
|
||||
}
|
||||
nx++;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel AddClip(Channel other)
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
map[x, y] = other.map[x, y];
|
||||
if (map[x, y] > 1)
|
||||
map[x, y] = 1;
|
||||
if (map[x, y] < 0)
|
||||
map[x, y] = 0;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Smooth(double amount)
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
double area = amount;
|
||||
double step = amount/4.0;
|
||||
|
||||
double[,] manipulate = new double[w,h];
|
||||
int x, y;
|
||||
double n, l;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; 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);
|
||||
}
|
||||
}
|
||||
|
||||
manipulate[x, y] = average/avgsteps;
|
||||
}
|
||||
}
|
||||
map = manipulate;
|
||||
}
|
||||
|
||||
public void Pertubation(double amount)
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
// Simple pertubation filter
|
||||
double[,] manipulated = new double[w,h];
|
||||
Random generator = new Random(seed); // Seeds FTW!
|
||||
//double amount = 8.0;
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
|
||||
double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
|
||||
double p = GetBilinearInterpolate(offset_x, offset_y);
|
||||
manipulated[x, y] = p;
|
||||
}
|
||||
}
|
||||
map = manipulated;
|
||||
}
|
||||
|
||||
public void PertubationMask(Channel mask)
|
||||
{
|
||||
// Simple pertubation filter
|
||||
double[,] manipulated = new double[w,h];
|
||||
Random generator = new Random(seed); // Seeds FTW!
|
||||
//double amount = 8.0;
|
||||
|
||||
double amount;
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
amount = mask.map[x, y];
|
||||
double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
|
||||
double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
|
||||
|
||||
if (offset_x > w)
|
||||
offset_x = w - 1;
|
||||
if (offset_y > h)
|
||||
offset_y = h - 1;
|
||||
if (offset_y < 0)
|
||||
offset_y = 0;
|
||||
if (offset_x < 0)
|
||||
offset_x = 0;
|
||||
|
||||
double p = GetBilinearInterpolate(offset_x, offset_y);
|
||||
manipulated[x, y] = p;
|
||||
SetDiff(x, y);
|
||||
}
|
||||
}
|
||||
map = manipulated;
|
||||
}
|
||||
|
||||
public void Distort(Channel mask, double str)
|
||||
{
|
||||
// Simple pertubation filter
|
||||
double[,] manipulated = new double[w,h];
|
||||
|
||||
double amount;
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
amount = mask.map[x, y];
|
||||
double offset_x = (double) x + (amount*str) - (0.5*str);
|
||||
double offset_y = (double) y + (amount*str) - (0.5*str);
|
||||
|
||||
if (offset_x > w)
|
||||
offset_x = w - 1;
|
||||
if (offset_y > h)
|
||||
offset_y = h - 1;
|
||||
if (offset_y < 0)
|
||||
offset_y = 0;
|
||||
if (offset_x < 0)
|
||||
offset_x = 0;
|
||||
|
||||
double p = GetBilinearInterpolate(offset_x, offset_y);
|
||||
manipulated[x, y] = p;
|
||||
SetDiff(x, y);
|
||||
}
|
||||
}
|
||||
map = manipulated;
|
||||
}
|
||||
|
||||
public void Distort(Channel mask, Channel mask2, double str)
|
||||
{
|
||||
// Simple pertubation filter
|
||||
double[,] manipulated = new double[w,h];
|
||||
|
||||
double amountX;
|
||||
double amountY;
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
amountX = mask.map[x, y];
|
||||
amountY = mask2.map[x, y];
|
||||
double offset_x = (double) x + (amountX*str) - (0.5*str);
|
||||
double offset_y = (double) y + (amountY*str) - (0.5*str);
|
||||
|
||||
if (offset_x > w)
|
||||
offset_x = w - 1;
|
||||
if (offset_y > h)
|
||||
offset_y = h - 1;
|
||||
if (offset_y < 0)
|
||||
offset_y = 0;
|
||||
if (offset_x < 0)
|
||||
offset_x = 0;
|
||||
|
||||
double p = GetBilinearInterpolate(offset_x, offset_y);
|
||||
manipulated[x, y] = p;
|
||||
SetDiff(x, y);
|
||||
}
|
||||
}
|
||||
map = manipulated;
|
||||
}
|
||||
|
||||
public Channel Blend(Channel other, double amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
Set(x, y, Tools.LinearInterpolate(map[x, y], other.map[x, y], amount));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Blend(Channel other, Channel amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
Set(x, y, Tools.LinearInterpolate(map[x, y], other.map[x, y], amount.map[x, y]));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
partial class Channel
|
||||
{
|
||||
public Channel Normalise()
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
double max = FindMax();
|
||||
double min = FindMin();
|
||||
|
||||
int x, y;
|
||||
|
||||
if (max != min)
|
||||
{
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
map[x, y] = (map[x, y] - min)*(1.0/(max - min));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Fill(0.5);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Normalise(double minv, double maxv)
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
if (minv == maxv)
|
||||
{
|
||||
Fill(minv);
|
||||
return this;
|
||||
}
|
||||
|
||||
double max = FindMax();
|
||||
double min = FindMin();
|
||||
|
||||
int x, y;
|
||||
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
if (min != max)
|
||||
{
|
||||
double val = (map[x, y] - min)*(1.0/(max - min));
|
||||
val *= maxv - minv;
|
||||
val += minv;
|
||||
|
||||
map[x, y] = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
map[x, y] = 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Elevate(double meters)
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
int x, y;
|
||||
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
map[x, y] += meters;
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Channel Clip()
|
||||
{
|
||||
int x, y;
|
||||
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
SetClip(x, y, map[x, y]);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Clip(double min, double max)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double val = map[x, y];
|
||||
if (val > max) val = max;
|
||||
if (val < min) val = min;
|
||||
|
||||
Set(x, y, val);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Crop(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
int width = x1 - x2 + 1;
|
||||
int height = y1 - y2 + 1;
|
||||
Channel chan = new Channel(width, height);
|
||||
|
||||
int x, y;
|
||||
int nx, ny;
|
||||
|
||||
nx = 0;
|
||||
for (x = x1; x < x2; x++)
|
||||
{
|
||||
ny = 0;
|
||||
for (y = y1; y < y2; y++)
|
||||
{
|
||||
chan.map[nx, ny] = map[x, y];
|
||||
|
||||
ny++;
|
||||
}
|
||||
nx++;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel AddClip(Channel other)
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
map[x, y] = other.map[x, y];
|
||||
if (map[x, y] > 1)
|
||||
map[x, y] = 1;
|
||||
if (map[x, y] < 0)
|
||||
map[x, y] = 0;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Smooth(double amount)
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
double area = amount;
|
||||
double step = amount/4.0;
|
||||
|
||||
double[,] manipulate = new double[w,h];
|
||||
int x, y;
|
||||
double n, l;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; 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);
|
||||
}
|
||||
}
|
||||
|
||||
manipulate[x, y] = average/avgsteps;
|
||||
}
|
||||
}
|
||||
map = manipulate;
|
||||
}
|
||||
|
||||
public void Pertubation(double amount)
|
||||
{
|
||||
SetDiff();
|
||||
|
||||
// Simple pertubation filter
|
||||
double[,] manipulated = new double[w,h];
|
||||
Random generator = new Random(seed); // Seeds FTW!
|
||||
//double amount = 8.0;
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
|
||||
double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
|
||||
double p = GetBilinearInterpolate(offset_x, offset_y);
|
||||
manipulated[x, y] = p;
|
||||
}
|
||||
}
|
||||
map = manipulated;
|
||||
}
|
||||
|
||||
public void PertubationMask(Channel mask)
|
||||
{
|
||||
// Simple pertubation filter
|
||||
double[,] manipulated = new double[w,h];
|
||||
Random generator = new Random(seed); // Seeds FTW!
|
||||
//double amount = 8.0;
|
||||
|
||||
double amount;
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
amount = mask.map[x, y];
|
||||
double offset_x = (double) x + (generator.NextDouble()*amount) - (amount/2.0);
|
||||
double offset_y = (double) y + (generator.NextDouble()*amount) - (amount/2.0);
|
||||
|
||||
if (offset_x > w)
|
||||
offset_x = w - 1;
|
||||
if (offset_y > h)
|
||||
offset_y = h - 1;
|
||||
if (offset_y < 0)
|
||||
offset_y = 0;
|
||||
if (offset_x < 0)
|
||||
offset_x = 0;
|
||||
|
||||
double p = GetBilinearInterpolate(offset_x, offset_y);
|
||||
manipulated[x, y] = p;
|
||||
SetDiff(x, y);
|
||||
}
|
||||
}
|
||||
map = manipulated;
|
||||
}
|
||||
|
||||
public void Distort(Channel mask, double str)
|
||||
{
|
||||
// Simple pertubation filter
|
||||
double[,] manipulated = new double[w,h];
|
||||
|
||||
double amount;
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
amount = mask.map[x, y];
|
||||
double offset_x = (double) x + (amount*str) - (0.5*str);
|
||||
double offset_y = (double) y + (amount*str) - (0.5*str);
|
||||
|
||||
if (offset_x > w)
|
||||
offset_x = w - 1;
|
||||
if (offset_y > h)
|
||||
offset_y = h - 1;
|
||||
if (offset_y < 0)
|
||||
offset_y = 0;
|
||||
if (offset_x < 0)
|
||||
offset_x = 0;
|
||||
|
||||
double p = GetBilinearInterpolate(offset_x, offset_y);
|
||||
manipulated[x, y] = p;
|
||||
SetDiff(x, y);
|
||||
}
|
||||
}
|
||||
map = manipulated;
|
||||
}
|
||||
|
||||
public void Distort(Channel mask, Channel mask2, double str)
|
||||
{
|
||||
// Simple pertubation filter
|
||||
double[,] manipulated = new double[w,h];
|
||||
|
||||
double amountX;
|
||||
double amountY;
|
||||
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
amountX = mask.map[x, y];
|
||||
amountY = mask2.map[x, y];
|
||||
double offset_x = (double) x + (amountX*str) - (0.5*str);
|
||||
double offset_y = (double) y + (amountY*str) - (0.5*str);
|
||||
|
||||
if (offset_x > w)
|
||||
offset_x = w - 1;
|
||||
if (offset_y > h)
|
||||
offset_y = h - 1;
|
||||
if (offset_y < 0)
|
||||
offset_y = 0;
|
||||
if (offset_x < 0)
|
||||
offset_x = 0;
|
||||
|
||||
double p = GetBilinearInterpolate(offset_x, offset_y);
|
||||
manipulated[x, y] = p;
|
||||
SetDiff(x, y);
|
||||
}
|
||||
}
|
||||
map = manipulated;
|
||||
}
|
||||
|
||||
public Channel Blend(Channel other, double amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
Set(x, y, Tools.LinearInterpolate(map[x, y], other.map[x, y], amount));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Channel Blend(Channel other, Channel amount)
|
||||
{
|
||||
int x, y;
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
Set(x, y, Tools.LinearInterpolate(map[x, y], other.map[x, y], amount.map[x, y]));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
public class Point2D
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
|
||||
public Point2D(double X, double Y)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
public class Point2D
|
||||
{
|
||||
public double x;
|
||||
public double y;
|
||||
|
||||
public Point2D(double X, double Y)
|
||||
{
|
||||
x = X;
|
||||
y = Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,60 +1,60 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
internal class Tools
|
||||
{
|
||||
public static double LinearInterpolate(double a, double b, double amount)
|
||||
{
|
||||
return a + ((b - a)*amount);
|
||||
}
|
||||
|
||||
public static double ExponentialInterpolate(double a, double b, double amount)
|
||||
{
|
||||
a = Math.Pow(a, amount);
|
||||
b = Math.Pow(b - a, 1.0 - amount);
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public static int PowerOf2Log2(int n)
|
||||
{
|
||||
for (int i = 0; i < 31; i++)
|
||||
{
|
||||
if ((n & 1) == 1)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
n >>= 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* 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;
|
||||
|
||||
namespace libTerrain
|
||||
{
|
||||
internal class Tools
|
||||
{
|
||||
public static double LinearInterpolate(double a, double b, double amount)
|
||||
{
|
||||
return a + ((b - a)*amount);
|
||||
}
|
||||
|
||||
public static double ExponentialInterpolate(double a, double b, double amount)
|
||||
{
|
||||
a = Math.Pow(a, amount);
|
||||
b = Math.Pow(b - a, 1.0 - amount);
|
||||
return a + b;
|
||||
}
|
||||
|
||||
public static int PowerOf2Log2(int n)
|
||||
{
|
||||
for (int i = 0; i < 31; i++)
|
||||
{
|
||||
if ((n & 1) == 1)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
n >>= 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue