public void BlendTPatterns()
        {
            if (Scene.current == null)
            {
                new Scene();
            }

            Scene.current.Clear();

            //RadialGradientPattern radialPattern = new RadialGradientPattern();

            StripePattern s1 = new StripePattern(new SolidColorPattern(Color.white), new SolidColorPattern(Color.green));
            StripePattern s2 = new StripePattern(new SolidColorPattern(Color.white), new SolidColorPattern(Color.green));

            s1.matrix = Mat4.RotateYMatrix(Constants.pi / 2);

            BlendPattern blend = new BlendPattern(s1, s2);

            Light light = new Light(new Point(-5, 5, -5), Color.white);
            Plane floor = new Plane();

            floor.material.pattern = blend;

            Plane wall = new Plane();

            wall.SetMatrix(Mat4.RotateXMatrix(Constants.pi / 2.0) *
                           Mat4.TranslateMatrix(0, 0, 4.1));
            wall.material.pattern = blend;

            Sphere sphere1 = new Sphere();

            sphere1.SetMatrix(Mat4.TranslateMatrix(0, 0.5, -3) *
                              Mat4.ScaleMatrix(0.5, 0.5, 0.5));
            sphere1.material.pattern = blend;

            Sphere sphere2 = new Sphere();

            sphere2.SetMatrix(Mat4.TranslateMatrix(2, 1.0, -1));
            sphere2.material.pattern = blend;

            Camera camera = new Camera(640, 480, Constants.pi / 3.0);

            //Need to halt execution if I end up with NaN
            camera.ViewTransform(new Point(0, 2, -10),
                                 new Point(0, 2, 4),
                                 new Vector(0, 1, 0));

            Canvas canvas = Scene.current.Render(camera);

            Save.SaveCanvas(canvas, "Chapter10_BlendPatterns");
        }
Beispiel #2
0
        public void T20_TransparencyTest()
        {
            if (Scene.current == null)
            {
                new Scene();
            }

            Scene.current.Clear();

            //RadialGradientPattern radialPattern = new RadialGradientPattern();

            StripePattern s1 = new StripePattern(new SolidColorPattern(Color.white), new SolidColorPattern(Color.green));
            StripePattern s2 = new StripePattern(new SolidColorPattern(Color.white), new SolidColorPattern(Color.green));

            s1.matrix = Mat4.RotateYMatrix(Constants.pi / 2);

            BlendPattern blend = new BlendPattern(s1, s2);

            Plane floor = new Plane();

            floor.SetMatrix(Mat4.TranslateMatrix(0, -1.2, 0));
            floor.material.pattern = blend;

            Plane wall = new Plane();

            wall.SetMatrix(Mat4.RotateXMatrix(Constants.pi / 2.0) *
                           Mat4.TranslateMatrix(0, 0, 4.1));
            wall.material.pattern = new Patterns.CheckersPattern();

            Light light = new Light(new Point(-5, 5, -5), Color.white);

            Sphere sphere1 = new Sphere();

            sphere1.material.Diffuse      = 0.0;
            sphere1.material.Shinniness   = 300;
            sphere1.material.Ambient      = 0.0;
            sphere1.material.Reflective   = 1.0;
            sphere1.material.RefracIndex  = RefractiveIndex.Vacuum;
            sphere1.material.Transparency = 1.0;
            sphere1.canCastShadows        = false;

            Camera camera = new Camera(150, 150, Constants.pi / 3.0);

            //Need to halt execution if I end up with NaN
            camera.ViewTransform(new Point(0, 0, -3),
                                 new Point(0, 0, 4),
                                 new Vector(0, 1, 0));
            Canvas canvas = Scene.current.Render(camera);

            Save.SaveCanvas(canvas, "Chapter11_SphereTest");
        }