Example #1
0
        public static void RdrTimeMaps()
        {
            int    nx     = 800;
            int    ny     = 600;
            double radius = 31;
            double cam_z  = 30;

            int    N      = 60;
            double dtheta = 2 * Math.PI / N;

            for (int i = 0; i < N; i++)
            {
                Info.WriteLine(i);
                double theta = 0.5 * Math.PI + i * dtheta;
                Camera c     = new Camera(new Triple(-radius * Math.Cos(-theta), radius * Math.Sin(-theta), cam_z), 0, 0, nx, ny, 0.9);
                c.AzimuthAngle = theta;
                Background        basic      = new Background();
                GlobalLightSource light      = new GlobalLightSource(new Triple(1, 2, -4));
                Scene             main_scene = new Scene(basic, c);

                Stl              stl_subject = new Stl("stl/cat.stl");
                FacetBody        subject     = stl_subject.ToFacetBody(new Triple(0, 0, 25));
                RectangularPrism floor       = new RectangularPrism(new Triple(0, 0, 21.3), 190, 190, 0.3);

                subject.BodyOpticalProperties.BaseColor    = new Triple(0.2, 0.2, 0.9);
                subject.BodyOpticalProperties.IsReflective = true;
                subject.BodyOpticalProperties.Reflectivity = 0.21;

                main_scene.AddBody(floor);
                main_scene.AddBody(subject);
                main_scene.AddLight(light);

                double[,] dist, ts;
                int[,] id;
                RayImage picture      = main_scene.Render(out dist, out id, out ts);
                RayImage dist_picture = RayImage.ArrayLogRangeXY(dist, ColorGradient.Jedi());
                RayImage t_picture    = RayImage.ArrayLogRangeXY(ts, ColorGradient.Jedi());

                picture.Save("outputdata/images/" + i.ToString().PadLeft(N.ToString().Length, '0') + ".png");
                dist_picture.Save("outputdata/dists/" + i.ToString().PadLeft(N.ToString().Length, '0') + ".png");
                t_picture.Save("outputdata/times/" + i.ToString().PadLeft(N.ToString().Length, '0') + ".png");
            }

            /*double[,] a = new double[nx, ny];
             * for (int x = 0; x < nx; x++)
             * {
             *      for (int y = 0; y < ny; y++)
             *      {
             *              a[x,y] = (double)(x+y);
             *      }
             * }
             * RayImage test = RayImage.ArrayRangeXY(a, ColorGradient.Rgb());
             * test.Save("frames/s.png");*/
        }
Example #2
0
        public static void Liberty()
        {
            int    nx     = 1950;
            int    ny     = 1000;
            double radius = 280;
            double cam_z  = 26;
            double theta  = 0.5 * Math.PI;
            Camera c      = new Camera(new Triple(-radius * Math.Cos(-theta), radius * Math.Sin(-theta), cam_z), 0, 0, nx, ny, 0.9);

            c.AzimuthAngle = theta;
            Background        basic      = new Background();
            GlobalLightSource light      = new GlobalLightSource(new Triple(1, 2, -4));
            Scene             main_scene = new Scene(basic, c);

            main_scene.DoShadows = true;

            Info.WriteLine("Importing...");
            Stl stl_subject = new Stl("stl/liberty.stl");

            Info.WriteLine("Done importing.");
            FacetBody        subject = stl_subject.ToFacetBody(new Triple(0, 0, 250));
            RectangularPrism floor   = new RectangularPrism(new Triple(0, 0, subject.ZminGlobal - 0.15), 190, 190, 0.3);

            c.Position.Z     = subject.ZminGlobal;
            c.ElevationAngle = 0.78 * Math.PI / 3;

            subject.BodyOpticalProperties.BaseColor    = new Triple(0.8, 0.5, 0.8);
            subject.BodyOpticalProperties.IsReflective = true;
            subject.BodyOpticalProperties.Reflectivity = 0.21;

            //main_scene.AddBody(floor);
            main_scene.AddBody(subject);
            main_scene.AddLight(light);

            double[,] dist, ts;
            int[,] id;
            Info.WriteLine("Rendering...");
            RayImage picture      = main_scene.Render(out dist, out id, out ts);
            RayImage dist_picture = RayImage.ArrayLogRangeXY(dist, ColorGradient.Jedi());
            RayImage t_picture    = RayImage.ArrayLogRangeXY(ts, ColorGradient.Jedi());

            Info.WriteLine("Done.");

            picture.Save("frames/lib.png");
            dist_picture.Save("frames/libdists.png");
            t_picture.Save("frames/libtimes.png");
            Utils.WriteCsv("frames/dists.csv", dist);
            Utils.WriteCsv("frames/times.csv", ts);
        }
Example #3
0
        public static void DestroyComputer()
        {
            int    nx     = 1950;
            int    ny     = 1000;
            double radius = 25;
            double cam_z  = 26;
            double theta  = 0.5 * Math.PI;
            Camera c      = new Camera(new Triple(-radius * Math.Cos(-theta), radius * Math.Sin(-theta), cam_z), 0, 0, nx, ny, 0.9);

            c.AzimuthAngle = theta;
            Background basic = new Background();

            basic.HasFloor = false;
            basic.SkyColor = new Triple(1, 1, 1);
            GlobalLightSource light      = new GlobalLightSource(new Triple(1, 2, -4));
            Scene             main_scene = new Scene(basic, c);

            main_scene.DoShadows = true;

            Info.WriteLine("Importing...");
            Stl stl_subject = new Stl("stl/car-a.stl", true);

            Info.WriteLine("Done importing.");
            FacetBody        subject = stl_subject.ToFacetBody(new Triple(0, 0, 25));
            RectangularPrism floor   = new RectangularPrism(new Triple(0, 0, subject.ZminGlobal - 0.15), 190, 190, 0.3);

            subject.BodyOpticalProperties.BaseColor    = new Triple(0.5, 0.5, 0.5);
            subject.BodyOpticalProperties.IsReflective = false;
            subject.BodyOpticalProperties.Reflectivity = 0.21;

            //main_scene.AddBody(floor);
            main_scene.AddBody(subject);
            main_scene.AddLight(light);

            double[,] dist, ts;
            int[,] id;
            Info.WriteLine("Rendering...");
            RayImage picture      = main_scene.Render(out dist, out id, out ts);
            RayImage dist_picture = RayImage.ArrayLogRangeXY(dist, ColorGradient.Jedi());
            RayImage t_picture    = RayImage.ArrayLogRangeXY(ts, ColorGradient.Jedi());

            Info.WriteLine("Done.");

            picture.Save("cfdstuff/car.png");
            dist_picture.Save("cfdstuff/cardists.png");
            t_picture.Save("cfdstuff/cartimes.png");
        }