public void StartRayTrace() { rayTraceProcess?.WaitStop(); var rayTraceConfguration = new RayTraceConfigurationModel { Width = rayTraceViewModel.BitmapWidth, Height = rayTraceViewModel.BitmapHeight, Samples = rayTraceViewModel.RenderSamples, UpdateRate = rayTraceViewModel.RenderUpdateRate, }; var sceneType = Int32.Parse(rayTraceViewModel.CurrentScene.Number); var aspect = (double)rayTraceConfguration.Width / (double)rayTraceConfguration.Height; IScene scene; switch (sceneType) { default: case 0: scene = new CoverScene(aspect); break; case 1: scene = new MaterialsScene(aspect); break; case 2: scene = new DefocusBlurScene(aspect); break; case 3: scene = new TestScene(aspect); break; } var rayTracer = new RayTracer(scene); var rayTraceTarget = new RayTraceTargetAdapter ( progress => rayTraceViewModel.Progress = progress, (x, y, c) => rayTraceViewModel.SetBitmapPixel(x, y, ColorFactory.CreateSquare(c)) ); rayTraceProcess = new RayTraceProcessHandler(rayTraceConfguration, rayTracer, rayTraceTarget); rayTraceProcess.StartAsync(); }
public void TerminateRayTrace() { rayTraceProcess?.WaitStop(); }