/// <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) { MT.singleRayTracing = true; rayVisualizer.Reset(); // determine output image size: int width = ImageWidth; if (width <= 0) { width = panel1.Width; } int height = ImageHeight; if (height <= 0) { height = panel1.Height; } if (dirty || imfs == null) { imfs = getImageFunction(FormSupport.getScene(), width, height); dirty = false; } double[] color = new double[3]; long hash = imfs.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); rayVisualizer.AddingRaysFinished(); MT.singleRayTracing = false; }
/// <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) { MT.singleRayTracing = true; rayVisualizer.Reset(); // determine output image size: ActualWidth = ImageWidth; if (ActualWidth <= 0) { ActualWidth = panel1.Width; } ActualHeight = ImageHeight; if (ActualHeight <= 0) { ActualHeight = panel1.Height; } if (dirty || imfs == null) { int ss = 1; // Force preprocess. ctx = null; _ = FormSupport.getScene( out _, out _, ref ActualWidth, ref ActualHeight, ref ss, TextParam.Text); sc = FormSupport.getScene( out imfs, out rend, ref ActualWidth, ref ActualHeight, ref ss, TextParam.Text); // IImageFunction. if (imfs == null) // not defined in the script { imfs = getImageFunction(imfs, sc); } else if (imfs is RayCasting imfray) { imfray.Scene = sc; } imfs.Width = ActualWidth; imfs.Height = ActualHeight; // IRenderer. if (rend == null) // not defined in the script { rend = getRenderer(); } rend.ImageFunction = imfs; rend.Width = ActualWidth; rend.Height = ActualHeight; rend.Adaptive = 0; // 8? rend.ProgressData = progress; dirty = false; } // Set TLS. MT.SetRendering(sc, imfs, rend); double[] color = new double[3]; long hash = imfs.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); // Reset TLS. MT.ResetRendering(); rayVisualizer.AddingRaysFinished(); MT.singleRayTracing = false; }