Exemplo n.º 1
0
        private void UpdateRenderedImage(FullRaytracer raytracer, string statusText, double progress, Bitmap bitmap)
        {
            Context.Post((v) => {
                if (raytracer == CurrentRaytracer && Visible)
                {
                    labelStatus.Text = statusText;

                    barProgress.Value  = Math.Min((int)Math.Round(progress * 100, 2), 100);
                    labelProgress.Text = $"{progress * 100:F1}%";
                    statusStrip.Update();

                    if (bitmap != null)
                    {
                        RenderedImage = bitmap;
                        UpdateImages();
                    }

                    if (!ScenePrepared && CurrentRaytracer.Scene.IsReady)
                    {
                        ScenePrepared = true;
                        SceneInspector?.UpdateBVH();
                    }
                }
            }, null);
        }
Exemplo n.º 2
0
 public void SetRaytracer(FullRaytracer raytracer)
 {
     Raytracer      = raytracer;
     inputX.Minimum = 0;
     inputY.Minimum = 0;
     inputX.Maximum = raytracer.Scene.Width;
     inputY.Maximum = raytracer.Scene.Height;
 }
Exemplo n.º 3
0
        public RayInspector(FullRaytracer raytracer)
        {
            InitializeComponent();

            SetRaytracer(raytracer);

            Shown += (o, e) => RunTraces();
        }
Exemplo n.º 4
0
 private void UpdateDebugImage(FullRaytracer raytracer, Bitmap bitmap)
 {
     Context.Post((v) => {
         if (raytracer == CurrentRaytracer && Visible)
         {
             if (bitmap != null)
             {
                 DebugImage = bitmap;
                 UpdateImages();
             }
         }
     }, null);
 }
Exemplo n.º 5
0
        private void LoadScene(string path)
        {
            Scene scene = null;

#if !DEBUG
            try
#endif
            {
                scene = SceneLoader.FromFile(path);
            }
#if !DEBUG
            catch (LoaderException e)
            {
                MessageBox.Show(this, $"{e.Message}{(e.InnerException != null ? $": {e.InnerException.Message}" : "")}", "Error while loading scene");
            }
#endif

            if (scene != null)
            {
                buttonScene.Text = Path.GetFileName(path);

                comboCamera.Items.Clear();
                for (int i = 0; i < scene.Cameras.Count; i++)
                {
                    comboCamera.Items.Add($"Camera {i}");
                }
                comboCamera.SelectedIndex = 0;

                CloseInspectors();

                ScenePrepared = false;

                RestartRender(() => {
                    CurrentRaytracer = new FullRaytracer(scene, Environment.ProcessorCount, UpdateRenderedImage, UpdateDebugImage);
                    SetExposure();

                    CurrentPath = path;
                });
            }
        }