Пример #1
0
        private static void TestCase03()
        {
            // The reflected color for a nonreflective material
            World w     = new DefaultWorld();
            Ray   r     = new Ray(Tuple.Point(0, 0, 0), Tuple.Vector(0, 0, 1));
            Shape shape = w.Shapes[1];

            shape.Material.Ambient = 1;
            Intersection  i     = new Intersection(1, shape);
            Computation   comps = new Computation(i, r);
            LightingModel l     = new PhongReflection();
            Tuple         color = l.ReflectedColor(w, comps);

            Assert.Equal(Tuple.Color(0, 0, 0), color);
        }
Пример #2
0
        private static void TestCase07()
        {
            // The reflected color at the maximum recursive depth
            World w     = new DefaultWorld();
            Shape shape = new Plane();

            shape.Material.Reflective = 0.5f;
            shape.Transform           = Transformation.Translation(0, -1, 0);
            w.Shapes.Add(shape);
            Ray           r     = new Ray(Tuple.Point(0, 0, -3), Tuple.Vector(0, -Sqrt(2) / 2, Sqrt(2) / 2));
            Intersection  i     = new Intersection(Sqrt(2), shape);
            Computation   comps = new Computation(i, r);
            LightingModel l     = new PhongReflection();
            Tuple         color = l.ReflectedColor(w, comps, 0);

            Assert.Equal(Tuple.Color(0, 0, 0), color);
        }
Пример #3
0
        private static void TestCase04()
        {
            // The reflected color for a reflective material
            World w     = new DefaultWorld();
            Shape shape = new Plane();

            shape.Material.Reflective = 0.5f;
            shape.Transform           = Transformation.Translation(0, -1, 0);
            w.Shapes.Add(shape);
            Ray           r     = new Ray(Tuple.Point(0, 0, -3), Tuple.Vector(0, -Sqrt(2) / 2, Sqrt(2) / 2));
            Intersection  i     = new Intersection(Sqrt(2), shape);
            Computation   comps = new Computation(i, r);
            LightingModel l     = new PhongReflection();
            Tuple         color = l.ReflectedColor(w, comps);

            Assert.Equal(0.19032f, color.X, 3);
            Assert.Equal(0.2379f, color.Y, 3);
            Assert.Equal(0.14274f, color.Z, 3);
        }