From a2009ffe2e71afefad79471811418df8958870ab Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 16 Mar 2012 13:08:05 -0700 Subject: Terrain: added [Terrain] section with an option to load an initial flat terrain. Default is still pinhead island. I much rather have a flat land in the beginning. --- OpenSim/Region/Framework/Scenes/TerrainChannel.cs | 60 +++++++++++++++++------ 1 file changed, 44 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes/TerrainChannel.cs') diff --git a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs index ca6210d..c0ca48e 100644 --- a/OpenSim/Region/Framework/Scenes/TerrainChannel.cs +++ b/OpenSim/Region/Framework/Scenes/TerrainChannel.cs @@ -46,23 +46,20 @@ namespace OpenSim.Region.Framework.Scenes public TerrainChannel() { map = new double[Constants.RegionSize, Constants.RegionSize]; - taint = new bool[Constants.RegionSize / 16,Constants.RegionSize / 16]; + taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; - int x; - for (x = 0; x < Constants.RegionSize; x++) - { - int y; - for (y = 0; y < Constants.RegionSize; y++) - { - map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; - double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01; - double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001; - if (map[x, y] < spherFacA) - map[x, y] = spherFacA; - if (map[x, y] < spherFacB) - map[x, y] = spherFacB; - } - } + PinHeadIsland(); + } + + public TerrainChannel(String type) + { + map = new double[Constants.RegionSize, Constants.RegionSize]; + taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; + + if (type.Equals("flat")) + FlatLand(); + else + PinHeadIsland(); } public TerrainChannel(double[,] import) @@ -238,5 +235,36 @@ namespace OpenSim.Region.Framework.Scenes } } } + + private void PinHeadIsland() + { + int x; + for (x = 0; x < Constants.RegionSize; x++) + { + int y; + for (y = 0; y < Constants.RegionSize; y++) + { + map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10; + double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01; + double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001; + if (map[x, y] < spherFacA) + map[x, y] = spherFacA; + if (map[x, y] < spherFacB) + map[x, y] = spherFacB; + } + } + } + + private void FlatLand() + { + int x; + for (x = 0; x < Constants.RegionSize; x++) + { + int y; + for (y = 0; y < Constants.RegionSize; y++) + map[x, y] = 21; + } + } + } } -- cgit v1.1