Exemple #1
0
        /// <summary>
        /// Constructs a new particle emitter object.
        /// </summary>
        public ParticleEmitter(ParticleSystem particleSystem,
                               float particlesPerSecond, Vector3 initialPosition)
        {
            this.particleSystem = particleSystem;

            timeBetweenParticles = 1.0f / particlesPerSecond;

            previousPosition = initialPosition;
        }
        public DefferedRenderer(GraphicsDevice device, ContentManager content, SpriteBatch spriteBatch, SpriteFont font, Game game)
        {
            #region Initialize Variables
            this.device = device;
            this.spriteBatch = spriteBatch;
            this.lights = new LightManager(content, device);
            this.font = font;
            fsq = new FullscreenQuad(device);

            halfPixel = new Vector2()
            {
                X = 0.5f / (float)device.PresentationParameters.BackBufferWidth,
                Y = 0.5f / (float)device.PresentationParameters.BackBufferHeight
            };

            int backbufferWidth = device.PresentationParameters.BackBufferWidth;
            int backbufferHeight = device.PresentationParameters.BackBufferHeight;
            lightIntensity = 0.9f;

            colorRT = new RenderTarget2D(device, backbufferWidth, backbufferHeight, false, SurfaceFormat.Color, DepthFormat.Depth24);
            normalRT = new RenderTarget2D(device, backbufferWidth, backbufferHeight, false, SurfaceFormat.Color, DepthFormat.None);
            depthRT = new RenderTarget2D(device, backbufferWidth, backbufferHeight, false, SurfaceFormat.Single, DepthFormat.None);
            lightRT = new RenderTarget2D(device, backbufferWidth, backbufferHeight, false, SurfaceFormat.Color, DepthFormat.None);

            explosionParticles = new ParticleSystem(game, content, "ExplosionSettings");
            explosionSmokeParticles = new ParticleSystem(game, content, "ExplosionSmokeSettings");
            SmokePlumeParticles = new ParticleSystem(game, content, "SmokePlumeSettings");
            menu = new Menu(spriteBatch, content, device.PresentationParameters);
            #endregion

            #region Load Content
            font = content.Load<SpriteFont>("Georgia");
            clearBuffer = content.Load<Effect>("Effects/Clear");
            GBuffer = content.Load<Effect>("Effects/GBuffer");
            directionalLight = content.Load<Effect>("Effects/DirectionalLight");
            finalComposition = content.Load<Effect>("Effects/Composition");
            pointLightEffect = content.Load<Effect>("Effects/PointLight");
            sphereModel = content.Load<Model>("Models/sphere");
            normals = content.Load<Texture2D>("null_normal");
            speculars = content.Load<Texture2D>("null_specular");
            spotLight = content.Load<Effect>("Effects/SpotLight");
            spotLightGeometry = content.Load<Model>("SpotLightGeometry");
            spotCookie = content.Load<Texture2D>("SpotCookie");
            water = new Water(device, content, GBuffer);
            explosionSmokeParticles.LoadContent(device);
            explosionParticles.LoadContent(device);
            SmokePlumeParticles.LoadContent(device);
            #endregion
        }
Exemple #3
0
        /// <summary>
        /// Constructs a new projectile.
        /// </summary>
        public Projectile(ParticleSystem explosionParticles,
                          ParticleSystem explosionSmokeParticles,
                          ParticleSystem projectileTrailParticles)
        {
            this.explosionParticles = explosionParticles;
            this.explosionSmokeParticles = explosionSmokeParticles;

            // Start at the origin, firing in a random (but roughly upward) direction.
            position = Vector3.Zero;

            velocity.X = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange;
            velocity.Y = (float)(random.NextDouble() + 0.5) * verticalVelocityRange;
            velocity.Z = (float)(random.NextDouble() - 0.5) * sidewaysVelocityRange;

            // Use the particle emitter helper to output our trail particles.
            trailEmitter = new ParticleEmitter(projectileTrailParticles,
                                               trailParticlesPerSecond, position);
        }