1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Terrain.BasicTerrain
{
static class RaiseLower
{
/// <summary>
/// Raises land around the selection
/// </summary>
/// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
/// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
/// <param name="size">The radius of the dimple</param>
/// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
public static void raise(float[,] map, double rx, double ry, double size, double amount)
{
raiseSphere(map, rx, ry, size, amount);
}
/// <summary>
/// Raises land in a sphere around the selection
/// </summary>
/// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
/// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
/// <param name="size">The radius of the sphere dimple</param>
/// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
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);
}
}
}
/// <summary>
/// Lowers land in a sphere around the selection
/// </summary>
/// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
/// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
/// <param name="size">The radius of the sphere dimple</param>
/// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
public static void lower(float[,] map, double rx, double ry, double size, double amount)
{
lowerSphere(map, rx, ry, size, amount);
}
/// <summary>
/// Lowers land in a sphere around the selection
/// </summary>
/// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
/// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
/// <param name="size">The radius of the sphere dimple</param>
/// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
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);
}
}
}
}
}
|