コード例 #1
0
        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);
        }