예제 #1
0
파일: World.cs 프로젝트: lilinm/RayTracing
        public void CornellBox()
        {
            List <GeometryObject> list  = new List <GeometryObject>();
            GeoMaterial           red   = new Lambert(new ConstantTexture(new SColor(0.65, 0.05, 0.05)));
            GeoMaterial           white = new Lambert(new ConstantTexture(new SColor(0.73, 0.73, 0.73)));
            GeoMaterial           green = new Lambert(new ConstantTexture(new SColor(0.12, 0.45, 0.15)));
            GeoMaterial           light = new DiffuseLight(new ConstantTexture(new SColor(15, 15, 15)));

            FilpNormals filpNormals = new FilpNormals(new YZRect(0, 555, 0, 555, 555, green));

            list.Add(filpNormals);
            YZRect yzRect = new YZRect(0, 555, 0, 555, 0, red);

            list.Add(yzRect);
            XZRect xzRect = new XZRect(213, 343, 227, 332, 554, light);

            list.Add(xzRect);
            FilpNormals filpNormals1 = new FilpNormals(new XZRect(0, 555, 0, 555, 555, white));

            list.Add(filpNormals1);
            XZRect xzRect1 = new XZRect(0, 555, 0, 555, 0, white);

            list.Add(xzRect1);
            FilpNormals filpNormals2 = new FilpNormals(new XYRect(0, 555, 0, 555, 555, white));

            list.Add(filpNormals2);

            AddGeoObj(new bvh_node(list));
        }
예제 #2
0
파일: World.cs 프로젝트: lilinm/RayTracing
        public void FinalFace()
        {
            List <GeometryObject> list    = new List <GeometryObject>();
            List <GeometryObject> boxList = new List <GeometryObject>();
            GeoMaterial           white   = new Lambert(new ConstantTexture(new SColor(0.73, 0.73, 0.73)));
            GeoMaterial           ground  = new Lambert(new ConstantTexture(new SColor(0.48, 0.83, 0.52)));

            for (int i = 0; i < 20; ++i)
            {
                for (int j = 0; j < 20; ++j)
                {
                    double w  = 100.0;
                    double x0 = -1000.0 + i * w;
                    double z0 = -1000.0 + j * w;
                    double y0 = 0.0;
                    double x1 = x0 + w;
                    double y1 = 100.0 * (Form2.random() + 0.01);
                    double z1 = z0 + w;
                    boxList.Add(new Box(new Point3D(x0, y0, z0), new Point3D(x1, y1, z1), ground));
                }
            }

            list.Add(new bvh_node(boxList));
            GeoMaterial light = new DiffuseLight(new ConstantTexture(new SColor(7, 7, 7)));

            list.Add(new XZRect(123, 423, 147, 412, 554, light));
            Point3D center = new Point3D(400, 400, 200);

            list.Add(new Sphere(center, 50, new Lambert(new ConstantTexture(new SColor(0.7, 0.3, 0.1)))));
            list.Add(new Sphere(new Point3D(260, 150, 45), 50, new Dielectric(1.5)));
            list.Add(new Sphere(new Point3D(0, 150, 145), 50, new Metal(new ConstantTexture(new SColor(0.8, 0.8, 0.9)), 10)));

            GeometryObject boundary = new Sphere(new Point3D(360, 150, 145), 70, new Dielectric(1.5));

            list.Add(boundary);
            list.Add(new ConstantMedium(boundary, 0.2, new ConstantTexture(new SColor(0.2, 0.4, 0.9))));
            GeometryObject boundary1 = new Sphere(new Point3D(0, 0, 0), 5000, new Dielectric(1.5));

            list.Add(new ConstantMedium(boundary1, 1e-4, new ConstantTexture(new SColor(1, 1, 1))));

            list.Add(new Sphere(new Point3D(400, 200, 400), 100, new Lambert(new ImageTexture(new Bitmap(@"C:\Users\cdd13\Desktop\学习\桌面程序开发\光线追踪素材\材质\EarthHighRes.jpg")))));
            list.Add(new Sphere(new Point3D(220, 280, 300), 80, new Lambert(new NoiseTexture(0.1))));
            List <GeometryObject> boxList2 = new List <GeometryObject>();

            for (int i = 0; i < 1000; ++i)
            {
                boxList2.Add(new Sphere(new Point3D(165.0 * Form2.random(), 165.0 * Form2.random(), 165.0 * Form2.random()), 10, white));
            }
            list.Add(new Translate(new GlobalGeometryList(boxList2), new Vector3D(-100, 270, 395)));
            AddGeoObj(new GlobalGeometryList(list));
        }