aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
blob: f805d18d7e08dd1f7227874a37fa507ff4f9ed9a (plain)
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
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Terrain.BasicTerrain;

namespace OpenSim.Terrain
{
    public class TerrainEngine
    {
        public float[,] map;
        public float[,] water;
        int w, h;

        public TerrainEngine()
        {
            w = 256;
            h = 256;
            map = new float[w, h];
            water = new float[w, h];

        }

        /// <summary>
        /// Swaps the references between the height and water buffers to allow you to edit the water heightmap. Remember to swap back when you are done.
        /// </summary>
        public void swapWaterBuffer()
        {
            float[,] temp = map;
            map = water;
            water = temp;
        }

        /// <summary>
        /// Raises land in a sphere around the specified coordinates
        /// </summary>
        /// <param name="rx">Center of the sphere on the X axis</param>
        /// <param name="ry">Center of the sphere on the Y axis</param>
        /// <param name="size">The radius of the sphere</param>
        /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
        public void raise(double rx, double ry, double size, double amount)
        {
            lock (map)
            {
                RaiseLower.raiseSphere(this.map, rx, ry, size, amount);
            }
        }
        public void lower(double rx, double ry, double size, double amount)
        {
            lock (map)
            {
                RaiseLower.lowerSphere(this.map, rx, ry, size, amount);
            }
        }

        public void hills()
        {
            lock (map)
            {
                Hills.hillsSpheres(this.map, 1337, 200, 20, 40, true, true, false);
            }
        }

    }
}