コード例 #1
0
 public Scene(RGBColor iamb, NameableCollection <Light> lights, Camera defaultCamera, float refractIndice)
 {
     this.IAmb         = iamb;
     this.RefractIndex = refractIndice;
     if (lights != null)
     {
         this.Lights = new NameableCollection <Light>(lights);
     }
     else
     {
         this.Lights = new NameableCollection <Light>();
     }
     this.primitives            = new NameableCollection <Primitive>();
     this.AccelerationStructure = new KDTreePrimitiveManager(this.primitives as IList <Primitive>);
     this.materials             = new NameableCollection <Material>();
     this.DefaultCamera         = defaultCamera;
     this.Cameras = new NameableCollection <Camera>();
     if (defaultCamera != null)
     {
         this.Cameras.Add(defaultCamera);
     }
     this.sampler           = new JitteredSampler();
     this.shader            = new PhongShader(this);
     this.renderStrategy    = new ScanlineRenderStrategy();
     this.isShadowActive    = false;
     this.softShadowSamples = 8;
     this.glossySamples     = 8;
     //this.cameras.CollectionChanged += new NotifyCollectionChangedEventHandler<Camera>(cameras_CollectionChanged);
 }
コード例 #2
0
ファイル: Scene.cs プロジェクト: hksonngan/sharptracing
 public Scene(RGBColor iamb, NameableCollection<Light> lights, Camera defaultCamera, float refractIndice)
 {
     this.IAmb = iamb;
     this.RefractIndex = refractIndice;
     if (lights != null) {
         this.Lights = new NameableCollection<Light>(lights);
     } else {
         this.Lights = new NameableCollection<Light>();
     }
     this.primitives = new NameableCollection<Primitive>();
     this.AccelerationStructure = new KDTreePrimitiveManager(this.primitives as IList<Primitive>);
     this.materials = new NameableCollection<Material>();
     this.DefaultCamera = defaultCamera;
     this.Cameras = new NameableCollection<Camera>();
     if (defaultCamera != null) {
         this.Cameras.Add(defaultCamera);
     }
     this.sampler = new JitteredSampler();
     this.shader = new PhongShader(this);
     this.renderStrategy = new ScanlineRenderStrategy();
     this.isShadowActive = false;
     this.softShadowSamples = 8;
     this.glossySamples = 8;
     //this.cameras.CollectionChanged += new NotifyCollectionChangedEventHandler<Camera>(cameras_CollectionChanged);
 }
コード例 #3
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);
         }
     }
 }
コード例 #4
0
        private void Scenes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs <Scene> e)
        {
            NameableCollection <Scene> scenes = sender as NameableCollection <Scene>;

            if (scenes != null)
            {
                foreach (Scene scene in scenes)
                {
                    scene.OnNameChanged -= this.nameable_OnNameChanged;

                    scene.Lights.CollectionChanged     -= this.Nameable_CollectionChanged;
                    scene.Primitives.CollectionChanged -= this.Nameable_CollectionChanged;
                    scene.Materials.CollectionChanged  -= this.Nameable_CollectionChanged;

                    foreach (INameable nameable in scene.Lights)
                    {
                        nameable.OnNameChanged -= this.nameable_OnNameChanged;
                    }
                    foreach (INameable nameable in scene.Primitives)
                    {
                        nameable.OnNameChanged -= this.nameable_OnNameChanged;
                    }
                    foreach (INameable nameable in scene.Materials)
                    {
                        nameable.OnNameChanged -= this.nameable_OnNameChanged;
                    }
                    //********************************************
                    scene.OnNameChanged += this.nameable_OnNameChanged;

                    scene.Lights.CollectionChanged     += this.Nameable_CollectionChanged;
                    scene.Primitives.CollectionChanged += this.Nameable_CollectionChanged;
                    scene.Materials.CollectionChanged  += this.Nameable_CollectionChanged;
                    foreach (INameable nameable in scene.Lights)
                    {
                        nameable.OnNameChanged += this.nameable_OnNameChanged;
                    }
                    foreach (INameable nameable in scene.Primitives)
                    {
                        nameable.OnNameChanged += this.nameable_OnNameChanged;
                    }
                    foreach (INameable nameable in scene.Materials)
                    {
                        nameable.OnNameChanged += this.nameable_OnNameChanged;
                    }
                }
            }

            #region MyRegion

            //foreach(Scene scene in e.NewItems) {
            //    switch(e.Action) {
            //        case NotifyCollectionChangedAction.Add:
            //        case NotifyCollectionChangedAction.Replace:
            //            scene.OnNameChanged += this.nameable_OnNameChanged;

            //            scene.Lights.CollectionChanged += Nameable_CollectionChanged;
            //            scene.Primitives.CollectionChanged += Nameable_CollectionChanged;
            //            scene.Materials.CollectionChanged += Nameable_CollectionChanged;
            //            foreach(INameable nameable in scene.Lights){
            //                nameable.OnNameChanged += this.nameable_OnNameChanged;
            //            }
            //            foreach(INameable nameable in scene.Primitives) {
            //                nameable.OnNameChanged += this.nameable_OnNameChanged;
            //            }
            //            foreach(INameable nameable in scene.Materials) {
            //                nameable.OnNameChanged += this.nameable_OnNameChanged;
            //            }

            //            break;
            //        case NotifyCollectionChangedAction.Remove:
            //        case NotifyCollectionChangedAction.Clear:
            //            scene.OnNameChanged -= this.nameable_OnNameChanged;

            //            scene.Lights.CollectionChanged -= Nameable_CollectionChanged;
            //            scene.Primitives.CollectionChanged -= Nameable_CollectionChanged;
            //            scene.Materials.CollectionChanged -= Nameable_CollectionChanged;

            //            foreach(INameable nameable in scene.Lights) {
            //                nameable.OnNameChanged -= this.nameable_OnNameChanged;
            //            }
            //            foreach(INameable nameable in scene.Primitives) {
            //                nameable.OnNameChanged -= this.nameable_OnNameChanged;
            //            }
            //            foreach(INameable nameable in scene.Materials) {
            //                nameable.OnNameChanged -= this.nameable_OnNameChanged;
            //            }
            //            break;
            //    }
            //}

            #endregion

            this.Refresh();
        }
コード例 #5
0
ファイル: Scene.cs プロジェクト: hksonngan/sharptracing
 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);
         }
     }
 }