From 2b42ea0a429c722bd7c5c67d3815c2ddc8399e78 Mon Sep 17 00:00:00 2001
From: MW
Date: Wed, 25 Jul 2007 18:19:38 +0000
Subject: Start of the OpenSim library , for now only contains a few textures.
---
.../libTerrainBSD/Channel/Generators/Fracture.cs | 288 +++++------
.../libTerrainBSD/Channel/Generators/Gradient.cs | 130 ++---
.../Channel/Generators/HillPlanter.cs | 566 ++++++++++-----------
.../libTerrainBSD/Channel/Generators/Noise.cs | 112 ++--
.../libTerrainBSD/Channel/Generators/Spiral.cs | 310 +++++------
.../libTerrainBSD/Channel/Generators/Voronoi.cs | 428 ++++++++--------
.../libTerrainBSD/Channel/Generators/Worms.cs | 146 +++---
7 files changed, 990 insertions(+), 990 deletions(-)
(limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators')
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
index 13dd1bc..2d42759 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
@@ -1,145 +1,145 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace libTerrain
-{
- partial class Channel
- {
- ///
- /// Produces a set of coordinates defined by an edge point. Eg - 0 = 0,0. 256 = 0,256. 512 = 256,256
- /// Assumes a 256^2 heightmap. This needs fixing for input values of w,h
- ///
- ///
- ///
- ///
- ///
- private int[] RadialEdge256(int val)
- {
- // Four cases:
- // 1. 000..255 return 0,val
- // 2. 256..511 return val - 256,255
- // 3. 512..767 return 255, val - 511
- // 4. 768..1023 return val - 768,0
-
- int[] ret = new int[2];
-
- if (val < 256)
- {
- ret[0] = 0;
- ret[1] = val;
- return ret;
- }
- if (val < 512)
- {
- ret[0] = (val % 256);
- ret[1] = 255;
- return ret;
- }
- if (val < 768)
- {
- ret[0] = 255;
- ret[1] = 255 - (val % 256);
- return ret;
- }
- if (val < 1024)
- {
- ret[0] = 255 - (val % 256);
- ret[1] = 255;
- return ret;
- }
-
- throw new Exception("Out of bounds parameter (val)");
- }
-
- public void Fracture(int number, double scalemin, double scalemax)
- {
- SetDiff();
-
- Random rand = new Random(seed);
-
- for (int i = 0; i < number; i++)
- {
- int[] a, b;
-
- a = RadialEdge256(rand.Next(1023)); // TODO: Broken
- b = RadialEdge256(rand.Next(1023)); // TODO: Broken
- double z = rand.NextDouble();
- double u = rand.NextDouble();
- double v = rand.NextDouble();
-
- for (int x = 0; x < w; x++)
- {
- for (int y = 0; y < h; y++)
- {
- double miny = Tools.linearInterpolate(a[1], b[1], (double)x / (double)w);
-
- if (v >= 0.5)
- {
- if (u >= 0.5)
- {
- if (y > miny)
- {
- map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
- }
- }
- else
- {
- if (y < miny)
- {
- map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
- }
- }
- }
- else
- {
- if (u >= 0.5)
- {
- if (x > miny)
- {
- map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
- }
- }
- else
- {
- if (x < miny)
- {
- map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
- }
- }
- }
- }
- }
- }
- Normalise();
- }
- }
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace libTerrain
+{
+ partial class Channel
+ {
+ ///
+ /// Produces a set of coordinates defined by an edge point. Eg - 0 = 0,0. 256 = 0,256. 512 = 256,256
+ /// Assumes a 256^2 heightmap. This needs fixing for input values of w,h
+ ///
+ ///
+ ///
+ ///
+ ///
+ private int[] RadialEdge256(int val)
+ {
+ // Four cases:
+ // 1. 000..255 return 0,val
+ // 2. 256..511 return val - 256,255
+ // 3. 512..767 return 255, val - 511
+ // 4. 768..1023 return val - 768,0
+
+ int[] ret = new int[2];
+
+ if (val < 256)
+ {
+ ret[0] = 0;
+ ret[1] = val;
+ return ret;
+ }
+ if (val < 512)
+ {
+ ret[0] = (val % 256);
+ ret[1] = 255;
+ return ret;
+ }
+ if (val < 768)
+ {
+ ret[0] = 255;
+ ret[1] = 255 - (val % 256);
+ return ret;
+ }
+ if (val < 1024)
+ {
+ ret[0] = 255 - (val % 256);
+ ret[1] = 255;
+ return ret;
+ }
+
+ throw new Exception("Out of bounds parameter (val)");
+ }
+
+ public void Fracture(int number, double scalemin, double scalemax)
+ {
+ SetDiff();
+
+ Random rand = new Random(seed);
+
+ for (int i = 0; i < number; i++)
+ {
+ int[] a, b;
+
+ a = RadialEdge256(rand.Next(1023)); // TODO: Broken
+ b = RadialEdge256(rand.Next(1023)); // TODO: Broken
+ double z = rand.NextDouble();
+ double u = rand.NextDouble();
+ double v = rand.NextDouble();
+
+ for (int x = 0; x < w; x++)
+ {
+ for (int y = 0; y < h; y++)
+ {
+ double miny = Tools.linearInterpolate(a[1], b[1], (double)x / (double)w);
+
+ if (v >= 0.5)
+ {
+ if (u >= 0.5)
+ {
+ if (y > miny)
+ {
+ map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
+ }
+ }
+ else
+ {
+ if (y < miny)
+ {
+ map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
+ }
+ }
+ }
+ else
+ {
+ if (u >= 0.5)
+ {
+ if (x > miny)
+ {
+ map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
+ }
+ }
+ else
+ {
+ if (x < miny)
+ {
+ map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
+ }
+ }
+ }
+ }
+ }
+ }
+ Normalise();
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs
index 47b7a66..141fe04 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs
@@ -1,66 +1,66 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace libTerrain
-{
- partial class Channel
- {
-
- public void GradientCube()
- {
- SetDiff();
-
- int x, y;
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- map[x, y] = x*y;
- }
- }
- Normalise();
- }
-
- public void GradientStripe()
- {
- int x, y;
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- map[x, y] = x;
- }
- }
- Normalise();
- }
- }
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace libTerrain
+{
+ partial class Channel
+ {
+
+ public void GradientCube()
+ {
+ SetDiff();
+
+ int x, y;
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ map[x, y] = x*y;
+ }
+ }
+ Normalise();
+ }
+
+ public void GradientStripe()
+ {
+ int x, y;
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ map[x, y] = x;
+ }
+ }
+ Normalise();
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
index 5a697b1..aa18e40 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
@@ -1,283 +1,283 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace libTerrain
-{
- partial class Channel
- {
- ///
- /// Generates a series of spheres which are then either max()'d or added together. Inspired by suggestion from jh.
- ///
- /// 3-Clause BSD Licensed
- /// The number of hills to generate
- /// The minimum size of each hill
- /// The maximum size of each hill
- /// Whether to bias hills towards the center of the map
- /// Whether to add hills together or to pick the largest value
- /// Generates hill-shaped noise instead of consistent hills
- public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
- {
- SetDiff();
-
- Random random = new Random(seed);
-
- int x, y;
- int i;
-
- for (i = 0; i < number; i++)
- {
- double rx = Math.Min(255.0, random.NextDouble() * w);
- double ry = Math.Min(255.0, random.NextDouble() * h);
- double rand = random.NextDouble();
-
- if (island)
- {
- // Move everything towards the center
- rx -= w / 2;
- rx /= 2;
- rx += w / 2;
-
- ry -= h / 2;
- ry /= 2;
- ry += h / 2;
- }
-
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- if (noisy)
- rand = random.NextDouble();
-
- double z = (scale_min + (scale_range * rand));
- z *= z;
- z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
-
- if (z < 0)
- z = 0;
-
- if (additive)
- {
- map[x, y] += z;
- }
- else
- {
- map[x, y] = Math.Max(map[x, y], z);
- }
- }
- }
- }
-
- Normalise();
- }
-
- ///
- /// Generates a series of cones which are then either max()'d or added together. Inspired by suggestion from jh.
- ///
- /// 3-Clause BSD Licensed
- /// The number of hills to generate
- /// The minimum size of each hill
- /// The maximum size of each hill
- /// Whether to bias hills towards the center of the map
- /// Whether to add hills together or to pick the largest value
- /// Generates hill-shaped noise instead of consistent hills
- public void HillsCones(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
- {
- SetDiff();
-
- Random random = new Random(seed);
-
- int x, y;
- int i;
-
- for (i = 0; i < number; i++)
- {
- double rx = Math.Min(255.0, random.NextDouble() * w);
- double ry = Math.Min(255.0, random.NextDouble() * h);
- double rand = random.NextDouble();
-
- if (island)
- {
- // Move everything towards the center
- rx -= w / 2;
- rx /= 2;
- rx += w / 2;
-
- ry -= h / 2;
- ry /= 2;
- ry += h / 2;
- }
-
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- if (noisy)
- rand = random.NextDouble();
-
- double z = (scale_min + (scale_range * rand));
- z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
-
- if (z < 0)
- z = 0;
-
- if (additive)
- {
- map[x, y] += z;
- }
- else
- {
- map[x, y] = Math.Max(map[x, y], z);
- }
- }
- }
- }
-
- Normalise();
- }
-
- public void HillsBlocks(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
- {
- SetDiff();
-
- Random random = new Random(seed);
-
- int x, y;
- int i;
-
- for (i = 0; i < number; i++)
- {
- double rx = Math.Min(255.0, random.NextDouble() * w);
- double ry = Math.Min(255.0, random.NextDouble() * h);
- double rand = random.NextDouble();
-
- if (island)
- {
- // Move everything towards the center
- rx -= w / 2;
- rx /= 2;
- rx += w / 2;
-
- ry -= h / 2;
- ry /= 2;
- ry += h / 2;
- }
-
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- if (noisy)
- rand = random.NextDouble();
-
- double z = (scale_min + (scale_range * rand));
- z -= Math.Abs(x-rx) + Math.Abs(y-ry);
- //z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
-
- if (z < 0)
- z = 0;
-
- if (additive)
- {
- map[x, y] += z;
- }
- else
- {
- map[x, y] = Math.Max(map[x, y], z);
- }
- }
- }
- }
-
- Normalise();
- }
-
- public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
- {
- SetDiff();
-
- Random random = new Random(seed);
-
- int x, y;
- int i;
-
- for (i = 0; i < number; i++)
- {
- double rx = Math.Min(255.0, random.NextDouble() * w);
- double ry = Math.Min(255.0, random.NextDouble() * h);
- double rand = random.NextDouble();
-
- if (island)
- {
- // Move everything towards the center
- rx -= w / 2;
- rx /= 2;
- rx += w / 2;
-
- ry -= h / 2;
- ry /= 2;
- ry += h / 2;
- }
-
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- if (noisy)
- rand = random.NextDouble();
-
- double z = (scale_min + (scale_range * rand));
- z *= z * z * z;
- double dx = Math.Abs(x - rx);
- double dy = Math.Abs(y - ry);
- z -= (dx * dx * dx * dx) + (dy * dy * dy * dy);
-
- if (z < 0)
- z = 0;
-
- if (additive)
- {
- map[x, y] += z;
- }
- else
- {
- map[x, y] = Math.Max(map[x, y], z);
- }
- }
- }
- }
-
- Normalise();
- }
-
- }
-}
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace libTerrain
+{
+ partial class Channel
+ {
+ ///
+ /// Generates a series of spheres which are then either max()'d or added together. Inspired by suggestion from jh.
+ ///
+ /// 3-Clause BSD Licensed
+ /// The number of hills to generate
+ /// The minimum size of each hill
+ /// The maximum size of each hill
+ /// Whether to bias hills towards the center of the map
+ /// Whether to add hills together or to pick the largest value
+ /// Generates hill-shaped noise instead of consistent hills
+ public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
+ {
+ SetDiff();
+
+ Random random = new Random(seed);
+
+ int x, y;
+ int i;
+
+ for (i = 0; i < number; i++)
+ {
+ double rx = Math.Min(255.0, random.NextDouble() * w);
+ double ry = Math.Min(255.0, random.NextDouble() * h);
+ double rand = random.NextDouble();
+
+ if (island)
+ {
+ // Move everything towards the center
+ rx -= w / 2;
+ rx /= 2;
+ rx += w / 2;
+
+ ry -= h / 2;
+ ry /= 2;
+ ry += h / 2;
+ }
+
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ if (noisy)
+ rand = random.NextDouble();
+
+ double z = (scale_min + (scale_range * rand));
+ z *= z;
+ z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
+
+ if (z < 0)
+ z = 0;
+
+ if (additive)
+ {
+ map[x, y] += z;
+ }
+ else
+ {
+ map[x, y] = Math.Max(map[x, y], z);
+ }
+ }
+ }
+ }
+
+ Normalise();
+ }
+
+ ///
+ /// Generates a series of cones which are then either max()'d or added together. Inspired by suggestion from jh.
+ ///
+ /// 3-Clause BSD Licensed
+ /// The number of hills to generate
+ /// The minimum size of each hill
+ /// The maximum size of each hill
+ /// Whether to bias hills towards the center of the map
+ /// Whether to add hills together or to pick the largest value
+ /// Generates hill-shaped noise instead of consistent hills
+ public void HillsCones(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
+ {
+ SetDiff();
+
+ Random random = new Random(seed);
+
+ int x, y;
+ int i;
+
+ for (i = 0; i < number; i++)
+ {
+ double rx = Math.Min(255.0, random.NextDouble() * w);
+ double ry = Math.Min(255.0, random.NextDouble() * h);
+ double rand = random.NextDouble();
+
+ if (island)
+ {
+ // Move everything towards the center
+ rx -= w / 2;
+ rx /= 2;
+ rx += w / 2;
+
+ ry -= h / 2;
+ ry /= 2;
+ ry += h / 2;
+ }
+
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ if (noisy)
+ rand = random.NextDouble();
+
+ double z = (scale_min + (scale_range * rand));
+ z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
+
+ if (z < 0)
+ z = 0;
+
+ if (additive)
+ {
+ map[x, y] += z;
+ }
+ else
+ {
+ map[x, y] = Math.Max(map[x, y], z);
+ }
+ }
+ }
+ }
+
+ Normalise();
+ }
+
+ public void HillsBlocks(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
+ {
+ SetDiff();
+
+ Random random = new Random(seed);
+
+ int x, y;
+ int i;
+
+ for (i = 0; i < number; i++)
+ {
+ double rx = Math.Min(255.0, random.NextDouble() * w);
+ double ry = Math.Min(255.0, random.NextDouble() * h);
+ double rand = random.NextDouble();
+
+ if (island)
+ {
+ // Move everything towards the center
+ rx -= w / 2;
+ rx /= 2;
+ rx += w / 2;
+
+ ry -= h / 2;
+ ry /= 2;
+ ry += h / 2;
+ }
+
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ if (noisy)
+ rand = random.NextDouble();
+
+ double z = (scale_min + (scale_range * rand));
+ z -= Math.Abs(x-rx) + Math.Abs(y-ry);
+ //z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry)));
+
+ if (z < 0)
+ z = 0;
+
+ if (additive)
+ {
+ map[x, y] += z;
+ }
+ else
+ {
+ map[x, y] = Math.Max(map[x, y], z);
+ }
+ }
+ }
+ }
+
+ Normalise();
+ }
+
+ public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
+ {
+ SetDiff();
+
+ Random random = new Random(seed);
+
+ int x, y;
+ int i;
+
+ for (i = 0; i < number; i++)
+ {
+ double rx = Math.Min(255.0, random.NextDouble() * w);
+ double ry = Math.Min(255.0, random.NextDouble() * h);
+ double rand = random.NextDouble();
+
+ if (island)
+ {
+ // Move everything towards the center
+ rx -= w / 2;
+ rx /= 2;
+ rx += w / 2;
+
+ ry -= h / 2;
+ ry /= 2;
+ ry += h / 2;
+ }
+
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ if (noisy)
+ rand = random.NextDouble();
+
+ double z = (scale_min + (scale_range * rand));
+ z *= z * z * z;
+ double dx = Math.Abs(x - rx);
+ double dy = Math.Abs(y - ry);
+ z -= (dx * dx * dx * dx) + (dy * dy * dy * dy);
+
+ if (z < 0)
+ z = 0;
+
+ if (additive)
+ {
+ map[x, y] += z;
+ }
+ else
+ {
+ map[x, y] = Math.Max(map[x, y], z);
+ }
+ }
+ }
+ }
+
+ Normalise();
+ }
+
+ }
+}
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs
index 3cefcfe..d40302c 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs
@@ -1,56 +1,56 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace libTerrain
-{
- partial class Channel
- {
- ///
- /// Fills a channel with 0..1 noise
- ///
- /// 3-Clause BSD Licensed
- public void Noise()
- {
- SetDiff();
-
- Random rand = new Random(seed);
- int x, y;
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- map[x, y] = rand.NextDouble();
- }
- }
- }
- }
-}
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace libTerrain
+{
+ partial class Channel
+ {
+ ///
+ /// Fills a channel with 0..1 noise
+ ///
+ /// 3-Clause BSD Licensed
+ public void Noise()
+ {
+ SetDiff();
+
+ Random rand = new Random(seed);
+ int x, y;
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ map[x, y] = rand.NextDouble();
+ }
+ }
+ }
+ }
+}
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs
index 80abfe5..59d877a 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs
@@ -1,156 +1,156 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace libTerrain
-{
- partial class Channel
- {
- private double[] CoordinatesToPolar(int x, int y)
- {
- double theta = Math.Atan2(x - (w / 2), y - (h / 2));
- double rx = (double)x - ((double)w / 2);
- double ry = (double)y - ((double)h / 2);
- double r = Math.Sqrt((rx * rx) + (ry * ry));
-
- double[] coords = new double[2];
- coords[0] = r;
- coords[1] = theta;
- return coords;
- }
-
- public int[] PolarToCoordinates(double r, double theta) {
- double nx;
- double ny;
-
- nx = (double)r * Math.Cos(theta);
- ny = (double)r * Math.Sin(theta);
-
- nx += w / 2;
- ny += h / 2;
-
- if (nx >= w)
- nx = w - 1;
-
- if (ny >= h)
- ny = h - 1;
-
- if (nx < 0)
- nx = 0;
-
- if (ny < 0)
- ny = 0;
-
- int[] coords = new int[2];
- coords[0] = (int)nx;
- coords[1] = (int)ny;
- return coords;
- }
-
- public void Polar()
- {
- SetDiff();
-
- Channel n = this.Copy();
-
- int x, y;
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- double[] coords = CoordinatesToPolar(x,y);
-
- coords[0] += w / 2.0;
- coords[1] += h / 2.0;
-
- map[x, y] = n.map[(int)coords[0] % n.w, (int)coords[1] % n.h];
- }
- }
- }
-
- public void SpiralPlanter(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle)
- {
- SetDiff();
-
- int i;
- double r = offsetRadius;
- double theta = offsetAngle;
- for (i = 0; i < steps; i++)
- {
- r += incRadius;
- theta += incAngle;
-
- int[] coords = PolarToCoordinates(r,theta);
- Raise(coords[0], coords[1], 20, 1);
- }
- }
-
- public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, double[] c)
- {
- SetDiff();
-
- List points = new List();
-
- int i;
- double r = offsetRadius;
- double theta = offsetAngle;
- for (i = 0; i < steps; i++)
- {
- r += incRadius;
- theta += incAngle;
-
- int[] coords = PolarToCoordinates(r, theta);
- points.Add(new Point2D(coords[0],coords[1]));
- }
-
- VoronoiDiagram(points, c);
- }
-
- public void Spiral(double wid, double hig, double offset)
- {
- SetDiff();
-
- int x, y, z;
- z = 0;
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- z++;
- double dx = Math.Abs((w / 2) - x);
- double dy = Math.Abs((h / 2) - y);
- map[x, y] += Math.Sin(dx / wid) + Math.Cos(dy / hig);
- }
- }
- Normalise();
- }
- }
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace libTerrain
+{
+ partial class Channel
+ {
+ private double[] CoordinatesToPolar(int x, int y)
+ {
+ double theta = Math.Atan2(x - (w / 2), y - (h / 2));
+ double rx = (double)x - ((double)w / 2);
+ double ry = (double)y - ((double)h / 2);
+ double r = Math.Sqrt((rx * rx) + (ry * ry));
+
+ double[] coords = new double[2];
+ coords[0] = r;
+ coords[1] = theta;
+ return coords;
+ }
+
+ public int[] PolarToCoordinates(double r, double theta) {
+ double nx;
+ double ny;
+
+ nx = (double)r * Math.Cos(theta);
+ ny = (double)r * Math.Sin(theta);
+
+ nx += w / 2;
+ ny += h / 2;
+
+ if (nx >= w)
+ nx = w - 1;
+
+ if (ny >= h)
+ ny = h - 1;
+
+ if (nx < 0)
+ nx = 0;
+
+ if (ny < 0)
+ ny = 0;
+
+ int[] coords = new int[2];
+ coords[0] = (int)nx;
+ coords[1] = (int)ny;
+ return coords;
+ }
+
+ public void Polar()
+ {
+ SetDiff();
+
+ Channel n = this.Copy();
+
+ int x, y;
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ double[] coords = CoordinatesToPolar(x,y);
+
+ coords[0] += w / 2.0;
+ coords[1] += h / 2.0;
+
+ map[x, y] = n.map[(int)coords[0] % n.w, (int)coords[1] % n.h];
+ }
+ }
+ }
+
+ public void SpiralPlanter(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle)
+ {
+ SetDiff();
+
+ int i;
+ double r = offsetRadius;
+ double theta = offsetAngle;
+ for (i = 0; i < steps; i++)
+ {
+ r += incRadius;
+ theta += incAngle;
+
+ int[] coords = PolarToCoordinates(r,theta);
+ Raise(coords[0], coords[1], 20, 1);
+ }
+ }
+
+ public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, double[] c)
+ {
+ SetDiff();
+
+ List points = new List();
+
+ int i;
+ double r = offsetRadius;
+ double theta = offsetAngle;
+ for (i = 0; i < steps; i++)
+ {
+ r += incRadius;
+ theta += incAngle;
+
+ int[] coords = PolarToCoordinates(r, theta);
+ points.Add(new Point2D(coords[0],coords[1]));
+ }
+
+ VoronoiDiagram(points, c);
+ }
+
+ public void Spiral(double wid, double hig, double offset)
+ {
+ SetDiff();
+
+ int x, y, z;
+ z = 0;
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ z++;
+ double dx = Math.Abs((w / 2) - x);
+ double dy = Math.Abs((h / 2) - y);
+ map[x, y] += Math.Sin(dx / wid) + Math.Cos(dy / hig);
+ }
+ }
+ Normalise();
+ }
+ }
}
\ No newline at end of file
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs
index eb8f7ba..3411ccf 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs
@@ -1,214 +1,214 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace libTerrain
-{
- partial class Channel
- {
- ///
- /// Generates a Voronoi diagram (sort of a stained glass effect) which will fill the entire channel
- ///
- /// 3-Clause BSD Licensed
- /// The number of generator points in each block
- /// A multiple of the channel width and height which will have voronoi points generated in it.
- /// This is to ensure a more even distribution of the points than pure random allocation.
- /// The Voronoi diagram type. Usually an array with values consisting of [-1,1]. Experiment with the chain, you can have as many values as you like.
- public void VoronoiDiagram(int pointsPerBlock, int blockSize, double[] c)
- {
- SetDiff();
-
- List points = new List();
- Random generator = new Random(seed);
-
- // Generate the emitter points
- int x, y, i;
- for (x = -blockSize; x < w + blockSize; x += blockSize)
- {
- for (y = -blockSize; y < h + blockSize; y += blockSize)
- {
- for (i = 0; i < pointsPerBlock; i++)
- {
- double pX = x + (generator.NextDouble() * (double)blockSize);
- double pY = y + (generator.NextDouble() * (double)blockSize);
-
- points.Add(new Point2D(pX, pY));
- }
- }
- }
-
- double[] distances = new double[points.Count];
-
- // Calculate the distance each pixel is from an emitter
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- for (i = 0; i < points.Count; i++)
- {
- double dx, dy;
- dx = Math.Abs((double)x - points[i].x);
- dy = Math.Abs((double)y - points[i].y);
-
- distances[i] = (dx * dx + dy * dy);
- }
-
- Array.Sort(distances);
-
- double f = 0.0;
-
- // Multiply the distances with their 'c' counterpart
- // ordering the distances descending
- for (i = 0; i < c.Length; i++)
- {
- if (i >= points.Count)
- break;
-
- f += c[i] * distances[i];
- }
-
- map[x, y] = f;
- }
- }
-
- // Normalise the result
- Normalise();
- }
-
- public void VoronoiDiagram(List points, double[] c)
- {
- SetDiff();
-
- Random generator = new Random(seed);
- int x, y, i;
- double[] distances = new double[points.Count];
-
- // Calculate the distance each pixel is from an emitter
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- for (i = 0; i < points.Count; i++)
- {
- double dx, dy;
- dx = Math.Abs((double)x - points[i].x);
- dy = Math.Abs((double)y - points[i].y);
-
- distances[i] = (dx * dx + dy * dy);
- }
-
- Array.Sort(distances);
-
- double f = 0.0;
-
- // Multiply the distances with their 'c' counterpart
- // ordering the distances descending
- for (i = 0; i < c.Length; i++)
- {
- if (i >= points.Count)
- break;
-
- f += c[i] * distances[i];
- }
-
- map[x, y] = f;
- }
- }
-
- // Normalise the result
- Normalise();
- }
-
- public void VoroflatDiagram(int pointsPerBlock, int blockSize)
- {
- SetDiff();
-
- List points = new List();
- Random generator = new Random(seed);
-
- // Generate the emitter points
- int x, y, i;
- for (x = -blockSize; x < w + blockSize; x += blockSize)
- {
- for (y = -blockSize; y < h + blockSize; y += blockSize)
- {
- for (i = 0; i < pointsPerBlock; i++)
- {
- double pX = x + (generator.NextDouble() * (double)blockSize);
- double pY = y + (generator.NextDouble() * (double)blockSize);
-
- points.Add(new Point2D(pX, pY));
- }
- }
- }
-
- double[] distances = new double[points.Count];
-
- // Calculate the distance each pixel is from an emitter
- for (x = 0; x < w; x++)
- {
- for (y = 0; y < h; y++)
- {
- for (i = 0; i < points.Count; i++)
- {
- double dx, dy;
- dx = Math.Abs((double)x - points[i].x);
- dy = Math.Abs((double)y - points[i].y);
-
- distances[i] = (dx * dx + dy * dy);
- }
-
- //Array.Sort(distances);
-
- double f = 0.0;
-
- double min = double.MaxValue;
- for (int j = 0; j < distances.Length;j++ )
- {
- if (distances[j] < min)
- {
- min = distances[j];
- f = j;
- }
- }
-
- // Multiply the distances with their 'c' counterpart
- // ordering the distances descending
-
- map[x, y] = f;
- }
- }
-
- // Normalise the result
- Normalise();
- }
- }
-}
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace libTerrain
+{
+ partial class Channel
+ {
+ ///
+ /// Generates a Voronoi diagram (sort of a stained glass effect) which will fill the entire channel
+ ///
+ /// 3-Clause BSD Licensed
+ /// The number of generator points in each block
+ /// A multiple of the channel width and height which will have voronoi points generated in it.
+ /// This is to ensure a more even distribution of the points than pure random allocation.
+ /// The Voronoi diagram type. Usually an array with values consisting of [-1,1]. Experiment with the chain, you can have as many values as you like.
+ public void VoronoiDiagram(int pointsPerBlock, int blockSize, double[] c)
+ {
+ SetDiff();
+
+ List points = new List();
+ Random generator = new Random(seed);
+
+ // Generate the emitter points
+ int x, y, i;
+ for (x = -blockSize; x < w + blockSize; x += blockSize)
+ {
+ for (y = -blockSize; y < h + blockSize; y += blockSize)
+ {
+ for (i = 0; i < pointsPerBlock; i++)
+ {
+ double pX = x + (generator.NextDouble() * (double)blockSize);
+ double pY = y + (generator.NextDouble() * (double)blockSize);
+
+ points.Add(new Point2D(pX, pY));
+ }
+ }
+ }
+
+ double[] distances = new double[points.Count];
+
+ // Calculate the distance each pixel is from an emitter
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (i = 0; i < points.Count; i++)
+ {
+ double dx, dy;
+ dx = Math.Abs((double)x - points[i].x);
+ dy = Math.Abs((double)y - points[i].y);
+
+ distances[i] = (dx * dx + dy * dy);
+ }
+
+ Array.Sort(distances);
+
+ double f = 0.0;
+
+ // Multiply the distances with their 'c' counterpart
+ // ordering the distances descending
+ for (i = 0; i < c.Length; i++)
+ {
+ if (i >= points.Count)
+ break;
+
+ f += c[i] * distances[i];
+ }
+
+ map[x, y] = f;
+ }
+ }
+
+ // Normalise the result
+ Normalise();
+ }
+
+ public void VoronoiDiagram(List points, double[] c)
+ {
+ SetDiff();
+
+ Random generator = new Random(seed);
+ int x, y, i;
+ double[] distances = new double[points.Count];
+
+ // Calculate the distance each pixel is from an emitter
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (i = 0; i < points.Count; i++)
+ {
+ double dx, dy;
+ dx = Math.Abs((double)x - points[i].x);
+ dy = Math.Abs((double)y - points[i].y);
+
+ distances[i] = (dx * dx + dy * dy);
+ }
+
+ Array.Sort(distances);
+
+ double f = 0.0;
+
+ // Multiply the distances with their 'c' counterpart
+ // ordering the distances descending
+ for (i = 0; i < c.Length; i++)
+ {
+ if (i >= points.Count)
+ break;
+
+ f += c[i] * distances[i];
+ }
+
+ map[x, y] = f;
+ }
+ }
+
+ // Normalise the result
+ Normalise();
+ }
+
+ public void VoroflatDiagram(int pointsPerBlock, int blockSize)
+ {
+ SetDiff();
+
+ List points = new List();
+ Random generator = new Random(seed);
+
+ // Generate the emitter points
+ int x, y, i;
+ for (x = -blockSize; x < w + blockSize; x += blockSize)
+ {
+ for (y = -blockSize; y < h + blockSize; y += blockSize)
+ {
+ for (i = 0; i < pointsPerBlock; i++)
+ {
+ double pX = x + (generator.NextDouble() * (double)blockSize);
+ double pY = y + (generator.NextDouble() * (double)blockSize);
+
+ points.Add(new Point2D(pX, pY));
+ }
+ }
+ }
+
+ double[] distances = new double[points.Count];
+
+ // Calculate the distance each pixel is from an emitter
+ for (x = 0; x < w; x++)
+ {
+ for (y = 0; y < h; y++)
+ {
+ for (i = 0; i < points.Count; i++)
+ {
+ double dx, dy;
+ dx = Math.Abs((double)x - points[i].x);
+ dy = Math.Abs((double)y - points[i].y);
+
+ distances[i] = (dx * dx + dy * dy);
+ }
+
+ //Array.Sort(distances);
+
+ double f = 0.0;
+
+ double min = double.MaxValue;
+ for (int j = 0; j < distances.Length;j++ )
+ {
+ if (distances[j] < min)
+ {
+ min = distances[j];
+ f = j;
+ }
+ }
+
+ // Multiply the distances with their 'c' counterpart
+ // ordering the distances descending
+
+ map[x, y] = f;
+ }
+ }
+
+ // Normalise the result
+ Normalise();
+ }
+ }
+}
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs
index ce36daf..ba2fad6 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs
@@ -1,74 +1,74 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace libTerrain
-{
- partial class Channel
- {
- ///
- /// Generates 'number' of worms which navigate randomly around the landscape creating terrain as they go.
- ///
- /// The number of worms which will traverse the map
- /// The number of steps each worm will traverse
- /// The maximum distance each worm will move each step
- /// The size of the area around the worm modified
- /// Do worms start in the middle, or randomly?
- public void Worms(int number, int rounds, double movement, double size, bool centerspawn)
- {
- SetDiff();
-
- Random random = new Random(seed);
- int i, j;
-
- for (i = 0; i < number; i++)
- {
- double rx, ry;
- if (centerspawn)
- {
- rx = w / 2.0;
- ry = h / 2.0;
- }
- else
- {
- rx = random.NextDouble() * (w - 1);
- ry = random.NextDouble() * (h - 1);
- }
- for (j = 0; j < rounds; j++)
- {
- rx += (random.NextDouble() * movement) - (movement / 2.0);
- ry += (random.NextDouble() * movement) - (movement / 2.0);
- Raise(rx, ry, size, 1.0);
- }
- }
- }
- }
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace libTerrain
+{
+ partial class Channel
+ {
+ ///
+ /// Generates 'number' of worms which navigate randomly around the landscape creating terrain as they go.
+ ///
+ /// The number of worms which will traverse the map
+ /// The number of steps each worm will traverse
+ /// The maximum distance each worm will move each step
+ /// The size of the area around the worm modified
+ /// Do worms start in the middle, or randomly?
+ public void Worms(int number, int rounds, double movement, double size, bool centerspawn)
+ {
+ SetDiff();
+
+ Random random = new Random(seed);
+ int i, j;
+
+ for (i = 0; i < number; i++)
+ {
+ double rx, ry;
+ if (centerspawn)
+ {
+ rx = w / 2.0;
+ ry = h / 2.0;
+ }
+ else
+ {
+ rx = random.NextDouble() * (w - 1);
+ ry = random.NextDouble() * (h - 1);
+ }
+ for (j = 0; j < rounds; j++)
+ {
+ rx += (random.NextDouble() * movement) - (movement / 2.0);
+ ry += (random.NextDouble() * movement) - (movement / 2.0);
+ Raise(rx, ry, size, 1.0);
+ }
+ }
+ }
+ }
}
\ No newline at end of file
--
cgit v1.1