aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Terrain.BasicTerrain/Hills.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-04-11 05:19:27 +0000
committerAdam Frisby2007-04-11 05:19:27 +0000
commitadb56a46f49127911a2df169c86f2cdfde034966 (patch)
treec5a7b5e279f93538c9506f630b7304b9d55e93e8 /OpenSim.Terrain.BasicTerrain/Hills.cs
parent(no commit message) (diff)
downloadopensim-SC_OLD-adb56a46f49127911a2df169c86f2cdfde034966.zip
opensim-SC_OLD-adb56a46f49127911a2df169c86f2cdfde034966.tar.gz
opensim-SC_OLD-adb56a46f49127911a2df169c86f2cdfde034966.tar.bz2
opensim-SC_OLD-adb56a46f49127911a2df169c86f2cdfde034966.tar.xz
Major ass changes to terrain (now uses libTerrain-BSD!) and all-round improvements to code quality. Terrain saving/loading may work now (running through setHeights1D and getHeights1D before DB4o) **WARNING: UNTESTED**
Diffstat (limited to 'OpenSim.Terrain.BasicTerrain/Hills.cs')
-rw-r--r--OpenSim.Terrain.BasicTerrain/Hills.cs72
1 files changed, 0 insertions, 72 deletions
diff --git a/OpenSim.Terrain.BasicTerrain/Hills.cs b/OpenSim.Terrain.BasicTerrain/Hills.cs
deleted file mode 100644
index 40543a9..0000000
--- a/OpenSim.Terrain.BasicTerrain/Hills.cs
+++ /dev/null
@@ -1,72 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Terrain.BasicTerrain
6{
7 static class Hills
8 {
9 /// <summary>
10 /// Generates a series of spheres which are then either max()'d or added together. Inspired by suggestion from jh.
11 /// </summary>
12 /// <remarks>3-Clause BSD Licensed</remarks>
13 /// <param name="number">The number of hills to generate</param>
14 /// <param name="scale_min">The minimum size of each hill</param>
15 /// <param name="scale_range">The maximum size of each hill</param>
16 /// <param name="island">Whether to bias hills towards the center of the map</param>
17 /// <param name="additive">Whether to add hills together or to pick the largest value</param>
18 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param>
19 public static void hillsSpheres(float[,] map,int seed, int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
20 {
21 Random random = new Random(seed);
22 int w = map.GetLength(0);
23 int h = map.GetLength(1);
24 int x, y;
25 int i;
26
27 for (i = 0; i < number; i++)
28 {
29 double rx = Math.Min(255.0, random.NextDouble() * w);
30 double ry = Math.Min(255.0, random.NextDouble() * h);
31 double rand = random.NextDouble();
32
33 if (island)
34 {
35 // Move everything towards the center
36 rx -= w / 2;
37 rx /= 2;
38 rx += w / 2;
39
40 ry -= h / 2;
41 ry /= 2;
42 ry += h / 2;
43 }
44
45 for (x = 0; x < w; x++)
46 {
47 for (y = 0; y < h; y++)
48 {
49 if (noisy)
50 rand = random.NextDouble();
51
52 double z = (scale_min + (scale_range * rand));
53 z *= z;
54 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
55
56 if (z < 0)
57 z = 0;
58
59 if (additive)
60 {
61 map[x, y] += (float)z;
62 }
63 else
64 {
65 map[x, y] = (float)Math.Max(map[x, y], z);
66 }
67 }
68 }
69 }
70 }
71 }
72}