Beispiel #1
0
        /// <summary>
        /// Shoots single primary ray only..
        /// </summary>
        /// <param name="x">X-coordinate inside the raster image.</param>
        /// <param name="y">Y-coordinate inside the raster image.</param>
        private void singleSample(int x, int y)
        {
            if (imf == null)
            {
                imf  = FormSupport.getImageFunction(FormSupport.getScene());
                rend = null;
            }

            // determine output image size:
            int width = ImageWidth;

            if (width <= 0)
            {
                width = panel1.Width;
            }
            int height = ImageHeight;

            if (height <= 0)
            {
                height = panel1.Height;
            }
            imf.Width  = width;
            imf.Height = height;
            double[] color = new double[3];
            long     hash  = imf.GetSample(x + 0.5, y + 0.5, color);

            labelSample.Text = string.Format(CultureInfo.InvariantCulture, "Sample at [{0},{1}] = [{2:f},{3:f},{4:f}], {5:X}",
                                             x, y, color[0], color[1], color[2], hash);
        }
Beispiel #2
0
        public Form1(string[] args)
        {
            singleton = this;
            InitializeComponent();
            progress = new RenderingProgress(this);

            // Init scenes etc.
            string name;

            FormSupport.InitializeScenes(args, out name);
            Text += " (rev: " + rev + ") '" + name + '\'';

            buttonRes.Text = FormResolution.GetLabel(ref ImageWidth, ref ImageHeight);
        }
Beispiel #3
0
        /// <summary>
        /// [Re]-renders the whole image (in separate thread).
        /// </summary>
        private void RenderImage()
        {
            Cursor.Current = Cursors.WaitCursor;

            // determine output image size:
            int width = ImageWidth;

            if (width <= 0)
            {
                width = panel1.Width;
            }
            int height = ImageHeight;

            if (height <= 0)
            {
                height = panel1.Height;
            }

            Bitmap newImage = new Bitmap(width, height, PixelFormat.Format24bppRgb);

            if (imf == null)
            {
                imf  = FormSupport.getImageFunction(FormSupport.getScene());
                rend = null;
            }
            imf.Width  = width;
            imf.Height = height;

            if (rend == null)
            {
                rend = FormSupport.getRenderer(imf);
            }
            rend.Width        = width;
            rend.Height       = height;
            rend.Adaptive     = 8;
            rend.ProgressData = progress;

            progress.SyncInterval = 5000L;
            progress.Reset();
            CSGInnerNode.ResetStatistics();
            MT.InitThreadData();

            lock ( sw )
            {
                sw.Reset();
                sw.Start();
            }

            rend.RenderRectangle(newImage, 0, 0, width, height);

            long elapsed;

            lock ( sw )
            {
                sw.Stop();
                elapsed = sw.ElapsedMilliseconds;
            }

            string msg = string.Format(CultureInfo.InvariantCulture, "{0:f1}s  [ {1}x{2}, r{3:#,#}k, i{4:#,#}k, bb{5:#,#}k, t{6:#,#}k ]",
                                       1.0e-3 * elapsed, width, height,
                                       (Intersection.countRays + 500L) / 1000L,
                                       (Intersection.countIntersections + 500L) / 1000L,
                                       (CSGInnerNode.countBoundingBoxes + 500L) / 1000L,
                                       (CSGInnerNode.countTriangles + 500L) / 1000L);

            SetText(msg);
            Console.WriteLine("Rendering finished: " + msg);
            SetImage(newImage);

            Cursor.Current = Cursors.Default;

            StopRendering();
        }