Example #1
0
        private void createFigure(int figureType)
        {
            clearScenes();
            figure = new Polyhedron();
            switch (figureType)
            {
            case 0:
                figure.make_hexahedron();
                break;

            case 1:
                figure.make_tetrahedron();
                break;

            case 2:
                figure.make_octahedron();
                break;

            case 3:
                figure.make_dodecahedron();
                break;

            case 4:
                figure.make_icosahedron();
                break;
            }
            CameraMode oldMode = camera == null ? CameraMode.Simple : camera.mode;

            camera = new Camera(new Polyhedron(figure), pictureBox3, fill_color, light_x, light_y, light_z);
            camera.setMode(oldMode);
            camera.Apply(Transformation.Identity());
            figure.show(g, pr);
            camera.show(camera_g, old_fig);
        }
Example #2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
            case 0:
                //Tetrahedron
                g.Clear(Color.White);
                figure = new Polyhedron();
                figure.make_tetrahedron();
                figure.show(g, projection);
                break;

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

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

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

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

            default:
                break;
            }
        }
Example #3
0
        public void make_dodecahedron()
        {
            Faces = new List <Polygon>();
            Polyhedron ik = new Polyhedron();

            ik.make_icosahedron();

            List <Point3D> pts = new List <Point3D>();

            foreach (Polygon f in ik.Faces)
            {
                pts.Add(f.Center);
            }

            Faces.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[0]),
                new Point3D(pts[1]),
                new Point3D(pts[2]),
                new Point3D(pts[3]),
                new Point3D(pts[4])
            }));

            Faces.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[5]),
                new Point3D(pts[6]),
                new Point3D(pts[7]),
                new Point3D(pts[8]),
                new Point3D(pts[9])
            }));

            for (int i = 0; i < 5; ++i)
            {
                Faces.Add(new Polygon(new List <Point3D>
                {
                    new Point3D(pts[i]),
                    new Point3D(pts[(i + 1) % 5]),
                    new Point3D(pts[(i == 4) ? 10 : 2 * i + 12]),
                    new Point3D(pts[(i == 4) ? 11 : 2 * i + 13]),
                    new Point3D(pts[2 * i + 10])
                }));
            }

            Faces.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[5]),
                new Point3D(pts[6]),
                new Point3D(pts[13]),
                new Point3D(pts[10]),
                new Point3D(pts[11])
            }));
            Faces.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[6]),
                new Point3D(pts[7]),
                new Point3D(pts[15]),
                new Point3D(pts[12]),
                new Point3D(pts[13])
            }));
            Faces.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[7]),
                new Point3D(pts[8]),
                new Point3D(pts[17]),
                new Point3D(pts[14]),
                new Point3D(pts[15])
            }));
            Faces.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[8]),
                new Point3D(pts[9]),
                new Point3D(pts[19]),
                new Point3D(pts[16]),
                new Point3D(pts[17])
            }));
            Faces.Add(new Polygon(new List <Point3D>
            {
                new Point3D(pts[9]),
                new Point3D(pts[5]),
                new Point3D(pts[11]),
                new Point3D(pts[18]),
                new Point3D(pts[19])
            }));

            find_center();
        }