Esempio n. 1
0
        //TRANSLATION ROTATION SCALE
        private void button2_Click(object sender, EventArgs e)
        {
            if (figure == null)
            {
                MessageBox.Show("Неодбходимо выбрать фигуру!", "Ошибка!", MessageBoxButtons.OK);
            }
            else
            {
                //TRANSLATE
                int offsetX = (int)numericUpDown1.Value, offsetY = (int)numericUpDown2.Value, offsetZ = (int)numericUpDown3.Value;
                figure.Translate(offsetX, offsetY, offsetZ);

                //ROTATE
                int rotateAngleX = (int)numericUpDown4.Value;
                figure.Rotate(rotateAngleX, 0);

                int rotateAngleY = (int)numericUpDown5.Value;
                figure.Rotate(rotateAngleY, Axis.AXIS_Y);

                int rotateAngleZ = (int)numericUpDown6.Value;
                figure.Rotate(rotateAngleZ, Axis.AXIS_Z);

                //SCALE
                if (checkBox1.Checked)
                {
                    float old_x = figure.Center.X, old_y = figure.Center.Y, old_z = figure.Center.Z;
                    figure.Translate(-old_x, -old_y, -old_z);

                    float kx = (float)numericUpDown9.Value, ky = (float)numericUpDown8.Value, kz = (float)numericUpDown7.Value;
                    figure.Scale(kx, ky, kz);

                    figure.Translate(old_x, old_y, old_z);
                }
                else
                {
                    float kx = (float)numericUpDown9.Value, ky = (float)numericUpDown8.Value, kz = (float)numericUpDown7.Value;
                    figure.Scale(kx, ky, kz);
                }
            }

            g.Clear(Color.White);
            if (clipping == 0)
            {
                figure.Show(g, projection);
            }
            else if (clipping == Clipping.Gouraud)
            {
                show_gouraud();
            }
            else if (clipping == Clipping.ZBuffer)
            {
                show_z_buff();
            }
            else if (clipping == Clipping.Texture)
            {
                show_texture();
            }

            camera.show(g, projection);
        }
Esempio n. 2
0
        //LOAD
        private void button5_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            string filename = openFileDialog1.FileName;
            string fileText = System.IO.File.ReadAllText(filename);

            figure = new Polyhedron(fileText);
            g.Clear(Color.White);
            figure.Show(g, 0);
        }
Esempio n. 3
0
        //DRAW FIGURE
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
            case 0:
                //Tetrahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Tetrahedron();
                figure.Show(g, projection);
                break;

            case 1:
                //Hexahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Hexahedron();
                figure.Show(g, projection);
                break;

            case 2:
                //Oktahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Octahedron();
                figure.Show(g, projection);
                break;

            case 3:
                //Icosahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Icosahedron();
                figure.Show(g, projection);
                break;

            case 4:
                //Dodecahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Dodecahedron();
                figure.Show(g, projection);
                break;

            default:
                break;
            }
        }
Esempio n. 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (figure == null)
            {
                MessageBox.Show("Неодбходимо выбрать фигуру!", "Ошибка!", MessageBoxButtons.OK);
            }
            else
            {
                //перемещение
                int offsetX = (int)numericUpDown1.Value, offsetY = (int)numericUpDown2.Value, offsetZ = (int)numericUpDown3.Value;
                figure.Translate(offsetX, offsetY, offsetZ);

                //поворот
                int rotateAngleX = (int)numericUpDown4.Value;
                figure.Rotate(rotateAngleX, 0);

                int rotateAngleY = (int)numericUpDown5.Value;
                figure.Rotate(rotateAngleY, Axis.AXIS_Y);

                int rotateAngleZ = (int)numericUpDown6.Value;
                figure.Rotate(rotateAngleZ, Axis.AXIS_Z);
            }

            g.Clear(Color.White);
            if (clipping == 0)
            {
                figure.Show(g, projection);
            }
            else if (clipping == Clipping.Gouraud)
            {
                show_gouraud();
            }
            else if (clipping == Clipping.ZBuffer)
            {
                show_z_buff();
            }
            else if (clipping == Clipping.Texture)
            {
                show_texture();
            }

            camera.show(g, projection);
        }
Esempio n. 5
0
        //Рисование фигуры
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
            case 0:
                //Татраэдр
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Tetrahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                break;

            case 1:
                //Гексаэдр
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Hexahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                break;

            case 2:
                //Октаэдр
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Octahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                break;

            case 3:
                //Икосаэдр
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Icosahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                break;

            case 4:
                //Додекаэдр
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Dodecahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                break;

            default:
                break;
            }
        }
Esempio n. 6
0
        //DRAW FIGURE
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
            case 0:
                //Tetrahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Tetrahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.Gouraud)
                {
                    show_gouraud();
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                else if (clipping == Clipping.Texture)
                {
                    show_texture();
                }
                break;

            case 1:
                //Hexahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Hexahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.Gouraud)
                {
                    show_gouraud();
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                else if (clipping == Clipping.Texture)
                {
                    show_texture();
                }
                break;

            case 2:
                //Oktahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Octahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.Gouraud)
                {
                    show_gouraud();
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                else if (clipping == Clipping.Texture)
                {
                    show_texture();
                }
                break;

            case 3:
                //Icosahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Icosahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.Gouraud)
                {
                    show_gouraud();
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                else if (clipping == Clipping.Texture)
                {
                    show_texture();
                }
                break;

            case 4:
                //Dodecahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.Dodecahedron();
                if (clipping == 0)
                {
                    figure.Show(g, projection);
                }
                else if (clipping == Clipping.Gouraud)
                {
                    show_gouraud();
                }
                else if (clipping == Clipping.ZBuffer)
                {
                    show_z_buff();
                }
                else if (clipping == Clipping.Texture)
                {
                    show_texture();
                }
                break;

            default:
                break;
            }
        }