예제 #1
0
        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;
        }
예제 #2
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;
 }
예제 #3
0
 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);
 }
예제 #4
0
        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();
        }
예제 #5
0
 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);
         }
     }
 }
예제 #6
0
 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);
         }
     }
 }