ZOMG Comments!

0.1-prestable
Adam Frisby 2007-04-07 17:30:11 +00:00
parent c18cf96824
commit c070d2bbf3
2 changed files with 39 additions and 0 deletions

View File

@ -6,6 +6,10 @@ namespace OpenSim.Terrain.BasicTerrain
{
static class Normalise
{
/// <summary>
/// Converts the heightmap to values ranging from 0..1
/// </summary>
/// <param name="map">The heightmap to be normalised</param>
public static void normalise(float[,] map)
{
double max = findMax(map);
@ -24,6 +28,11 @@ namespace OpenSim.Terrain.BasicTerrain
}
}
/// <summary>
/// Converts the heightmap to values ranging from 0..<newmax>
/// </summary>
/// <param name="map">The heightmap to be normalised</param>
/// <param name="newmax">The new maximum height value of the map</param>
public static void normalise(float[,] map, double newmax)
{
double max = findMax(map);
@ -42,6 +51,11 @@ namespace OpenSim.Terrain.BasicTerrain
}
}
/// <summary>
/// Finds the largest value in the heightmap
/// </summary>
/// <param name="map">The heightmap</param>
/// <returns>The highest value</returns>
public static double findMax(float[,] map)
{
int x, y;
@ -61,6 +75,11 @@ namespace OpenSim.Terrain.BasicTerrain
return max;
}
/// <summary>
/// Finds the lowest value in a heightmap
/// </summary>
/// <param name="map">The heightmap</param>
/// <returns>The minimum value</returns>
public static double findMin(float[,] map)
{
int x, y;

View File

@ -7,10 +7,19 @@ namespace OpenSim.Terrain
{
public class TerrainEngine
{
/// <summary>
/// A [normally] 256x256 heightmap
/// </summary>
public float[,] map;
/// <summary>
/// A 256x256 heightmap storing water height values
/// </summary>
public float[,] water;
int w, h;
/// <summary>
/// Generate a new TerrainEngine instance and creates a new heightmap
/// </summary>
public TerrainEngine()
{
w = 256;
@ -90,6 +99,14 @@ namespace OpenSim.Terrain
RaiseLower.raiseSphere(this.map, rx, ry, size, amount);
}
}
/// <summary>
/// Lowers the land in a sphere around the specified coordinates
/// </summary>
/// <param name="rx">The center of the sphere at the X axis</param>
/// <param name="ry">The center of the sphere at the Y axis</param>
/// <param name="size">The radius of the sphere in meters</param>
/// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
public void lower(double rx, double ry, double size, double amount)
{
lock (map)
@ -98,6 +115,9 @@ namespace OpenSim.Terrain
}
}
/// <summary>
/// Generates a simple set of hills in the shape of an island
/// </summary>
public void hills()
{
lock (map)