public Camera(int w, int h) { int camera_half_size = 5; small_cube.Hexahedron(camera_half_size); small_cube.Translate(view.First.X, view.First.Y, view.First.Z); set_rot_line(); Width = w; Height = h; }
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; } }
//Рисование фигуры 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 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 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(); }