public Material(Pigment p, Finish f) { pigment = p; finish = f; filter = new Colour(1.0); ior = 1.0; transparent = false; }
public void Scene1() { var camera = new Camera(new Point3(1.0, 2.0, -15.0), // Position Point3.Origin, // 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.2); var l = new Light(new Point3(-1.0, -2.0, -10.0), // Position new Colour(1.0), // Colour 0.3); // Intensity scene.Add(l); l = new Light(new Point3(1.0, 5.0, -10.0), // Position new Colour(1.0), // Colour 0.3); // Intensity scene.Add(l); // A transparent sphere var glassfinish = new Finish(0.0, 0.1, 0.1, 0.3); var black = new Pigment(Colour.Black); var glass = new Material(black, glassfinish); glass.MakeTransparent(new Colour(0.8, 0.9, 1.0), 1.5); // glass.PerturbNormal(1.0, 0.1, VectorFunctions.Perlin); Solid s = new Sphere(new Point3(-1.4, 1.0, 0.0), 2.5, glass); scene.Add(s); // A strange textured Sphere var blueSmoke = new Pigment(Colour.PeachPuff, Colour.CadetBlue, RealFunctions.PerlinRidged); blueSmoke.Scale = 0.3; var f = new Finish(0.8, 0.4, 0.1, 0.0); var mr = new Material(blueSmoke, f); mr.PerturbNormal(0.1, 0.2, VectorFunctions.Perlin); s = new Sphere(new Point3(2.0, -1.0, -3.0), 1.5, mr); scene.Add(s); // A checkered plane var chex = new Pigment(new Colour(0.0), new Colour(1.0), RealFunctions.Checker); // Surface finish - diffuse, specular, phongsize, reflectance var finish = new Finish(0.6, 0.6, 0.1, 0.0); var mat = new Material(chex, finish); var p = new Plane(new Point3(0.0, 0.0, 5.001), -Vector3.UnitZ, mat); scene.Add(p); scene.Gamma = 1.2; }
public void Scene9() { var camera = new Camera(new Point3(12.0, -6.0, -20.0), new Point3(12.0, -6.0, 0.0), Vector3.UnitY, 1.0, // Short focal length picture.Width, picture.Height); scene.Camera = camera; scene.Antialias = true; var l = new Light(new Point3(7.0, 7.0, -7.0), // Position new Colour(1.0), // Colour 1.0); // Intensity scene.Add(l); var orange = new Pigment(Colour.Orange); var fin = new Finish(0.3, 0.4, 10.0, 0.5); var mat = new Material(orange, fin); var path = new GraphicsPath(); var ff = new FontFamily("Celtic Knots"); path.AddString("QWE\r\nASD\r\nZXC", ff, 0, 10f, new Point(0, 0), StringFormat.GenericTypographic); path.Flatten(); var pts = path.PathData.Points; var cmds = path.PathData.Types; var closeTo = pts[0]; for (var i = 1; i < pts.Length + 1; i++) { Solid c; if (cmds[i - 1] > 127) { c = Cylinder(new Point3((double)closeTo.X, 8 - (double)closeTo.Y, 0.0), new Point3((double)pts[i - 1].X, 8 - (double)pts[i - 1].Y, 0.0), 0.3); if (i < pts.Length) { closeTo = pts[i]; } } else { c = Cylinder(new Point3((double)pts[i].X, 8 - (double)pts[i].Y, 0.0), new Point3((double)pts[i - 1].X, 8 - (double)pts[i - 1].Y, 0.0), 0.3); } if (c != null) { c.Material = mat; scene.Add(c); } if (i < pts.Length) { scene.Add(new Sphere(new Point3((double)pts[i].X, 8 - (double)pts[i].Y, 0.0), 0.3, mat)); } } }
public void Scene2() { var camera = new Camera(new Point3(5.0, 5.0, -5.0), new Point3(0.0, 0.0, 0.0), Vector3.UnitY, 1.0, // Short focal length picture.Width, picture.Height); scene.Camera = camera; scene.Antialias = true; var l = new Light(new Point3(7.0, 7.0, -7.0), // Position new Colour(1.0), // Colour 0.5); // Intensity scene.Add(l); // l = new Light(new Point(-1.0, 5.0, 3.0), // Position // new Colour(1.0), // Colour // 0.5); // Intensity // scene.Add(l); Material mat; Finish fin; fin = new Finish(0.6, 0.4, 0.4, 0.5); var blue = new Pigment(Colour.CornflowerBlue); mat = new Material(blue, fin); Solid s1 = new CylinderX(1.0, 1.0, mat); var orchid = new Pigment(Colour.Orchid); mat = new Material(orchid, fin); Solid s2 = new CylinderY(1.0, 1.0, mat); var pink = new Pigment(Colour.DeepPink); mat = new Material(pink, fin); Solid s3 = new CylinderZ(1.0, 1.0, mat); scene.Add(s1 | s2 | s3); var orange = new Pigment(Colour.Orange); fin = new Finish(0.3, 0.4, 10.0, 0.5); mat = new Material(orange, fin); mat.MakeTransparent(Colour.Gold, 1.3); Solid s = new Sphere(new Point3(0.0, 0.0, 0.0), 2.0, mat); scene.Add(s); }
public void Scene5() { var camera = new Camera(new Point3(0.0, 0.0, -5.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, 5.0, -10.0), // Position new Colour(1.0), // Colour 0.5); // Intensity scene.Add(l); scene.Antialias = true; scene.Gamma = 0.8; scene.TraceMax = 30; Finish fin; Pigment pig; Material mat; Solid s; ///////////////////////////////////////////////////// fin = new Finish(0.5, 0.5, 0.5, 0.5); pig = new Pigment(Colour.Tomato); mat = new Material(pig, fin); for (var j = -5; j < 6; j++) { for (var k = -5; k < 6; k++) { s = new Sphere(new Point3(j, k, 0.0), 0.4, mat); scene.Add(s); } } pig = new Pigment(Colour.HotPink); mat = new Material(pig, fin); for (var j = -5; j < 6; j++) { for (var k = -5; k < 6; k++) { s = new Sphere(new Point3(j + 0.5, k + 0.5, -1.0), 0.4, mat); scene.Add(s); } } }
public void Scene8() { var camera = new Camera(new Point3(5.0, 8.0, -10.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, 5.0, -10.0), // Position new Colour(1.0), // Colour 0.5); // Intensity scene.Add(l); l = new Light(new Point3(10.0, -5.0, 0.0), // Position new Colour(1.0), // Colour 0.5); // Intensity scene.Add(l); scene.Antialias = true; Finish fin; Pigment pig; Material mat; fin = new Finish(0.5, 0.5, 0.5, 0.5); pig = new Pigment(Colour.Tomato); mat = new Material(pig, fin); pig = new Pigment(Colour.Lime, Colour.Navy, RealFunctions.Perlin); pig.Scale = 0.1; mat = new Material(pig, fin); //Material flakematerial = new Material(new Colour(0.8, 0.5, 0.2), 0.4, 0.2, 30.0, 0.4); var a = new Aggregate(mat); sphereflake(a, Point3.Origin, 1.0, 0, 0.5, 4); // Create a top level bounding volume var bound = new Sphere(Point3.Origin, 2.9); a.Bound = bound; scene.Add(a); }
public void Scene6() { var camera = new Camera(new Point3(0.0, 0.0, -5.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, 5.0, -10.0), // Position new Colour(1.0), // Colour 0.5); // Intensity scene.Add(l); scene.Antialias = false; // A wavy plane var wavy = new Pigment(Colour.DarkGreen, Colour.LawnGreen, Ripple); // Surface finish - diffuse, specular, phongsize, reflectance var finish = new Finish(0.6, 0.6, 0.1, 0.0); var mat = new Material(wavy, finish); var p = new Plane(new Point3(0.0, 0.0, 10.001), -Vector3.UnitZ, mat); scene.Add(p); // A transparent sphere var glassfinish = new Finish(0.0, 0.1, 0.1, 0.3); var black = new Pigment(Colour.Black); var glass = new Material(black, glassfinish); glass.MakeTransparent(Colour.White, 1.5); // glass.PerturbNormal(1.0, 0.1, VectorFunctions.Perlin); Solid s = new Sphere(new Point3(0.0, 0.0, 0.0), 1.0, glass); Solid b = new Sphere(new Point3(0.4, 0.2, 0.0), 0.2, glass); scene.Add(s - b); }
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)); }
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); }