Exemplo n.º 1
0
        // constructor
        public TerrainForm()
        {
            this.components = new System.ComponentModel.Container();
            this.Size = new System.Drawing.Size(SCREEN_SIZE, SCREEN_SIZE);
            this.Text = "Terrain Viewer";
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
            this.Icon = TerrainGenerator.Properties.Resources.Ico;
            this.CenterToScreen();

            terrainSettings = new TerrainSettings();
            heightMap = new HeightMap();
        }
Exemplo n.º 2
0
        // constructor
        public TerrainForm()
        {
            this.components = new System.ComponentModel.Container();
            this.Size       = new System.Drawing.Size(SCREEN_SIZE, SCREEN_SIZE);
            this.Text       = "Terrain Viewer";
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);
            this.Icon = TerrainGenerator.Properties.Resources.Ico;
            this.CenterToScreen();

            terrainSettings = new TerrainSettings();
            heightMap       = new HeightMap();
        }
 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);
 }
Exemplo n.º 4
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 void CopyFrom(TerrainSettings setting)
        {
            for (int i = 0; i < actions.Length; i++)
            {
                actions[i]         = setting.actions[i];
                setting.actions[i] = false;
            }

            for (int i = 0; i < bools.Length; i++)
            {
                bools[i] = setting.bools[i];
            }

            for (int i = 0; i < ints.Length; i++)
            {
                ints[i] = setting.ints[i];
            }

            for (int i = 0; i < floats.Length; i++)
            {
                floats[i] = setting.floats[i];
            }
        }
        public void CopyFrom(TerrainSettings setting)
        {
            for (int i = 0; i < actions.Length; i++)
            {
                actions[i] = setting.actions[i];
                setting.actions[i] = false;
            }

            for (int i = 0; i < bools.Length; i++)
                bools[i] = setting.bools[i];

            for (int i = 0; i < ints.Length; i++)
                ints[i] = setting.ints[i];

            for (int i = 0; i < floats.Length; i++)
                floats[i] = setting.floats[i];
        }
Exemplo n.º 7
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);
            }
        }
Exemplo n.º 8
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);
            }
        }