public DocumentWindow(Scene scene) { this.InitializeComponent(); this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true); UnifiedScenesRepository.Scenes.Add(scene); this.TabText = scene.Name; UnifiedScenesRepository.CurrentEditingScene = UnifiedScenesRepository.Scenes[this.TabText]; UnifiedScenesRepository.Scenes[this.TabText].OnNameChanged += this.scene_OnNameChanged; foreach (Object renderType in Enum.GetValues(typeof(RenderType))) { toolStripRenderer.Items.Add(renderType); } toolStripRenderer.SelectedIndex = 0; foreach (Object strategy in Enum.GetValues(typeof(StrategyType))) { toolStripStrategy.Items.Add(strategy); } toolStripStrategy.SelectedIndex = 0; }
private void tiledPictureViewControlView_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } if (this.tracer.Scene == null) { this.tracer.Scene = UnifiedScenesRepository.Scenes[this.TabText]; } Ray ray = tracer.Scene.DefaultCamera.CreateRayFromScreen(e.X, e.Y); Intersection inter; if (this.Scene.FindIntersection(ray, out inter)) { PropertyWindow.Instance.PropertyGrid.SelectedObject = inter.HitPrimitive; } else { PropertyWindow.Instance.PropertyGrid.SelectedObject = UnifiedScenesRepository.Scenes[this.TabText]; } //Avoid MouseUp logic this.intersected = null; }
private void pictureView_MouseDown(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left) { return; } this.tracer.Scene = UnifiedScenesRepository.Scenes[this.TabText]; Ray ray = this.tracer.Scene.DefaultCamera.CreateRayFromScreen(e.X, e.Y); this.intersected = this.Scene.FindIntersection(ray, out this.current_intersection); this.prevPoint = new Point(e.X, e.Y); }
public void SetUpAndRenderScene() { this.StopRender(); this.tracer.Scene = UnifiedScenesRepository.Scenes[this.TabText]; int tilesX = Convert.ToInt32(this.txtXParallel.Text); int tilesY = Convert.ToInt32(this.txtYParallel.Text); this.tiledBitmap = new TiledBitmap(tilesX, tilesY, (int)this.tracer.Scene.DefaultCamera.ResX, (int)this.tracer.Scene.DefaultCamera.ResY); if (this.tiledPictureViewControlView.TiledBitmap != null) { this.tiledPictureViewControlView.TiledBitmap.Dispose(); } this.tiledPictureViewControlView.TiledBitmap = tiledBitmap; int numOfWorkers = this.tiledBitmap.TilesX * this.tiledBitmap.TilesY; int renderPerTiles = Convert.ToInt32(this.toolStripTextBoxRenderByTiles.Text); ThreadPool.SetMinThreads(numOfWorkers / renderPerTiles, numOfWorkers / renderPerTiles); this.StartRender(); }
private void SaveDialog(Scene scene) { if (UnifiedScenesRepository.Scenes.Contains(scene)) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Scene Files (*.xml)|*.xml;*.scn"; if (scene != null) { saveFileDialog.FileName = scene.Name; } if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { UnifiedScenesRepository.Scenes[scene.Name].Name = Path.GetFileNameWithoutExtension(saveFileDialog.FileName); scene.Save(saveFileDialog.FileName); } } }
public Scene(Scene toCopy) { if (toCopy != null) { this.defaultCamera = toCopy.defaultCamera; this.IAmb = toCopy.iAmb; this.refractIndex = toCopy.refractIndex; this.lights = new NameableCollection<Light>(toCopy.lights); this.primitives = new NameableCollection<Primitive>(toCopy.primitives); this.materials = new NameableCollection<Material>(toCopy.materials); this.cameras = new NameableCollection<Camera>(toCopy.cameras); this.isShadowActive = toCopy.isShadowActive; this.isSoftShadowActive = toCopy.isSoftShadowActive; this.softShadowSamples = toCopy.softShadowSamples; this.glossySamples = toCopy.glossySamples; this.IsEnvironmentMapped = toCopy.IsEnvironmentMapped; this.EnvironmentMap = toCopy.environmentMap; this.backgroundColor = toCopy.backgroundColor; if (toCopy.sampler != null) { this.sampler = new JitteredSampler(toCopy.sampler.NumberOfSamples, toCopy.sampler.NumberOfSets); } } }