示例#1
0
 /// <summary>
 /// You should be RenderingEngine to do this
 /// </summary>
 public GenericParticles()
 {
     GenericParticles.instance = this;
     particles = new List<Particle>();
 }
示例#2
0
        /// <summary>
        /// Loads the spritebatch, shaders and initializes the lists to be used for data storage
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            PresentationParameters pp = GraphicsDevice.PresentationParameters;
            SurfaceFormat format = pp.BackBufferFormat;

            Vertices = new VertexPositionColorTexture[4];
            Vertices[0] = new VertexPositionColorTexture(new Vector3(-1, 1, 0), Color.White, new Vector2(0, 0));
            Vertices[1] = new VertexPositionColorTexture(new Vector3(1, 1, 0), Color.White, new Vector2(1, 0));
            Vertices[2] = new VertexPositionColorTexture(new Vector3(-1, -1, 0), Color.White, new Vector2(0, 1));
            Vertices[3] = new VertexPositionColorTexture(new Vector3(1, -1, 0), Color.White, new Vector2(1, 1));
            VertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColorTexture), Vertices.Length, BufferUsage.None);
            VertexBuffer.SetData(Vertices);

            colorMapRenderTarget = new RenderTarget2D(GraphicsDevice, w, h);
            normalMapRenderTarget = new RenderTarget2D(GraphicsDevice, w, h);
            shadowMapRenderTarget = new RenderTarget2D(GraphicsDevice, w, h, false, format, pp.DepthStencilFormat, pp.MultiSampleCount, RenderTargetUsage.DiscardContents);

            lightEffect = Game.Content.Load<Effect>("graphics/MultiTarget");
            lightCombinedEffect = Game.Content.Load<Effect>("graphics/DeferredCombined");

            lightEffectTechniquePointLight = lightEffect.Techniques["DeferredPointLight"];
            lightEffectTechniqueCircleLight = lightEffect.Techniques["DeferredCircleLight"];
            lightEffectTechniqueConeLight = lightEffect.Techniques["DeferredConeLight"];
            lightEffectTechniqueLineLight = lightEffect.Techniques["DeferredLineLight"];
            lightEffectParameterConeDirection = lightEffect.Parameters["coneDirection"];
            lightEffectParameterConeAngle = lightEffect.Parameters["coneAngle"];
            lightEffectParameterLineRadius = lightEffect.Parameters["radius"];
            lightEffectParameterMinSize = lightEffect.Parameters["minsize"];
            lightEffectParameterMaxSize = lightEffect.Parameters["maxsize"];
            lightEffectParameterHardEdge = lightEffect.Parameters["coneHardEdge"];
            lightEffectParameterLightColor = lightEffect.Parameters["lightColor"];
            lightEffectParameterLightDecay = lightEffect.Parameters["lightDecay"];
            lightEffectParameterNormapMap = lightEffect.Parameters["NormalMap"];
            lightEffectParameterPosition = lightEffect.Parameters["lightPosition"];
            lightEffectParameterEndPosition = lightEffect.Parameters["lightEndPosition"];
            lightEffectParameterScreenHeight = lightEffect.Parameters["screenHeight"];
            lightEffectParameterScreenWidth = lightEffect.Parameters["screenWidth"];
            lightEffectParameterStrength = lightEffect.Parameters["lightStrength"];

            lightCombinedEffectTechnique = lightCombinedEffect.Techniques["DeferredCombined2"];
            lightCombinedEffectParamAmbient = lightCombinedEffect.Parameters["ambient"];
            lightCombinedEffectParamLightAmbient = lightCombinedEffect.Parameters["lightAmbient"];
            lightCombinedEffectParamAmbientColor = lightCombinedEffect.Parameters["ambientColor"];
            lightCombinedEffectParamColorMap = lightCombinedEffect.Parameters["ColorMap"];
            lightCombinedEffectParamShadowMap = lightCombinedEffect.Parameters["ShadingMap"];
            lightCombinedEffectParamNormalMap = lightCombinedEffect.Parameters["NormalMap"];

            font = base.Game.Content.Load<SpriteFont>(@"graphics/font");

            animations = new List<Animation>();
            bgs = new List<Background>();
            staticbgs = new List<UniformBackground>();
            sheetmap = new Dictionary<string, SpriteSheet>();
            singletextures = new Dictionary<string, Texture2D>();
            particles = new GenericParticles();
        }