private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e) { pr = (Projection)comboBox1.SelectedIndex; g.Clear(Color.White); if (figure != null) { figure.show(g, pr); } }
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); }
private void createFigureFromFile(string fileText, int mode = 0) { clearScenes(); figure = new Polyhedron(fileText, mode); 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); }
private void Button3_Click(object sender, EventArgs e) { Form2 form2 = new Form2(); form2.ShowDialog(); var f = form2.f; float x0 = form2.X0; float x1 = form2.X1; float y0 = form2.Y0; float y1 = form2.Y1; int cnt_of_breaks = form2.Cnt_of_breaks; form2.Dispose(); ReverseFloatComparer fcmp = new ReverseFloatComparer(); float dx = (Math.Abs(x0) + Math.Abs(x1)) / cnt_of_breaks; float dy = (Math.Abs(y0) + Math.Abs(y1)) / cnt_of_breaks; List <Face> faces = new List <Face>(); List <Point3d> pts0 = new List <Point3d>(); List <Point3d> pts1 = new List <Point3d>(); for (float x = x0; x < x1; x += dx) { for (float y = y0; y < y1; y += dy) { float z = f(x, y); pts1.Add(new Point3d(x, y, z)); } if (pts0.Count != 0) { for (int i = 1; i < pts0.Count; ++i) { faces.Add(new Face(new List <Point3d>() { new Point3d(pts0[i - 1]), new Point3d(pts1[i - 1]), new Point3d(pts1[i]), new Point3d(pts0[i]) })); } } pts0.Clear(); pts0 = pts1; pts1 = new List <Point3d>(); } g.Clear(Color.White); figure = new Polyhedron(faces); figure.Apply(Transformation.Scale(5, 5, 5)); figure.show(g, pr, new_fig); }
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; } }
private void button1_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)numericUpDown7.Value, ky = (float)numericUpDown8.Value, kz = (float)numericUpDown9.Value; figure.scale(kx, ky, kz); figure.translate(old_x, old_y, old_z); } else { float kx = (float)numericUpDown7.Value, ky = (float)numericUpDown8.Value, kz = (float)numericUpDown9.Value; figure.scale(kx, ky, kz); } } g.Clear(Color.White); figure.show(g, projection); }