//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); }
private void button7_Click(object sender, EventArgs e) { List <Point3D> points = new List <Point3D>(); var lines = textBox1.Text.Split('\n'); foreach (var p in lines) { var arr = ((string)p).Split(','); points.Add(new Point3D(float.Parse(arr[0]), float.Parse(arr[1]), float.Parse(arr[2]))); } Axis axis = 0; switch (comboBox6.SelectedItem.ToString()) { case "OX": axis = 0; break; case "OY": axis = Axis.AXIS_Y; break; case "OZ": axis = Axis.AXIS_Z; break; default: axis = 0; break; } RotationFigure rotateFigure = new RotationFigure(points, axis, (int)numericUpDown23.Value); figure = rotateFigure; g.Clear(Color.White); if (clipping == 0) { rotateFigure.Show(g, 0); } else if (clipping == Clipping.Gouraud) { show_gouraud(); } else { show_z_buff(); } }
public void Tetrahedron(Polyhedron cube = null) { if (cube == null) { cube = new Polyhedron(); cube.Hexahedron(); } Polygon f0 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[0].Points[0]), new Point3D(cube.Polygons[1].Points[1]), new Point3D(cube.Polygons[1].Points[3]) } ); Polygon f1 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[1].Points[3]), new Point3D(cube.Polygons[1].Points[1]), new Point3D(cube.Polygons[0].Points[2]) } ); Polygon f2 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[0].Points[2]), new Point3D(cube.Polygons[1].Points[1]), new Point3D(cube.Polygons[0].Points[0]) } ); Polygon f3 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[0].Points[2]), new Point3D(cube.Polygons[0].Points[0]), new Point3D(cube.Polygons[1].Points[3]) } ); Polygons = new List <Polygon> { f0, f1, f2, f3 }; UpdateCenter(); }
//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; } }
public void make_tetrahedron(Polyhedron cube = null) { if (cube == null) { cube = new Polyhedron(); cube.make_hexahedron(); } Polygon f0 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[0].Points[0]), new Point3d(cube.Faces[1].Points[1]), new Point3d(cube.Faces[1].Points[3]) } ); Polygon f1 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[1].Points[3]), new Point3d(cube.Faces[1].Points[1]), new Point3d(cube.Faces[0].Points[2]) } ); Polygon f2 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[0].Points[2]), new Point3d(cube.Faces[1].Points[1]), new Point3d(cube.Faces[0].Points[0]) } ); Polygon f3 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[0].Points[2]), new Point3d(cube.Faces[0].Points[0]), new Point3d(cube.Faces[1].Points[3]) } ); Faces = new List <Polygon> { f0, f1, f2, f3 }; find_center(); }
//Рисование фигуры 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; } }
//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; } }
public void Dodecahedron() { Polygons = new List <Polygon>(); Polyhedron ik = new Polyhedron(); ik.Icosahedron(); List <Point3D> pts = new List <Point3D>(); foreach (Polygon f in ik.Polygons) { pts.Add(f.Center); } Polygons.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]) })); Polygons.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) { Polygons.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]) })); } Polygons.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]) })); Polygons.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]) })); Polygons.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]) })); Polygons.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]) })); Polygons.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]) })); UpdateCenter(); }
public void Octahedron(Polyhedron cube = null) { if (cube == null) { cube = new Polyhedron(); cube.Hexahedron(); } Polygon f0 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[2].Center), new Point3D(cube.Polygons[1].Center), new Point3D(cube.Polygons[4].Center) } ); Polygon f1 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[2].Center), new Point3D(cube.Polygons[1].Center), new Point3D(cube.Polygons[5].Center) } ); Polygon f2 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[2].Center), new Point3D(cube.Polygons[5].Center), new Point3D(cube.Polygons[0].Center) } ); Polygon f3 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[2].Center), new Point3D(cube.Polygons[0].Center), new Point3D(cube.Polygons[4].Center) } ); Polygon f4 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[3].Center), new Point3D(cube.Polygons[1].Center), new Point3D(cube.Polygons[4].Center) } ); Polygon f5 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[3].Center), new Point3D(cube.Polygons[1].Center), new Point3D(cube.Polygons[5].Center) } ); Polygon f6 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[3].Center), new Point3D(cube.Polygons[5].Center), new Point3D(cube.Polygons[0].Center) } ); Polygon f7 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[3].Center), new Point3D(cube.Polygons[0].Center), new Point3D(cube.Polygons[4].Center) } ); Polygons = new List <Polygon> { f0, f1, f2, f3, f4, f5, f6, f7 }; UpdateCenter(); }
public Polyhedron(Polyhedron polyhedron) { Polygons = polyhedron.Polygons.Select(face => new Polygon(face)).ToList(); Center = new Point3D(polyhedron.Center); }
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(); }
public void make_octahedron(Polyhedron cube = null) { if (cube == null) { cube = new Polyhedron(); cube.make_hexahedron(); } Polygon f0 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[2].Center), new Point3d(cube.Faces[1].Center), new Point3d(cube.Faces[4].Center) } ); Polygon f1 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[2].Center), new Point3d(cube.Faces[1].Center), new Point3d(cube.Faces[5].Center) } ); Polygon f2 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[2].Center), new Point3d(cube.Faces[5].Center), new Point3d(cube.Faces[0].Center) } ); Polygon f3 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[2].Center), new Point3d(cube.Faces[0].Center), new Point3d(cube.Faces[4].Center) } ); Polygon f4 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[3].Center), new Point3d(cube.Faces[1].Center), new Point3d(cube.Faces[4].Center) } ); Polygon f5 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[3].Center), new Point3d(cube.Faces[1].Center), new Point3d(cube.Faces[5].Center) } ); Polygon f6 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[3].Center), new Point3d(cube.Faces[5].Center), new Point3d(cube.Faces[0].Center) } ); Polygon f7 = new Polygon( new List <Point3d> { new Point3d(cube.Faces[3].Center), new Point3d(cube.Faces[0].Center), new Point3d(cube.Faces[4].Center) } ); Faces = new List <Polygon> { f0, f1, f2, f3, f4, f5, f6, f7 }; find_center(); }
public Polyhedron(Polyhedron polyhedron) { Faces = polyhedron.Faces.Select(face => new Polygon(face)).ToList(); Center = new Point3d(polyhedron.Center); }
public void Octahedron(Polyhedron cube = null) { if (cube == null) { cube = new Polyhedron(); cube.Hexahedron(); } Polygon f0 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[2].Center), new Point3D(cube.Polygons[1].Center), new Point3D(cube.Polygons[4].Center) } ); f0.Points[0].TextureCoordinates = new PointF(0, 0); f0.Points[1].TextureCoordinates = new PointF(0, 1); f0.Points[2].TextureCoordinates = new PointF(.5f, .5f); Polygon f1 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[2].Center), new Point3D(cube.Polygons[1].Center), new Point3D(cube.Polygons[5].Center) } ); f1.Points[0].TextureCoordinates = new PointF(0, 0); f1.Points[1].TextureCoordinates = new PointF(0, 1); f1.Points[2].TextureCoordinates = new PointF(.5f, .5f); Polygon f2 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[2].Center), new Point3D(cube.Polygons[5].Center), new Point3D(cube.Polygons[0].Center) } ); f2.Points[0].TextureCoordinates = new PointF(0, 0); f2.Points[1].TextureCoordinates = new PointF(0, 1); f2.Points[2].TextureCoordinates = new PointF(.5f, .5f); Polygon f3 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[2].Center), new Point3D(cube.Polygons[0].Center), new Point3D(cube.Polygons[4].Center) } ); f3.Points[0].TextureCoordinates = new PointF(0, 0); f3.Points[1].TextureCoordinates = new PointF(0, 1); f3.Points[2].TextureCoordinates = new PointF(.5f, .5f); Polygon f4 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[3].Center), new Point3D(cube.Polygons[1].Center), new Point3D(cube.Polygons[4].Center) } ); f4.Points[0].TextureCoordinates = new PointF(0, 0); f4.Points[1].TextureCoordinates = new PointF(0, 1); f4.Points[2].TextureCoordinates = new PointF(.5f, .5f); Polygon f5 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[3].Center), new Point3D(cube.Polygons[1].Center), new Point3D(cube.Polygons[5].Center) } ); f5.Points[0].TextureCoordinates = new PointF(0, 0); f5.Points[1].TextureCoordinates = new PointF(0, 1); f5.Points[2].TextureCoordinates = new PointF(.5f, .5f); Polygon f6 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[3].Center), new Point3D(cube.Polygons[5].Center), new Point3D(cube.Polygons[0].Center) } ); f6.Points[0].TextureCoordinates = new PointF(0, 0); f6.Points[1].TextureCoordinates = new PointF(0, 1); f6.Points[2].TextureCoordinates = new PointF(.5f, .5f); Polygon f7 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[3].Center), new Point3D(cube.Polygons[0].Center), new Point3D(cube.Polygons[4].Center) } ); f7.Points[0].TextureCoordinates = new PointF(0, 0); f7.Points[1].TextureCoordinates = new PointF(0, 1); f7.Points[2].TextureCoordinates = new PointF(.5f, .5f); Polygons = new List <Polygon> { f0, f1, f2, f3, f4, f5, f6, f7 }; UpdateCenter(); }
public void Tetrahedron(Polyhedron cube = null) { if (cube == null) { cube = new Polyhedron(); cube.Hexahedron(); } Polygon f0 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[0].Points[0]), new Point3D(cube.Polygons[1].Points[1]), new Point3D(cube.Polygons[1].Points[3]) } ); f0.Points[0].TextureCoordinates = new PointF(0.5f, 0); f0.Points[1].TextureCoordinates = new PointF(0, 1); f0.Points[2].TextureCoordinates = new PointF(1, 1); Polygon f1 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[1].Points[3]), new Point3D(cube.Polygons[1].Points[1]), new Point3D(cube.Polygons[0].Points[2]) } ); f1.Points[0].TextureCoordinates = new PointF(0.5f, 0); f1.Points[1].TextureCoordinates = new PointF(0, 1); f1.Points[2].TextureCoordinates = new PointF(1, 1); Polygon f2 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[0].Points[2]), new Point3D(cube.Polygons[1].Points[1]), new Point3D(cube.Polygons[0].Points[0]) } ); f2.Points[0].TextureCoordinates = new PointF(0.5f, 0); f2.Points[1].TextureCoordinates = new PointF(0, 1); f2.Points[2].TextureCoordinates = new PointF(1, 1); Polygon f3 = new Polygon( new List <Point3D> { new Point3D(cube.Polygons[0].Points[2]), new Point3D(cube.Polygons[0].Points[0]), new Point3D(cube.Polygons[1].Points[3]) } ); f3.Points[0].TextureCoordinates = new PointF(0.5f, 0); f3.Points[1].TextureCoordinates = new PointF(0, 1); f3.Points[2].TextureCoordinates = new PointF(1, 1); Polygons = new List <Polygon> { f0, f1, f2, f3 }; UpdateCenter(); }