private void ApplySettingsOnScene()
        {
            // Set Renderer
              if (radioButton_Forward.Checked)
            _scene.V3DLayer.RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_FORWARD;
              else if (radioButton_ForwardMobile.Checked)
            _scene.V3DLayer.RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_MOBILE_FORWARD;
              else if (radioButton_Deferred.Checked)
            _scene.V3DLayer.RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_DEFERRED;
              else if (radioButton_NoRenderer.Checked)
              {
            _scene.V3DLayer.RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_SIMPLE;
            return;
              }

              // Enable Post Processors
              ShapeComponentType[] compTypes = EditorManager.RendererNodeManager.ComponentTypes;
              _scene.V3DLayer.RendererSetup._rendererComponents.Clear();
              EditorManager.RendererNodeManager.RemovePostprocessors();
              foreach (ShapeComponentType compType in compTypes)
              {
            if (compType.Hidden)
              continue;

            if (!EditorManager.RendererNodeManager.CanAttachPostprocessor(compType.ProbeComponent))
              continue;

            bool bEnable = false;
            if (compType.UniqueName.Equals("VPostProcessSSAO"))
              bEnable = checkBox_SSAO.Checked;
            else if (compType.UniqueName.Equals("VPostProcessGlow"))
              bEnable = checkBox_Glow.Checked;
            else if (compType.UniqueName.Equals("VPostProcessDepthOfField"))
              bEnable = checkBox_DOF.Checked;
            else if (compType.UniqueName.Equals("VPostProcessToneMapping"))
              bEnable = checkBox_TM.Checked;
            else if (compType.UniqueName.Equals("VPostProcessFXAA"))
              bEnable = checkBox_AA.Checked;
            else if (compType.UniqueName.Equals("VDeferredShadingLights"))
              bEnable = checkBox_Lighting.Checked && radioButton_Deferred.Checked;
            else if (compType.UniqueName.Equals("VDeferredShadingRimLight"))
              bEnable = checkBox_RimLight.Checked && radioButton_Deferred.Checked;
            else if (compType.UniqueName.Equals("VGlobalFogPostprocess"))
              bEnable = checkBox_DepthFog.Checked && radioButton_Deferred.Checked;

            ShapeComponent comp = (ShapeComponent)compType.CreateInstance(_scene.V3DLayer);
            comp.Active = bEnable;
            _scene.V3DLayer.RendererSetup._rendererComponents.Add(comp);
              }

              // Update renderer node
              EditorManager.RendererNodeManager.UpdateRendererNode(_scene.RendererProperties, _scene.Postprocessors);

              // Setup Lighting
              if (checkBox_TOD.Checked)
              {
            _scene.V3DLayer.EnableTimeOfDay = true;

            ShapeBase lightShape = null;
            DynLightShape sunlight = null;
            DynLightShape backlight = null;
            #if !HK_ANARCHY
            SunglareShape sunglare = null;
            #else
            Shape3D sunglare = null;
            #endif

            if (checkBox_Sunlight.Checked)
            {
              sunlight = new DynLightShape("Sun Light");
              lightShape = sunlight;
              sunlight.LightType = LightSourceType_e.Directional;
              sunlight.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
              sunlight.ExportAsStatic = false;
              sunlight.CastModelShadows = checkBox_Shadows.Checked;
              sunlight.CastWorldShadows = checkBox_Shadows.Checked;
              sunlight.MakeTimeOfDayLight(1.0f, true, null);
            }

            // Shadows
            if (checkBox_Shadows.Checked && checkBox_Sunlight.Checked)
            {
            #if !HK_ANARCHY
              ShapeComponentType compType = (ShapeComponentType)EditorManager.EngineManager.ComponentClassManager.GetCollectionType("VShadowMapComponentSunlight");
              System.Diagnostics.Debug.Assert(compType != null, "Cannot create component of type VShadowMapComponentSunlight");
            #else
              ShapeComponentType compType = (ShapeComponentType)EditorManager.EngineManager.ComponentClassManager.GetCollectionType("VMobileShadowMapComponentSpotDirectional");
              System.Diagnostics.Debug.Assert(compType != null, "Cannot create component of type VMobileShadowMapComponentSpotDirectional");
            #endif
              if (compType != null)
              {
            ShapeComponent comp = (ShapeComponent)compType.CreateInstance(sunlight);
            sunlight.AddComponentInternal(comp);
              }
            }

            // Back light
            if (checkBox_Backlight.Checked && checkBox_Sunlight.Checked)
            {
              backlight = new DynLightShape("Back Light");
              backlight.LightType = LightSourceType_e.Directional;
              backlight.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
              backlight.ExportAsStatic = false;
              backlight.CastModelShadows = false;
              backlight.CastWorldShadows = false;
              backlight.MakeTimeOfDayBackLight();
            }

            #if !HK_ANARCHY
            // Sun glare
            if (checkBox_Sunglare.Checked && checkBox_Sunlight.Checked)
            {
              sunglare = new SunglareShape("Sun Glare");
              sunglare.AttachToTimeOfDay = true;
              sunglare.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
            }
            #endif

            // Group light shapes
            if (backlight != null || sunglare != null)
            {
              Group3DShape group = new Group3DShape("Sunlight Shapes");
              group.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
              group.AddChild(sunlight);
              if (backlight != null)
            group.AddChild(backlight);
              if (sunglare != null)
            group.AddChild(sunglare);
              lightShape = group;
            }

            // Add to scene
            if (lightShape != null)
              _scene.V3DLayer.AddShape(lightShape, null);
              }
              else
              {
            _scene.V3DLayer.EnableTimeOfDay = false;
              }
        }
        private void ApplySettingsOnScene()
        {
            // Set Renderer
            if (radioButton_Forward.Checked)
            {
                _scene.V3DLayer.RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_FORWARD;
            }
            else if (radioButton_ForwardMobile.Checked)
            {
                _scene.V3DLayer.RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_MOBILE_FORWARD;
            }
            else if (radioButton_Deferred.Checked)
            {
                _scene.V3DLayer.RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_DEFERRED;
            }
            else if (radioButton_NoRenderer.Checked)
            {
                _scene.V3DLayer.RendererNodeClass = IRendererNodeManager.RENDERERNODECLASS_SIMPLE;
                return;
            }

            // Enable Post Processors
            ShapeComponentType[] compTypes = EditorManager.RendererNodeManager.ComponentTypes;
            _scene.V3DLayer.RendererSetup._rendererComponents.Clear();
            EditorManager.RendererNodeManager.RemovePostprocessors();
            foreach (ShapeComponentType compType in compTypes)
            {
                if (compType.Hidden)
                {
                    continue;
                }

                if (!EditorManager.RendererNodeManager.CanAttachPostprocessor(compType.ProbeComponent))
                {
                    continue;
                }

                bool bEnable = false;
                if (compType.UniqueName.Equals("VPostProcessSSAO"))
                {
                    bEnable = checkBox_SSAO.Checked;
                }
                else if (compType.UniqueName.Equals("VPostProcessGlow"))
                {
                    bEnable = checkBox_Glow.Checked;
                }
                else if (compType.UniqueName.Equals("VPostProcessDepthOfField"))
                {
                    bEnable = checkBox_DOF.Checked;
                }
                else if (compType.UniqueName.Equals("VPostProcessToneMapping"))
                {
                    bEnable = checkBox_TM.Checked;
                }
                else if (compType.UniqueName.Equals("VPostProcessFXAA"))
                {
                    bEnable = checkBox_AA.Checked;
                }
                else if (compType.UniqueName.Equals("VDeferredShadingLights"))
                {
                    bEnable = checkBox_Lighting.Checked && radioButton_Deferred.Checked;
                }
                else if (compType.UniqueName.Equals("VDeferredShadingRimLight"))
                {
                    bEnable = checkBox_RimLight.Checked && radioButton_Deferred.Checked;
                }
                else if (compType.UniqueName.Equals("VGlobalFogPostprocess"))
                {
                    bEnable = checkBox_DepthFog.Checked && radioButton_Deferred.Checked;
                }

                ShapeComponent comp = (ShapeComponent)compType.CreateInstance(_scene.V3DLayer);
                comp.Active = bEnable;
                _scene.V3DLayer.RendererSetup._rendererComponents.Add(comp);
            }

            // Update renderer node
            EditorManager.RendererNodeManager.UpdateRendererNode(_scene.RendererProperties, _scene.Postprocessors);

            // Setup Lighting
            if (checkBox_TOD.Checked)
            {
                _scene.V3DLayer.EnableTimeOfDay = true;

                ShapeBase     lightShape = null;
                DynLightShape sunlight   = null;
                DynLightShape backlight  = null;
#if !HK_ANARCHY
                SunglareShape sunglare = null;
#else
                Shape3D sunglare = null;
#endif

                if (checkBox_Sunlight.Checked)
                {
                    sunlight                  = new DynLightShape("Sun Light");
                    lightShape                = sunlight;
                    sunlight.LightType        = LightSourceType_e.Directional;
                    sunlight.Position         = EditorManager.Scene.CurrentShapeSpawnPosition;
                    sunlight.ExportAsStatic   = false;
                    sunlight.CastModelShadows = checkBox_Shadows.Checked;
                    sunlight.CastWorldShadows = checkBox_Shadows.Checked;
                    sunlight.MakeTimeOfDayLight(1.0f, true, null);
                }

                // Shadows
                if (checkBox_Shadows.Checked && checkBox_Sunlight.Checked)
                {
#if !HK_ANARCHY
                    ShapeComponentType compType = (ShapeComponentType)EditorManager.EngineManager.ComponentClassManager.GetCollectionType("VShadowMapComponentSunlight");
                    System.Diagnostics.Debug.Assert(compType != null, "Cannot create component of type VShadowMapComponentSunlight");
#else
                    ShapeComponentType compType = (ShapeComponentType)EditorManager.EngineManager.ComponentClassManager.GetCollectionType("VMobileShadowMapComponentSpotDirectional");
                    System.Diagnostics.Debug.Assert(compType != null, "Cannot create component of type VMobileShadowMapComponentSpotDirectional");
#endif
                    if (compType != null)
                    {
                        ShapeComponent comp = (ShapeComponent)compType.CreateInstance(sunlight);
                        sunlight.AddComponentInternal(comp);
                    }
                }

                // Back light
                if (checkBox_Backlight.Checked && checkBox_Sunlight.Checked)
                {
                    backlight                  = new DynLightShape("Back Light");
                    backlight.LightType        = LightSourceType_e.Directional;
                    backlight.Position         = EditorManager.Scene.CurrentShapeSpawnPosition;
                    backlight.ExportAsStatic   = false;
                    backlight.CastModelShadows = false;
                    backlight.CastWorldShadows = false;
                    backlight.MakeTimeOfDayBackLight();
                }

#if !HK_ANARCHY
                // Sun glare
                if (checkBox_Sunglare.Checked && checkBox_Sunlight.Checked)
                {
                    sunglare = new SunglareShape("Sun Glare");
                    sunglare.AttachToTimeOfDay = true;
                    sunglare.Position          = EditorManager.Scene.CurrentShapeSpawnPosition;
                }
#endif

                // Group light shapes
                if (backlight != null || sunglare != null)
                {
                    Group3DShape group = new Group3DShape("Sunlight Shapes");
                    group.Position = EditorManager.Scene.CurrentShapeSpawnPosition;
                    group.AddChild(sunlight);
                    if (backlight != null)
                    {
                        group.AddChild(backlight);
                    }
                    if (sunglare != null)
                    {
                        group.AddChild(sunglare);
                    }
                    lightShape = group;
                }

                // Add to scene
                if (lightShape != null)
                {
                    _scene.V3DLayer.AddShape(lightShape, null);
                }
            }
            else
            {
                _scene.V3DLayer.EnableTimeOfDay = false;
            }
        }