public void AddEmitter(EmitterParameters emitterParameters)
        {
            this.emitterParameters.Add(emitterParameters);
            Emitter emit = new Emitter(texPool, game, emitterParameters, 800, 600);//note: screenspace

            if (initialized)
            {
                emit.Initialize();
                emit.InitializeRender();
                emit.CreateRenderData();
                emit.SetRenderData();
            }

            emitters.Add(emit);
        }
Esempio n. 2
0
        public Emitter(TexturePool texturePool, DX11Game game, EmitterParameters parameters, int width, int height)
        {
            this.texturePool = texturePool;

            //this.declarationPool = declarationPool;
            this.game = game;
            context   = game.Device.ImmediateContext;

            this.parameters = parameters;
            this.width      = width;
            this.height     = height;
            simulater       = new ParticleSimulater(game, parameters.size, parameters.EffectName);



            var blendStateDescription = new BlendStateDescription();

            blendStateDescription.RenderTargets[0].BlendEnable           = true;
            blendStateDescription.RenderTargets[0].BlendOperation        = BlendOperation.Add;
            blendStateDescription.RenderTargets[0].BlendOperationAlpha   = BlendOperation.Add;
            blendStateDescription.RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
            blendStateDescription.RenderTargets[0].SourceBlend           = BlendOption.One;
            blendStateDescription.RenderTargets[0].SourceBlendAlpha      = BlendOption.One;
            blendStateDescription.RenderTargets[0].DestinationBlend      = BlendOption.One;
            blendStateDescription.RenderTargets[0].DestinationBlendAlpha = BlendOption.InverseSourceAlpha;

            additiveBlendState = BlendState.FromDescription(game.Device, blendStateDescription);
            blendStateDescription.RenderTargets[0].BlendEnable           = true;
            blendStateDescription.RenderTargets[0].BlendOperation        = BlendOperation.Add;
            blendStateDescription.RenderTargets[0].BlendOperationAlpha   = BlendOperation.Add;
            blendStateDescription.RenderTargets[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;
            blendStateDescription.RenderTargets[0].SourceBlend           = BlendOption.One;
            blendStateDescription.RenderTargets[0].SourceBlendAlpha      = BlendOption.One;
            blendStateDescription.RenderTargets[0].DestinationBlend      = BlendOption.InverseSourceAlpha;
            blendStateDescription.RenderTargets[0].DestinationBlendAlpha = BlendOption.InverseSourceAlpha;

            normalBlendState = BlendState.FromDescription(game.Device, blendStateDescription);

            depthStencilState = DepthStencilState.FromDescription(game.Device, new DepthStencilStateDescription
            {
                IsDepthEnabled  = true,
                DepthWriteMask  = DepthWriteMask.Zero,
                DepthComparison = Comparison.LessEqual
            });
        }