Пример #1
0
 public SettingsForm()
 {
     InitializeComponent();
     terrain         = new TerrainSettings();
     trackBar1.Value = terrain.GetInt(TerrainSettings.Setting.SampleDepth);
     trackBar1_Scroll(null, null);
     vScrollBar1.Value       = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA0)) * 100);
     vScrollBar2.Value       = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA1)) * 100);
     vScrollBar3.Value       = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA2)) * 100);
     vScrollBar4.Value       = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA3)) * 100);
     vScrollBar5.Value       = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA4)) * 100);
     vScrollBar6.Value       = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA5)) * 100);
     vScrollBar7.Value       = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA6)) * 100);
     label2.Text             = terrain.GetInt(TerrainSettings.Setting.SampleDepth).ToString();
     trackBar2.Value         = (int)(terrain.GetFloat(TerrainSettings.Setting.RotateSpeed) * 2);
     comboBox1.SelectedIndex = terrain.GetInt(TerrainSettings.Setting.LightMode);
     comboBox2.SelectedIndex = terrain.GetInt(TerrainSettings.Setting.FillMode);
 }
 public SettingsForm()
 {
     InitializeComponent();
     terrain = new TerrainSettings();
     trackBar1.Value = terrain.GetInt(TerrainSettings.Setting.SampleDepth);
     trackBar1_Scroll(null, null);
     vScrollBar1.Value = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA0)) * 100);
     vScrollBar2.Value = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA1)) * 100);
     vScrollBar3.Value = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA2)) * 100);
     vScrollBar4.Value = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA3)) * 100);
     vScrollBar5.Value = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA4)) * 100);
     vScrollBar6.Value = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA5)) * 100);
     vScrollBar7.Value = (int)((1 - terrain.GetFloat(TerrainSettings.Setting.DNA6)) * 100);
     label2.Text = terrain.GetInt(TerrainSettings.Setting.SampleDepth).ToString();
     trackBar2.Value = (int) (terrain.GetFloat(TerrainSettings.Setting.RotateSpeed) * 2);
     comboBox1.SelectedIndex = terrain.GetInt(TerrainSettings.Setting.LightMode);
     comboBox2.SelectedIndex = terrain.GetInt(TerrainSettings.Setting.FillMode);
 }
Пример #3
0
        private void LoadSettings()
        {
            if (controlPanel != null)
            {
                terrainSettings.CopyFrom(controlPanel.GetTerrain());
            }
            else
            {
                if (terrainSettings == null)
                {
                    terrainSettings = new TerrainSettings();
                }
            }


            DNA    = new float[7];
            DNA[0] = terrainSettings.GetFloat(TerrainSettings.Setting.DNA0);
            DNA[1] = terrainSettings.GetFloat(TerrainSettings.Setting.DNA1);
            DNA[2] = terrainSettings.GetFloat(TerrainSettings.Setting.DNA2);
            DNA[3] = terrainSettings.GetFloat(TerrainSettings.Setting.DNA3);
            DNA[4] = terrainSettings.GetFloat(TerrainSettings.Setting.DNA4);
            DNA[5] = terrainSettings.GetFloat(TerrainSettings.Setting.DNA5);
            DNA[6] = terrainSettings.GetFloat(TerrainSettings.Setting.DNA6);

            int tempFillMode = terrainSettings.GetInt(TerrainSettings.Setting.FillMode);

            if (fillMode != tempFillMode)
            {
                SetFillMode(tempFillMode);
            }

            int tempLightMode = terrainSettings.GetInt(TerrainSettings.Setting.LightMode);

            if (lightMode != tempLightMode)
            {
                SetLightMode(tempLightMode);
            }

            rotateSpeed = terrainSettings.GetFloat(TerrainSettings.Setting.RotateSpeed);

            levelOfDetail = terrainSettings.GetInt(TerrainSettings.Setting.SampleDepth);


            if (terrainSettings.GetAction(TerrainSettings.Action.Generate))
            {
                Generate();
            }

            if (terrainSettings.GetAction(TerrainSettings.Action.UpSample))
            {
                if (CanUpsample())
                {
                    heightMap.UpSample(DNA);
                    heightMap.CalcVerticesIndices(SIZE);
                    LoadMesh();
                }
            }

            if (terrainSettings.GetAction(TerrainSettings.Action.DownSample))
            {
                heightMap.DownSample();
                heightMap.CalcVerticesIndices(SIZE);
                LoadMesh();
            }

            if (terrainSettings.GetAction(TerrainSettings.Action.RandomizeLight))
            {
                RandomizeLights();
                SetLightMode(-1);
            }

            if (terrainSettings.GetAction(TerrainSettings.Action.RandomizeFill))
            {
                RandomizeFill();
                SetFillMode(-1);
            }
        }