static Hitable CornellBox() { var red = new Lambertian(new vec3(0.65f, 0.05f, 0.05f)); var white = new Lambertian(new vec3(0.73f, 0.73f, 0.73f)); var green = new Lambertian(new vec3(0.12f, 0.45f, 0.15f)); Material aluminum = new Metal(new vec3(0.8f, 0.85f, 0.88f), 0.3f); var light = new DiffuseLight(new SolidTexture(new vec3(15, 15, 15))); int i = 0; Hitable[] hitables = new Hitable[8]; hitables[i++] = new YZRect(555, 0, 555, 0, 555, green, true); hitables[i++] = new YZRect(0, 0, 555, 0, 555, red); var lightRect = new XZRect(554, 213, 343, 227, 332, light, true); hitables[i++] = lightRect; hitables[i++] = new XZRect(0, 0, 555, 0, 555, aluminum); hitables[i++] = new XZRect(555, 0, 555, 0, 555, white, true); hitables[i++] = new XYRect(555, 0, 555, 0, 555, white, true); //Hitable box = new Box(new vec3(0, 0, 0), new vec3(165, 165, 165), white); //box = new Tranlate(new RotateY(box, -18), new vec3(130, 0, 65)); //hitables[i++] = box; Sphere sp = new Sphere(new vec3(190, 90.5f, 190), 90f, new Dieletric(1.6f)); hitables[i++] = sp; Hitable box2 = new Box(new vec3(0, 0, 0), new vec3(165, 330, 165), white); box2 = new Tranlate(new RotateY(box2, 15), new vec3(265, 0, 295)); hitables[i++] = box2; _lightPDf = new LightPDF(lightRect); _spherePDF = new SpherePDF(sp); return(new HitList(hitables.Where(p => p != null).ToArray())); }
public Box(vec3 min, vec3 max, Material mat) { _aabb = new AABB(min, max); var sides = new Hitable[6]; sides[0] = new XZRect(max.y, min.x, max.x, min.z, max.z, mat); sides[1] = new XZRect(min.y, min.x, max.x, min.z, max.z, mat, true); sides[2] = new YZRect(max.x, min.y, max.y, min.z, max.z, mat); sides[3] = new YZRect(min.x, min.y, max.y, min.z, max.z, mat, true); sides[4] = new XYRect(max.z, min.x, max.x, min.y, max.y, mat); sides[5] = new XYRect(min.z, min.x, max.x, min.y, max.y, mat, true); _sideList = new HitList(sides); }