public void Generate(IScene scene, string[] s)
 {
     //string noiseGen = MainConsole.Instance.CmdPrompt("Noise generator (Perlin or Kosh)", "Perlin", new List<string>(new [] { "Perlin", "Kosh" }));
     //if(noiseGen == "Perlin")
     {
         _noiseGen = m_perlinNoise;
         PerlinNoiseSettings pns = new PerlinNoiseSettings();
         pns.ResultX = scene.RegionInfo.RegionSizeX;
         pns.ResultY = scene.RegionInfo.RegionSizeY;
         pns.RandomSeed = int.Parse(MainConsole.Instance.Prompt("Random Seed (0-infinity)", "10"));
         pns.CorsenessX = int.Parse(MainConsole.Instance.Prompt("Corseness (X direction) (2-1000)", "100"));
         pns.CorsenessY = int.Parse(MainConsole.Instance.Prompt("Corseness (Y direction) (2-1000)", "100"));
         pns.FlatEdges = MainConsole.Instance.Prompt("Flat Edges (recommended)", "true", new List<string>(new[] { "true", "false" })) == "true";
         pns.Octaves = int.Parse(MainConsole.Instance.Prompt("Octaves (0-infinity)", "5"));
         pns.Persistence = float.Parse(MainConsole.Instance.Prompt("Persistence", "0.8"));
         _noiseGen.Settings = pns;
     }
     /*else
     {
         _noiseGen = m_kochLikeNoise;
         KochLikeNoiseSettings kns = new KochLikeNoiseSettings();
         kns.ResultX = MainConsole.Instance.Prompt.RegionInfo.RegionSizeX;
         kns.ResultY = MainConsole.Instance.Prompt.RegionInfo.RegionSizeY;
         kns.H = double.Parse(MainConsole.Instance.Prompt("H", "1.0"));
         kns.InitalGridX = int.Parse(MainConsole.Instance.Prompt("Initial Grid X", "2"));
         if(kns.InitalGridX < 2)
             kns.InitalGridX = 2;
         kns.InitalGridY = int.Parse(MainConsole.Instance.Prompt("Initial Grid Y", "2"));
         if(kns.InitalGridY < 2)
             kns.InitalGridY = 2;
         kns.RandomMin = int.Parse(MainConsole.Instance.Prompt("Random Min", "-1"));
         kns.RandomMax = int.Parse(MainConsole.Instance.Prompt("Random Max", "1"));
         kns.RandomSeed = int.Parse(MainConsole.Instance.Prompt("Random Seed", "0"));
         kns.Scale = double.Parse(MainConsole.Instance.Prompt("Scale", "1.0"));
         _noiseGen.Settings = kns;
     }*/
     float scaling = float.Parse(MainConsole.Instance.Prompt("Fractal Scaling", "50"));
     float[,] land = _noiseGen.Generate();
     ITerrainChannel c = new TerrainChannel(scene);
     for(int x = 0; x < scene.RegionInfo.RegionSizeX; x++)
     {
         for(int y = 0; y < scene.RegionInfo.RegionSizeY; y++)
         {
             c[x, y] = (land[x, y] * scaling) + (float)scene.RegionInfo.RegionSettings.WaterHeight + 10;
         }
     }
     scene.RequestModuleInterface<ITerrainModule>().TerrainMap = c;
     scene.RequestModuleInterface<ITerrainModule>().TaintTerrain();
     scene.RegisterModuleInterface<ITerrainChannel>(c);
 }
        public void GenerateTerrain(IScene scene, string[] s)
        {
            string noiseType = MainConsole.Instance.Prompt("Noise generator (Perlin or Kosh)", "Perlin");
            bool perlinNoise = noiseType.ToLower().StartsWith("p");
            int baseHeight;

            if (perlinNoise)
            {
                _noiseGen = m_perlinNoise;
                PerlinNoiseSettings pns = new PerlinNoiseSettings();
                pns.ResultX = scene.RegionInfo.RegionSizeX;
                pns.ResultY = scene.RegionInfo.RegionSizeY;
                pns.RandomSeed = int.Parse(MainConsole.Instance.Prompt("Random Seed (0-infinity)", "10"));
                pns.CorsenessX = int.Parse(MainConsole.Instance.Prompt("Coarseness (X direction) (2-1000)", "100"));
                pns.CorsenessY = int.Parse(MainConsole.Instance.Prompt("Coarseness (Y direction) (2-1000)", "100"));
                pns.FlatEdges = MainConsole.Instance.Prompt("Flat Edges (recommended)", "true", new List<string>(new[] { "true", "false" })) == "true";
                pns.Octaves = int.Parse(MainConsole.Instance.Prompt("Octaves (0-infinity)", "5"));
                pns.Persistence = float.Parse(MainConsole.Instance.Prompt("Persistence", "0.8"));
                _noiseGen.Settings = pns;
                baseHeight = 30;
            }
            else
            {
                _noiseGen = m_kochLikeNoise;
                KochLikeNoiseSettings kns = new KochLikeNoiseSettings();
                //kns.ResultX = MainConsole.Instance.Prompt.RegionInfo.RegionSizeX;
                //kns.ResultY = MainConsole.Instance.Prompt.RegionInfo.RegionSizeY;
                kns.ResultX = scene.RegionInfo.RegionSizeX * 2;
                kns.ResultY = scene.RegionInfo.RegionSizeY * 2;
                kns.H = double.Parse(MainConsole.Instance.Prompt("Smoothing (Higher values are smoother)", "1.5"));
                kns.InitalGridX = int.Parse(MainConsole.Instance.Prompt("Initial Grid X", "2"));
                if(kns.InitalGridX < 2)
                    kns.InitalGridX = 2;
                kns.InitalGridY = int.Parse(MainConsole.Instance.Prompt("Initial Grid Y", "2"));
                if(kns.InitalGridY < 2)
                    kns.InitalGridY = 2;
                // grid X/Y divide the region so...
                //                kns.ResultX = kns.ResultX * kns.InitalGridX;
                //                kns.ResultY = kns.ResultY * kns.InitalGridY;

                kns.RandomMin = int.Parse(MainConsole.Instance.Prompt("Random Min", "-1"));
                kns.RandomMax = int.Parse(MainConsole.Instance.Prompt("Random Max", "1"));
                kns.RandomSeed = int.Parse(MainConsole.Instance.Prompt("Random Seed", "0"));
                kns.Scale = double.Parse(MainConsole.Instance.Prompt("Scale", "1.0"));

                _noiseGen.Settings = kns;
                baseHeight = 0;
            }

            float scaling = float.Parse(MainConsole.Instance.Prompt("Fractal Scaling", "50"));
            float[,] land = _noiseGen.Generate();
            ITerrainChannel c = new TerrainChannel(scene);
            for(int x = 0; x < scene.RegionInfo.RegionSizeX; x++)
            {
                for(int y = 0; y < scene.RegionInfo.RegionSizeY; y++)
                {
                    c[x, y] = (land[x, y] * scaling) + (float)scene.RegionInfo.RegionSettings.WaterHeight + baseHeight;
                }
            }
            scene.RequestModuleInterface<ITerrainModule>().TerrainMap = c;
            scene.RequestModuleInterface<ITerrainModule>().TaintTerrain();
            scene.RegisterModuleInterface<ITerrainChannel>(c);
        }
        public PerlinGenerator(int seed, int size)
        {
            PerlinNoiseSettings objSettings = new PerlinNoiseSettings();

            objSettings.RandomSeed = seed;
            objSettings.ResultX = size;
            objSettings.ResultY = size;

            _settings = objSettings;
        }
 public PerlinNoise()
 {
     _settings = new PerlinNoiseSettings();
 }