예제 #1
0
        void Awake()
        {
            skin = (GUISkin)GUISkin.Instantiate(HighLogic.Skin);
            skin.button.padding    = new RectOffset(2, 2, 2, 2);
            skin.button.margin     = new RectOffset(1, 1, 1, 1);
            skin.box.padding       = new RectOffset(2, 2, 2, 2);
            skin.box.margin        = new RectOffset(1, 1, 1, 1);
            skin.textField.margin  = new RectOffset(3, 1, 1, 1);
            skin.textField.padding = new RectOffset(4, 2, 1, 0);

            if (!RegisterWithFAR())
            {
                this.enabled = false;
            }

            LoadConfig();
            LoadSettings();
            InitializeToolbars();
            OnGuiVisibilityChange();

            simplexNoise = new OpenSimplex2S(HighLogic.CurrentGame.Seed);

            currentWindSpeed = oldWindSpeed = newWindSpeed = 0f;
            currentWindDir   = oldWindDir = newWindDir = -1f;
            blendStart       = 0;
            blendDuration    = 0;
            weatherLat       = -1000f;
            weatherLng       = -1000f;
            weatherTime      = -1f;

            CalculateWeather();
            gustsmodel.Init(config);
            ComputeWindVector();
        }
예제 #2
0
 /// <summary>
 /// The constructor for the singleton GameData
 /// </summary>
 public GameData()
 {
     simplex = new OpenSimplex2S(worldGenerator.seed);
     chunks  = new Dictionary <Vector2Int, Chunk>();
 }
예제 #3
0
        private void generateButton_Click(object sender, EventArgs e)
        {
            if (widthInputBox.Value != 0 && heightInputBox.Value != 0)
            {
                Random random = new Random();
                heightBitmap = new Bitmap(Convert.ToInt32(widthInputBox.Value), Convert.ToInt32(heightInputBox.Value));
                blendBitmap  = new Bitmap(Convert.ToInt32(widthInputBox.Value), Convert.ToInt32(heightInputBox.Value));

                long seed = useRandomSeedCheckBox.Checked ? random.Next(int.MinValue, int.MaxValue) : Convert.ToInt64(seedInputBox.Value);

                int coordinateMultiplier = 1;

                double finalMax = 1d;
                double value;

                Text = "HeightMapGen - Working...";

                if (useFastLibraryRadioButton.Checked)
                {
                    OpenSimplex2F noiseLibrary = new OpenSimplex2F(seed);

                    for (int x = 0; x < widthInputBox.Value; x++)
                    {
                        for (int y = 0; y < heightInputBox.Value; y++)
                        {
                            value = normalizeValue(noiseLibrary.Noise2(x / Convert.ToDouble(resolutionInputBox.Value), y / Convert.ToDouble(resolutionInputBox.Value)), 1d, -1d, 1d, 0d);

                            for (int o = 1; o - 1 < octavesInputBox.Value; o++)
                            {
                                finalMax += 1d / Math.Pow(2, o);

                                value += 1d / Math.Pow(2, o) * normalizeValue(noiseLibrary.Noise2(Math.Pow(2, o) * (x / Convert.ToDouble(resolutionInputBox.Value)), Math.Pow(2, o) * (y / Convert.ToDouble(resolutionInputBox.Value))), 1d, -1d, 1d, 0d);
                                coordinateMultiplier = coordinateMultiplier * 2;
                            }

                            mapValue(x, y, value, finalMax, Convert.ToDouble(exponentInputBox.Value));
                        }
                    }
                }
                else
                {
                    OpenSimplex2S noiseLibrary = new OpenSimplex2S(seed);

                    for (int x = 0; x < widthInputBox.Value; x++)
                    {
                        for (int y = 0; y < heightInputBox.Value; y++)
                        {
                            value = normalizeValue(noiseLibrary.Noise2(x / Convert.ToDouble(resolutionInputBox.Value), y / Convert.ToDouble(resolutionInputBox.Value)), 1d, -1d, 1d, 0d);

                            for (int o = 1; o - 1 < octavesInputBox.Value; o++)
                            {
                                finalMax += 1d / Math.Pow(2, o);

                                value += 1d / Math.Pow(2, o) * normalizeValue(noiseLibrary.Noise2(Math.Pow(2, o) * (x / Convert.ToDouble(resolutionInputBox.Value)), Math.Pow(2, o) * (y / Convert.ToDouble(resolutionInputBox.Value))), 1d, -1d, 1d, 0d);
                                coordinateMultiplier = coordinateMultiplier * 2;
                            }

                            mapValue(x, y, value, finalMax, Convert.ToDouble(exponentInputBox.Value));
                            finalMax = 1d;
                        }
                    }
                }

                heightMapImageBox.Image = heightBitmap;
                blendMapImageBox.Image  = blendBitmap;

                Text = "HeightMapGen";
            }
        }