Ejemplo n.º 1
0
        private void button_Generate_Click(object sender, EventArgs e)
        {
            terra = null;

            seed  = int.Parse(textBox_seed.Text);
            terra = new DiamondSquare(size, willWarp, seed);
            terra.Generate(detail);
            canShow = true;
        }
Ejemplo n.º 2
0
        public Form_3D(DiamondSquare map)
        {
            terra     = map;
            terWidth  = terra.Size;
            terLength = terra.Size;
            indCount  = (terWidth - 1) * (terLength - 1) * 6;
            vertCount = terWidth * terLength;
            this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            InitializeComponent();
            InitializeGraphics();

            InitializeEventHandler();
        }
Ejemplo n.º 3
0
        private void GenerateVertex()
        {
            verts = new CustomVertex.PositionColored[vertCount];
            int           k = 0;
            DiamondSquare a = terra;

            for (int z = 0; z < terWidth; z++)
            {
                for (int x = 0; x < terLength; x++)
                {
                    verts[k].Position = new Vector3(x, 60 * (float)a.GetValue(x, z), z);
                    if (50 * a.GetValue(x, z) < 0)
                    {
                        verts[k].Color = Color.Blue.ToArgb();
                    }
                    else if (50 * a.GetValue(x, z) >= 0 && 50 * a.GetValue(x, z) < 5)
                    {
                        verts[k].Color = Color.Yellow.ToArgb();
                    }
                    else if (50 * a.GetValue(x, z) >= 5 && 50 * a.GetValue(x, z) < 30)
                    {
                        verts[k].Color = Color.Green.ToArgb();
                    }
                    else if (50 * a.GetValue(x, z) >= 30 && 50 * a.GetValue(x, z) < 50)
                    {
                        verts[k].Color = Color.Gray.ToArgb();
                    }
                    else
                    {
                        verts[k].Color = Color.White.ToArgb();
                    }

                    k++;
                }
            }
        }