示例#1
0
        /// <summary>
        /// Creates a new Gaussian Blur Effect
        /// </summary>
        /// <param name="blurAmount">Intensity of the blur</param>
        /// <param name="toggle">If true, then deactivate it if already activated</param>
        public static void gaussianBlurEffect(float blurAmount, bool toggle = false, string effectFileName = "GaussianBlur_PP")
        {
            if (!toggle && _postProcessor.isEffectLoaded("GaussianBlur"))
            {
                _postProcessor.removeEffect("GaussianBlur");
                return;
            }
            else if (toggle && _postProcessor.isEffectLoaded("GaussianBlur"))
            {
                return;
            }

            _gbBlurAmount = blurAmount;

            _postProcessor.LoadEffect("GaussianBlur", GetEffect(effectFileName));

            // Calculate weights/offsets for horizontal pass
            gaussianCalcSettings(1.0f / (float)_graphicsDevice.Viewport.Width, 0,
                                 out gbWeightsH, out gboffsetsH);

            // Calculate weights/offsets for vertical pass
            gaussianCalcSettings(0, 1.0f / (float)_graphicsDevice.Viewport.Height,
                                 out gbweightsV, out gboffsetsV);

            gbRenderCapture = new CRenderCapture(_graphicsDevice);

            _postProcessor.gbweightsH = gbWeightsH;
            _postProcessor.gboffsetsH = gboffsetsH;
            _postProcessor.gbweightsV = gbweightsV;
            _postProcessor.gboffsetsV = gboffsetsV;
            _postProcessor.gbCapture  = gbRenderCapture;
        }
示例#2
0
        /// <summary>
        /// Initialize the class
        /// </summary>
        /// <param name="content">ContentManager class</param>
        /// <param name="graphicsDevice">GraphicsDevice class</param>
        /// <param name="spriteBatch">SpriteBatch class</param>
        /// <param name="postProcessor">CPostProcessor class</param>
        public static void LoadContent(ContentManager content, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch, CPostProcessor postProcessor, CRenderCapture renderCapture)
        {
            _spriteBatch    = spriteBatch;
            _graphicsDevice = graphicsDevice;
            _content        = content;
            _postProcessor  = postProcessor;
            _renderCapture  = renderCapture;

            _pixelTexture = content.Load <Texture2D>("Textures/Pixel");

            uwWaterfallTexture = content.Load <Texture2D>("Textures/uw_effect");
        }
示例#3
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            renderCapture = new Display2D.CRenderCapture(GraphicsDevice);
            postProcessor = new Display2D.CPostProcessor(GraphicsDevice);

            Display2D.C2DEffect.LoadContent(Content, GraphicsDevice, spriteBatch, postProcessor, renderCapture);
            Display2D.C2DEffect.isSoftwareEmbedded = isSoftwareEmbedded;
            Display2D.C2DEffect.renderTarget       = (isSoftwareEmbedded) ? em_renderTarget2D : renderCapture.renderTarget;

            Display3D.Particles.ParticlesManager.LoadContent(GraphicsDevice);
            Game.Settings.CGameSettings.LoadDatas(GraphicsDevice);
            Game.CConsole.LoadContent(Content, GraphicsDevice, spriteBatch, true, true /*false*/);
            Game.CConsole._activationKeys = Game.Settings.CGameSettings._gameSettings.KeyMapping.Console;
            Game.CConsole._activationKeys = Keys.F1;
            try
            {
                if (!isSoftwareEmbedded)
                {
                    Game.CGameManagement.ChangeState("CInGame");
                }
                Game.CGameManagement.LoadContent(Content, GraphicsDevice, spriteBatch, graphics);
            }
            catch (Exception e)
            {
                Game.CGameManagement.ChangeState("CError");
                Game.CGameManagement.SendParam("Error encountered\n\nCheck logs for more information");
                Game.CConsole.WriteLogs(e.ToString());
            }


            if (!isSoftwareEmbedded)
            {
                Game.Script.CLuaVM.Initialize();
                if (System.IO.Directory.Exists("Scripts"))
                {
                    foreach (string file in System.IO.Directory.GetFiles("Scripts", "*.lua").ToList <string>())
                    {
                        Game.Script.CLuaVM.LoadScript(file);
                    }
                }
                else
                {
                    System.IO.Directory.CreateDirectory("Scripts");
                }
            }
        }