예제 #1
0
        public void Scene7()
        {
            var camera = new Camera(new Point3(4.0, 12.0, -15.0), // Location
                                    new Point3(0.0, 0.0, 0.0),    // Look at
                                    new Vector3(0.0, 1.0, 0.0),   // Sky Vector
                                    4.0);                         // Focal length

            scene.Camera = camera;

            var l = new Light(new Point3(-1.0, 5.0, -10.0), // Position
                              new Colour(1.0),              // Colour
                              1.0);                         // Intensity

            scene.Add(l);
            scene.Antialias = true;
            scene.Gamma     = 0.8;

            var   matt          = new Finish(1.0, 0.0, 0.0, 0.0);
            var   boardmaterial = new Material(new Colour(0.204, 0.467, 0.620), matt);
            Solid c             = new Cuboid(new Point3(0.0, 0.5, 0.0), 4.0, 1.0, 4.0, boardmaterial);

            var metal  = new Finish(0.3, 0.4, 50.0, 0.5);
            var gold   = new Material(new Colour(0.851, 0.812, 0.067), metal);
            var silver = new Material(new Colour(0.820, 0.969, 0.988), metal);

            // Form board and pieces using CSG
            Solid s = new Sphere(new Point3(-1.4, 1.1, 1.4), 0.45, gold);

            c = c | s;
            s = new Sphere(new Point3(0.0, 1.1, 1.4), 0.45, boardmaterial);
            c = c - s;
            s = new Sphere(new Point3(1.4, 1.1, 1.4), 0.45, gold);
            c = c | s;

            s = new Sphere(new Point3(-1.4, 1.1, 0.0), 0.45, silver);
            c = c | s;
            s = new Sphere(new Point3(0.0, 1.1, 0.0), 0.45, gold);
            c = c | s;
            s = new Sphere(new Point3(1.4, 1.1, 0.0), 0.45, silver);
            c = c | s;

            s = new Sphere(new Point3(-1.4, 1.1, -1.4), 0.45, gold);
            c = c | s;
            s = new Sphere(new Point3(0.0, 1.1, -1.4), 0.45, boardmaterial);
            c = c - s;
            s = new Sphere(new Point3(1.4, 1.1, -1.4), 0.45, silver);
            c = c | s;

            scene.Add(c);

            // Unplayed pieces
            s = new Sphere(new Point3(-3.1, 0.45, -1.0), 0.45, gold);
            scene.Add(s);
            s = new Sphere(new Point3(3.0, 0.45, 1.4), 0.45, silver);
            scene.Add(s);
            s = new Sphere(new Point3(3.3, 0.45, -1.2), 0.45, silver);
            scene.Add(s);

            // The floor
            var floormaterial = new Material(new Colour(0.2, 1.0, 0.4), matt);

            scene.Add(new Plane(new Point3(0.0, 0.0, 0.0),  // Point in plane
                                new Vector3(0.0, 1.0, 0.0), // Normal
                                floormaterial));            // Material
        }
예제 #2
0
        public void Scene3()
        {
            var camera = new Camera(new Point3(8.0, 8.0, -8.0),     // Position
                                    new Point3(0.0, 0.0, 0.0),      // Look at
                                    Vector3.UnitY,                  // Up
                                    4.0,                            // Focal length
                                    picture.Width, picture.Height); // Aspect

            scene.Camera = camera;

            var l = new Light(new Point3(-1.0, 3.0, -10.0), // Position
                              new Colour(1.0),              // Colour
                              0.5);                         // Intensity

            scene.Add(l);

            scene.Ambient    = new Colour(0.4);
            scene.Antialias  = true;
            scene.Background = Colour.DeepSkyBlue;

            Material  mat;
            Finish    fin;
            Pigment   pig;
            Solid     s;
            Transform t;

            /////////////////////////////////////////////////////
            fin       = new Finish(0.7, 0.3, 1.0, 0.0);
            pig       = new Pigment(Colour.Blue, Colour.Red, RealFunctions.Onion);
            pig.Scale = 0.1;
            mat       = new Material(pig, fin);

            // A rotation about Z
            t = new Transform(Axis.Z, 45.0);

            s = new Cube(new Point3(0.0, 0.0, 2.0), 2.0, mat);
            s.Apply(t);
            scene.Add(s);

            s = new Cube(new Point3(0.0, 0.0, -2.0), 2.0, mat);
            s.Apply(t);
            scene.Add(s);

            /////////////////////////////////////////////////////
            pig       = new Pigment(Colour.Orange, Colour.Lime, RealFunctions.Perlin);
            pig.Scale = 0.1;
            mat       = new Material(pig, fin);

            // A rotation about X
            t = new Transform(Axis.X, 45.0);

            s = new Cube(new Point3(2.0, 0.0, 0.0), 2.0, mat);
            s.Apply(t);
            scene.Add(s);

            s = new Cube(new Point3(-2.0, 0.0, 0.0), 2.0, mat);
            s.Apply(t);
            scene.Add(s);

            /////////////////////////////////////////////////////
            pig = new Pigment(Colour.Green);
            mat = new Material(pig, fin);
            mat.PerturbNormal(0.1, 0.3, VectorFunctions.Perlin);

            // A rotation about Y
            t = new Transform(Axis.Y, 45.0);

            s = new Cube(new Point3(0.0, 2.0, 0.0), 2.0, mat);
            s.Apply(t);
            scene.Add(s);

            s = new Cube(new Point3(0.0, -2.0, 0.0), 2.0, mat);
            s.Apply(t);
            scene.Add(s);
        }
예제 #3
0
        public void Scene4()
        {
            var camera = new Camera(new Point3(-14.0, 0.0, -5.0),   // Position
                                    new Point3(0.0, 1.0, 0.0),      // Look at
                                    Vector3.UnitY,                  // Up
                                    4.0,                            // Focal length
                                    picture.Width, picture.Height); // Aspect

            scene.Camera = camera;
            //scene.Antialias = true;
            scene.Ambient    = new Colour(0.5);
            scene.Background = Colour.SkyBlue;

            var l = new Light(new Point3(-10.0, 2.0, -5.0), // Position
                              new Colour(1.0),              // Colour
                              0.6);                         // Intensity

            scene.Add(l);

            Finish    fin;
            Pigment   pig;
            Material  mat;
            Solid     so, si;
            Transform t;
            Point3    centre;
            Solid     outer;
            Solid     inner;

            /////////////////////////////////////////////////////
            fin       = new Finish(0.5, 0.5, 0.5, 0.0);
            pig       = new Pigment(Colour.Beige, Colour.RosyBrown, RealFunctions.Perlin);
            pig.Scale = 0.1;

            mat = new Material(pig, fin);

            t      = new Transform();
            centre = new Point3(0.4, 0.0, 0.0);

            outer = new Sphere(centre, 0.200);
            inner = new Sphere(centre, 0.195);
            so    = outer; // Compiler can't see init of so

            for (var k = 1; k < 100; k++)
            {
                so = new Sphere(centre, 0.200 + k / 80.0);

                t.Rotate(Axis.Z, -5.0);
                t.Scale(1.02);
                so.Apply(t);

                outer = new CSGUnion(outer, so);

                if (k > 80)
                {
                    si = new Sphere(centre, 0.190 + k / 80.0);
                    si.Apply(t);
                    inner = new CSGUnion(inner, si);
                }
            }
            var sp = (so as Sphere);

            var nml = new Vector3(0.210, 0.133, 0.000).Normalise();
            var pt  = new Point3(sp.Centre.x, sp.Centre.y, 0.0);

            si  = new Plane(pt, nml);
            nml = new Vector3(nml.y, -nml.x, 0.0);
            so  = new Plane(pt + (nml * sp.Radius), nml);

            si    = new CSGIntersection(si, so);
            inner = new CSGUnion(inner, si);

            inner.Bound = new Sphere(centre, 1.9);

            scene.Add(new CSGDifference(outer, inner, mat));
        }
예제 #4
0
 public Material(Colour c, Finish f) : this(new Pigment(c), f)
 {
 }