OpenSimMirror/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs

85 lines
2.3 KiB
C#
Raw Normal View History

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];
}
public float[] getHeights1D()
{
float[] heights = new float[w*h];
int i;
for(i=0;i<w*h;i++) {
2007-04-07 16:05:45 +00:00
heights[i] = map[i / w, i % w];
}
return heights;
}
public void setHeights1D(float[] heights)
{
int i;
for (i = 0; i < w * h; i++)
{
map[i / w, i % w] = heights[i];
}
}
/// <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);
2007-04-07 16:19:49 +00:00
Normalise.normalise(this.map,60);
}
}
}
}