/// <summary>
        /// Get all pixel positions in a rectangle.
        /// </summary>
        public static PixelPos[] GetPixelRange(Rectangle rect)
        {
            PixelPos[] pixels = new PixelPos[rect.Width * rect.Height];

            for (int x = 0; x < rect.Width; x++)
            {
                for (int y = 0; y < rect.Height; y++)
                {
                    pixels[x + y * rect.Width] = new PixelPos(rect.Left + x, rect.Top + y);
                }
            }

            return(pixels);
        }
Exemple #2
0
        public void Render()
        {
            while (Running)
            {
            }

            Running = true;

            while (!Stop)
            {
                for (uint pixel = 0; pixel < Pixels.Length && !Stop; pixel++)
                {
                    PixelPos pos = Pixels[pixel];

                    for (int i = 0; i < 1; i++)
                    {
                        DoubleColor color = GetColor(pos.X, pos.Y);

                        if (color == DoubleColor.Placeholder)
                        {
                            FullRaytracer.AddMiss(pos);
                        }
                        else
                        {
                            FullRaytracer.AddSample(pos, color);
                        }

                        Samples++;
                    }

                    if (!Stop && FullRaytracer.IsPaused)
                    {
                        Paused = true;
                        FullRaytracer.WaitForResume();
                        Paused = false;
                    }
                }
            }

            Stop    = false;
            Running = false;
        }
 /// <summary>
 /// Add a sample to the specified pixel.
 /// </summary>
 /// <param name="pos">The pixel position to add the sample to.</param>
 /// <param name="color">The color of the sample.</param>
 public void AddSample(PixelPos pos, DoubleColor color)
 {
     SampleSets[pos.X, pos.Y].AddSample(color);
 }
 /// <summary>
 /// Add a miss to the specified pixel.
 /// </summary>
 /// <param name="pos">The pixel position to add a miss to.</param>
 public void AddMiss(PixelPos pos)
 {
     SampleSets[pos.X, pos.Y].AddMiss();
 }
 /// <summary>
 /// Get the SampleSet data at the specified pixel position.
 /// </summary>
 /// <param name="x">The pixel position.</param>
 public SampleSet GetSampleSet(PixelPos position)
 {
     return(GetSampleSet(position.X, position.Y));
 }