using System; using System.Collections.Generic; using System.Text; namespace OpenSim.Terrain.BasicTerrain { static class RaiseLower { /// /// Raises land around the selection /// /// The center the X coordinate of where you wish to raise the land /// The center the Y coordinate of where you wish to raise the land /// The radius of the dimple /// How much impact to add to the terrain (0..2 usually) public static void raise(float[,] map, double rx, double ry, double size, double amount) { raiseSphere(map, rx, ry, size, amount); } /// /// Raises land in a sphere around the selection /// /// The center the X coordinate of where you wish to raise the land /// The center the Y coordinate of where you wish to raise the land /// The radius of the sphere dimple /// How much impact to add to the terrain (0..2 usually) public static void raiseSphere(float[,] map, double rx, double ry, double size, double amount) { int x, y; int w = map.GetLength(0); int h = map.GetLength(1); 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; map[x, y] += (float)(z * amount); } } } /// /// Lowers land in a sphere around the selection /// /// The center the X coordinate of where you wish to lower the land /// The center the Y coordinate of where you wish to lower the land /// The radius of the sphere dimple /// How much impact to remove from the terrain (0..2 usually) public static void lower(float[,] map, double rx, double ry, double size, double amount) { lowerSphere(map, rx, ry, size, amount); } /// /// Lowers land in a sphere around the selection /// /// The center the X coordinate of where you wish to lower the land /// The center the Y coordinate of where you wish to lower the land /// The radius of the sphere dimple /// How much impact to remove from the terrain (0..2 usually) public static void lowerSphere(float[,] map, double rx, double ry, double size, double amount) { int x, y; int w = map.GetLength(0); int h = map.GetLength(1); 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; map[x, y] -= (float)(z * amount); } } } } }