Exemplo n.º 1
0
        public SmokeSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Create a single particle system and add it multiple times to the scene
            // graph ("instancing"). By default, all instances look identical. The
            // properties ParticleSystemNode.Color/Alpha/AngleOffset can be used to
            // render the particles with some variations.
            var particleSystem = Smoke.Create(ContentManager);

            ParticleSystemService.ParticleSystems.Add(particleSystem);

            _particleSystemNode0 = new ParticleSystemNode(particleSystem);
            GraphicsScreen.Scene.Children.Add(_particleSystemNode0);

            _particleSystemNode1             = new ParticleSystemNode(particleSystem);
            _particleSystemNode1.PoseWorld   = new Pose(new Vector3(5, 0, -5));
            _particleSystemNode1.Color       = new Vector3(0.9f, 0.8f, 0.7f);
            _particleSystemNode1.Alpha       = 0.8f;
            _particleSystemNode1.AngleOffset = 0.3f;
            GraphicsScreen.Scene.Children.Add(_particleSystemNode1);

            _particleSystemNode2             = new ParticleSystemNode(particleSystem);
            _particleSystemNode2.PoseWorld   = new Pose(new Vector3(-10, 5, -5), Matrix.CreateRotationZ(-ConstantsF.PiOver2));
            _particleSystemNode2.Color       = new Vector3(0.5f, 0.5f, 0.5f);
            _particleSystemNode2.AngleOffset = 0.6f;
            GraphicsScreen.Scene.Children.Add(_particleSystemNode2);
        }
Exemplo n.º 2
0
        public RingOfFireSample(Microsoft.Xna.Framework.Game game)
            : base(game)
        {
            // Create a new "empty" particle system.
            var particleSystem = new ParticleSystem();

            // Particle systems can have child particle systems.
            // Add a fire and a smoke effect as children.
            var fire  = Fire.Create(ContentManager);
            var smoke = Smoke.Create(ContentManager); // The smoke effect from the previous sample.

            particleSystem.Children = new ParticleSystemCollection {
                fire, smoke
            };

            // If we need to, we can modify the predefined effects.
            // Change the smoke particle lifetime.
            smoke.Parameters.Get <float>(ParticleParameterNames.Lifetime).DefaultValue = 4;
            // Change the smoke's start positions to a ring.
            smoke.Effectors.OfType <StartPositionEffector>().First().Distribution =
                new CircleDistribution {
                InnerRadius = 2, OuterRadius = 2
            };

            // Position the particle system (including its child) in the level.
            particleSystem.Pose = new Pose(new Vector3F(0, 3, 0));

            // We only need to add the parent particle system to the particle system service.
            // The service will automatically update the parent system each frame. The parent
            // system will automatically update its children.
            ParticleSystemService.ParticleSystems.Add(particleSystem);

            // Add the particle system to the scene graph.
            _particleSystemNode = new ParticleSystemNode(particleSystem);
            GraphicsScreen.Scene.Children.Add(_particleSystemNode);
        }