aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Terrain.BasicTerrain
diff options
context:
space:
mode:
authorAdam Frisby2007-04-07 17:30:11 +0000
committerAdam Frisby2007-04-07 17:30:11 +0000
commitc070d2bbf3eca682166d9e1875aff194c61c3154 (patch)
treefa88ec114052d660efe30b6cfbecd86007b65154 /OpenSim.Terrain.BasicTerrain
parentTerrain can now import from a specially formatted file. (diff)
downloadopensim-SC_OLD-c070d2bbf3eca682166d9e1875aff194c61c3154.zip
opensim-SC_OLD-c070d2bbf3eca682166d9e1875aff194c61c3154.tar.gz
opensim-SC_OLD-c070d2bbf3eca682166d9e1875aff194c61c3154.tar.bz2
opensim-SC_OLD-c070d2bbf3eca682166d9e1875aff194c61c3154.tar.xz
ZOMG Comments!
Diffstat (limited to '')
-rw-r--r--OpenSim.Terrain.BasicTerrain/Normalise.cs19
-rw-r--r--OpenSim.Terrain.BasicTerrain/TerrainEngine.cs20
2 files changed, 39 insertions, 0 deletions
diff --git a/OpenSim.Terrain.BasicTerrain/Normalise.cs b/OpenSim.Terrain.BasicTerrain/Normalise.cs
index 507795b..0d37f44 100644
--- a/OpenSim.Terrain.BasicTerrain/Normalise.cs
+++ b/OpenSim.Terrain.BasicTerrain/Normalise.cs
@@ -6,6 +6,10 @@ namespace OpenSim.Terrain.BasicTerrain
6{ 6{
7 static class Normalise 7 static class Normalise
8 { 8 {
9 /// <summary>
10 /// Converts the heightmap to values ranging from 0..1
11 /// </summary>
12 /// <param name="map">The heightmap to be normalised</param>
9 public static void normalise(float[,] map) 13 public static void normalise(float[,] map)
10 { 14 {
11 double max = findMax(map); 15 double max = findMax(map);
@@ -24,6 +28,11 @@ namespace OpenSim.Terrain.BasicTerrain
24 } 28 }
25 } 29 }
26 30
31 /// <summary>
32 /// Converts the heightmap to values ranging from 0..<newmax>
33 /// </summary>
34 /// <param name="map">The heightmap to be normalised</param>
35 /// <param name="newmax">The new maximum height value of the map</param>
27 public static void normalise(float[,] map, double newmax) 36 public static void normalise(float[,] map, double newmax)
28 { 37 {
29 double max = findMax(map); 38 double max = findMax(map);
@@ -42,6 +51,11 @@ namespace OpenSim.Terrain.BasicTerrain
42 } 51 }
43 } 52 }
44 53
54 /// <summary>
55 /// Finds the largest value in the heightmap
56 /// </summary>
57 /// <param name="map">The heightmap</param>
58 /// <returns>The highest value</returns>
45 public static double findMax(float[,] map) 59 public static double findMax(float[,] map)
46 { 60 {
47 int x, y; 61 int x, y;
@@ -61,6 +75,11 @@ namespace OpenSim.Terrain.BasicTerrain
61 return max; 75 return max;
62 } 76 }
63 77
78 /// <summary>
79 /// Finds the lowest value in a heightmap
80 /// </summary>
81 /// <param name="map">The heightmap</param>
82 /// <returns>The minimum value</returns>
64 public static double findMin(float[,] map) 83 public static double findMin(float[,] map)
65 { 84 {
66 int x, y; 85 int x, y;
diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
index 45da742..87dbf7e 100644
--- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
@@ -7,10 +7,19 @@ namespace OpenSim.Terrain
7{ 7{
8 public class TerrainEngine 8 public class TerrainEngine
9 { 9 {
10 /// <summary>
11 /// A [normally] 256x256 heightmap
12 /// </summary>
10 public float[,] map; 13 public float[,] map;
14 /// <summary>
15 /// A 256x256 heightmap storing water height values
16 /// </summary>
11 public float[,] water; 17 public float[,] water;
12 int w, h; 18 int w, h;
13 19
20 /// <summary>
21 /// Generate a new TerrainEngine instance and creates a new heightmap
22 /// </summary>
14 public TerrainEngine() 23 public TerrainEngine()
15 { 24 {
16 w = 256; 25 w = 256;
@@ -90,6 +99,14 @@ namespace OpenSim.Terrain
90 RaiseLower.raiseSphere(this.map, rx, ry, size, amount); 99 RaiseLower.raiseSphere(this.map, rx, ry, size, amount);
91 } 100 }
92 } 101 }
102
103 /// <summary>
104 /// Lowers the land in a sphere around the specified coordinates
105 /// </summary>
106 /// <param name="rx">The center of the sphere at the X axis</param>
107 /// <param name="ry">The center of the sphere at the Y axis</param>
108 /// <param name="size">The radius of the sphere in meters</param>
109 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
93 public void lower(double rx, double ry, double size, double amount) 110 public void lower(double rx, double ry, double size, double amount)
94 { 111 {
95 lock (map) 112 lock (map)
@@ -98,6 +115,9 @@ namespace OpenSim.Terrain
98 } 115 }
99 } 116 }
100 117
118 /// <summary>
119 /// Generates a simple set of hills in the shape of an island
120 /// </summary>
101 public void hills() 121 public void hills()
102 { 122 {
103 lock (map) 123 lock (map)