public void build_scene() { Figure room = Figure.get_Hexahedron(10); up_left = room.sides[0].get_point(0); up_right = room.sides[0].get_point(1); down_right = room.sides[0].get_point(2); down_left = room.sides[0].get_point(3); Point3D normal = Side.norm(room.sides[0]); // нормаль стороны комнаты Point3D center = (up_left + up_right + down_left + down_right) / 4; // центр стороны комнаты focus = center + normal * 10; room.set_pen(new Pen(Color.Gray)); room.isRoom = true; float refl, refr, amb, dif, env; room.sides[0].drawing_pen = new Pen(Color.Green); if (backWallSpecularCB.Checked) { refl = 0.8f; refr = 0f; amb = 0.0f; dif = 0.0f; env = 1f; } else { refl = 0.0f; refr = 0f; amb = 0.1f; dif = 0.8f; env = 1f; } room.back_wall_material = new Material(refl, refr, amb, dif, env); room.sides[1].drawing_pen = new Pen(Color.Gold); if (frontWallSpecularCB.Checked) { refl = 0.8f; refr = 0f; amb = 0.0f; dif = 0.0f; env = 1f; } else { refl = 0.0f; refr = 0f; amb = 0.1f; dif = 0.8f; env = 1f; } room.front_wall_material = new Material(refl, refr, amb, dif, env); room.sides[2].drawing_pen = new Pen(Color.DeepPink); if (rightWallSpecularCB.Checked) { refl = 0.8f; refr = 0f; amb = 0.0f; dif = 0.0f; env = 1f; } else { refl = 0.0f; refr = 0f; amb = 0.1f; dif = 0.8f; env = 1f; } room.right_wall_material = new Material(refl, refr, amb, dif, env); room.sides[3].drawing_pen = new Pen(Color.BlueViolet); if (leftWallSpecularCB.Checked) { refl = 0.8f; refr = 0f; amb = 0.0f; dif = 0.0f; env = 1f; } else { refl = 0.0f; refr = 0f; amb = 0.1f; dif = 0.8f; env = 1f; } room.left_wall_material = new Material(refl, refr, amb, dif, env); if (upWallSpecularCB.Checked) { refl = 0.8f; refr = 0f; amb = 0.0f; dif = 0.0f; env = 1f; } else { refl = 0.0f; refr = 0f; amb = 0.1f; dif = 0.8f; env = 1f; } room.up_wall_material = new Material(refl, refr, amb, dif, env); if (downWallSpecularCB.Checked) { refl = 0.8f; refr = 0f; amb = 0.0f; dif = 0.0f; env = 1f; } else { refl = 0.0f; refr = 0f; amb = 0.1f; dif = 0.8f; env = 1f; } room.down_wall_material = new Material(refl, refr, amb, dif, env); Light l1 = new Light(new Point3D(0f, 1f, 4.9f), new Point3D(1f, 1f, 1f)); lights.Add(l1); if (twoLightsCB.Checked) { Light l2 = new Light(new Point3D(0f, 4f, -4.9f), new Point3D(1f, 1f, 1f)); lights.Add(l2); } Sphere s1 = new Sphere(new Point3D(2.8f, -2.5f, 2.5f), 2f); s1.set_pen(new Pen(Color.White)); if (sphereSpecularCB.Checked) { refl = 0.9f; refr = 0f; amb = 0f; dif = 0.1f; env = 1f; } else { refl = 0.0f; refr = 0f; amb = 0.1f; dif = 0.8f; env = 1f; } s1.figure_material = new Material(refl, refr, amb, dif, env); Figure cube1 = Figure.get_Hexahedron(3.2f); cube1.offset(-0.5f, -1, -3.5f); cube1.rotate_around(55, "CZ"); cube1.set_pen(new Pen(Color.Aqua)); if (refractCubeCB.Checked) { refl = 0.0f; refr = 0.8f; amb = 0f; dif = 0.0f; env = 1.03f; } else { refl = 0f; refr = 0f; amb = 0.1f; dif = 0.7f; env = 1f; } cube1.figure_material = new Material(refl, refr, amb, dif, env); Figure cube2 = Figure.get_Hexahedron(2.6f); cube2.offset(-2.4f, 2, -3.8f); cube2.rotate_around(30, "CZ"); cube2.set_pen(new Pen(Color.Blue)); if (cubeSpecularCB.Checked) { refl = 0.8f; refr = 0f; amb = 0.05f; dif = 0.0f; env = 1f; } else { refl = 0.0f; refr = 0f; amb = 0.1f; dif = 0.8f; env = 1f; } cube2.figure_material = new Material(refl, refr, amb, dif, env); Sphere s2 = new Sphere(new Point3D(-2.2f, 1.6f, -1.4f), 1.2f); s2.set_pen(new Pen(Color.DarkOrange)); s2.figure_material = new Material(0.0f, 0.0f, 0.1f, 0.7f, 1.0f); Sphere s3 = new Sphere(new Point3D(2.5f, 2f, -3.4f), 1.7f); s3.set_pen(new Pen(Color.LimeGreen)); if (refractSphereCB.Checked) { refl = 0.0f; refr = 0.9f; amb = 0f; dif = 0.0f; env = 1.03f; } else { refl = 0.0f; refr = 0f; amb = 0.1f; dif = 0.9f; env = 1f; } s3.figure_material = new Material(refl, refr, amb, dif, env); Sphere s4 = new Sphere(new Point3D(2.7f, -2.5f, 3.95f), 1.3f); s4.set_pen(new Pen(Color.Red)); s4.figure_material = new Material(0.7f, 0f, 0.0f, 0.0f, 1f); scene.Add(room); scene.Add(cube1); scene.Add(cube2); scene.Add(s1); scene.Add(s2); scene.Add(s3); }
public void build_scene() { Figure room = Figure.get_Hexahedron(10); up_left = room.sides[0].get_point(0); up_right = room.sides[0].get_point(1); down_right = room.sides[0].get_point(2); down_left = room.sides[0].get_point(3); Point3D normal = Side.norm(room.sides[0]); // нормаль стороны комнаты Point3D center = (up_left + up_right + down_left + down_right) / 4; // центр стороны комнаты focus = center + normal * 10; room.set_pen(new Pen(Color.Gray)); room.sides[0].drawing_pen = new Pen(Color.Green); room.sides[1].drawing_pen = new Pen(Color.Gold); room.sides[2].drawing_pen = new Pen(Color.DeepPink); room.sides[3].drawing_pen = new Pen(Color.BlueViolet); room.figure_material = new Material(0f, 0, 0.05f, 0.7f); Light l1 = new Light(new Point3D(0f, 2f, 4.9f), new Point3D(1f, 1f, 1f)); Light l2 = new Light(new Point3D(-4.9f, -4.9f, 4.9f), new Point3D(1f, 1f, 1f)); lights.Add(l1); lights.Add(l2); Sphere s1 = new Sphere(new Point3D(-2.5f, 1.7f, -3.7f), 1.4f); s1.set_pen(new Pen(Color.White)); s1.figure_material = new Material(0.05f, 0.9f, 0f, 0f, 1.05f); Sphere s2 = new Sphere(new Point3D(-2.5f, -2, 2.5f), 2f); s2.set_pen(new Pen(Color.White)); s2.figure_material = new Material(0.9f, 0f, 0f, 0.1f, 1f); Figure cube1 = Figure.get_Hexahedron(2.8f); cube1.offset(-0.5f, -1, -3.9f); cube1.rotate_around(55, "CZ"); cube1.set_pen(new Pen(Color.Aqua)); cube1.figure_material = new Material(0f, 0f, 0.1f, 0.7f, 1.5f); Figure cube2 = Figure.get_Hexahedron(1.5f); cube2.offset(-0.5f, -0.9f, -1.7f); cube2.rotate_around(120, "CZ"); cube2.set_pen(new Pen(Color.White)); cube2.figure_material = new Material(0.9f, 0f, 0f, 0.1f, 1.2f); Figure cube3 = Figure.get_Hexahedron(2f); cube3.offset(2.7f, 2.5f, -3.95f); cube3.rotate_around(-10, "CZ"); cube3.set_pen(new Pen(Color.Red)); cube3.figure_material = new Material(0, 0.7f, 0.1f, 0.5f, 1f); scene.Add(room); scene.Add(cube1); scene.Add(cube2); scene.Add(cube3); scene.Add(s1); scene.Add(s2); }