public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            Vector3 deltaColorFirst = _medianColor - _initialColor;
            Vector3 deltaColorLast = _finalColor - _medianColor;
            Particle particle = iterator.First;

            do
            {
                if (particle.Age < _median)
                {
                    float ageMultiplier = particle.Age / _median;
                    particle.Color.X = _initialColor.X + deltaColorFirst.X * ageMultiplier;
                    particle.Color.Y = _initialColor.Y + deltaColorFirst.Y * ageMultiplier;
                    particle.Color.Z = _initialColor.Z + deltaColorFirst.Z * ageMultiplier;
                }
                else
                {
                    float ageMultiplier = (particle.Age - _median) / (1f - _median);
                    particle.Color.X = _medianColor.X + deltaColorLast.X * particle.Age;
                    particle.Color.Y = _medianColor.Y + deltaColorLast.Y * particle.Age;
                    particle.Color.Z = _medianColor.Z + deltaColorLast.Z * particle.Age;
                }

            } while (iterator.MoveNext(ref particle));
        }
 public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
 {
     Particle particle = iterator.First;
     do
     {
         particle.Rotation = FlaiMath.GetAngle(particle.Velocity);
     } while (iterator.MoveNext(ref particle));
 }
 public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
 {
     Particle particle = iterator.First;
     if (_noiseSpeedMultiplier == 1)
     {
         do
         {
             particle.Opacity = _initialOpacity - _initialOpacity * particle.Age;
         } while (iterator.MoveNext(ref particle));
     }
     else
     {
         float multiplier = _initialOpacity * _noiseSpeedMultiplier + _initialOpacity;
         do
         {
             particle.Opacity = _initialOpacity - _initialOpacity * (1 + (multiplier - 1) * particle.Noise) * particle.Age; // with this opacity can go below zero
         } while (iterator.MoveNext(ref particle));
     }
 }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float scaleDelta = _finalScale - _initialScale;
            Particle particle = iterator.First;

            do
            {
                particle.Scale = _initialScale + scaleDelta * particle.Age;
            } while (iterator.MoveNext(ref particle));
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float opacityDelta = _finalOpacity - _initialOpacity;
            Particle particle = iterator.First;

            do
            {
                particle.Opacity = _initialOpacity + opacityDelta * particle.Age;
            } while (iterator.MoveNext(ref particle));
        }
Пример #6
0
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float hueChange = this.HueShiftAmount * updateContext.DeltaSeconds * FlaiMath.Pi / 180f;
            Matrix hueShiftMatrix = HueShifter.CreateHueTransformationMatrix(hueChange);

            Particle particle = iterator.First;
            do
            {
                HueShifter.Shift(ref particle.Color, ref hueShiftMatrix);
            } while (iterator.MoveNext(ref particle));
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            Vector3 deltaColor = _finalColor - _initialColor;
            Particle particle = iterator.First;
            do
            {
                particle.Color.X = _initialColor.X + deltaColor.X * particle.Age;
                particle.Color.Y = _initialColor.Y + deltaColor.Y * particle.Age;
                particle.Color.Z = _initialColor.Z + deltaColor.Z * particle.Age;

            } while (iterator.MoveNext(ref particle));
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            const float Multiplier = 200;
            float tempAttractionPower = this.AttractionPower * updateContext.DeltaSeconds * Multiplier;
            Particle particle = iterator.First;

            do
            {
                float distance = Vector2.Distance(this.AttractionPoint, particle.Position);
                particle.Velocity += (this.AttractionPoint - particle.Position) * tempAttractionPower / distance;
            } while (iterator.MoveNext(ref particle));
        }
Пример #9
0
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            if (this.RotationRate <= float.Epsilon)
            {
                return;
            }

            float deltaRotation = this.RotationRate * updateContext.DeltaSeconds;
            Particle particle = iterator.First;
            do
            {
                particle.Rotation += deltaRotation;
            } while (iterator.MoveNext(ref particle));
        }
Пример #10
0
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float deltaStrength = this.Strength * updateContext.DeltaSeconds;
            if (deltaStrength == 0f || _direction == Vector2.Zero)
            {
                return;
            }

            Vector2 deltaGravity = _direction * deltaStrength;
            Particle particle = iterator.First;
            do
            {
                particle.Velocity += deltaGravity;
            } while (iterator.MoveNext(ref particle));
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            if (this.DampingPower <= float.Epsilon)
            {
                return;
            }

            float inverseDampingDelta = -this.DampingPower * updateContext.DeltaSeconds; 
            Particle particle = iterator.First;
            do
            {
                particle.Velocity.X += particle.Velocity.X * inverseDampingDelta; // inverse velocity 
                particle.Velocity.Y += particle.Velocity.Y * inverseDampingDelta; // inverse velocity 
            } while (iterator.MoveNext(ref particle));
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            Particle particle = iterator.First;
            float maxSpeedSquared = _maximumSpeed * _maximumSpeed;

            do
            {
                float speedSquared = particle.Velocity.X * particle.Velocity.X + particle.Velocity.Y * particle.Velocity.Y;
                if (speedSquared > maxSpeedSquared)
                {
                    particle.Velocity.Normalize();
                    particle.Velocity *= _maximumSpeed;
                }

            } while (iterator.MoveNext(ref particle));
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float opacityDeltaFirst = _medianOpacity - _initialOpacity;
            float opacityDeltaLast = _finalOpacity - _medianOpacity;
            Particle particle = iterator.First;

            do
            {
                if (particle.Age < _median)
                {
                    particle.Opacity = _initialOpacity + opacityDeltaFirst * (particle.Age / _median);
                }
                else
                {
                    particle.Opacity = _medianOpacity + opacityDeltaLast * (particle.Age - _median) / (1f - _median);                   
                }

            } while (iterator.MoveNext(ref particle));
        }
        public override void Process(UpdateContext updateContext, ref ParticleBuffer.Iterator iterator)
        {
            float scaleDeltaFirst = _medianScale - _initialScale;
            float scaleDeltaLast = _finalScale - _medianScale;
            Particle particle = iterator.First;

            do
            {
                if (particle.Age < _median)
                {
                    particle.Scale = _initialScale + scaleDeltaFirst * (particle.Age / _median);
                }
                else
                {
                    particle.Scale = _medianScale + scaleDeltaLast * (particle.Age - _median) / (1f - _median);
                }

            } while (iterator.MoveNext(ref particle));
        }
        protected override void Render(GraphicsContext graphicsContext, ref ParticleBuffer.Iterator iterator, TextureDefinition texture, ParticleBlendMode blendMode)
        {
            if (!this.IsSpriteBatchAlreadyRunning)
            {
                graphicsContext.SpriteBatch.Begin(SpriteSortMode.Deferred, blendMode.ToBlendState(), SamplerState.PointClamp, null, null, null);
            }

            float inverseTextureWidth = 1f / texture.Width;
            Vector2 origin = new Vector2(texture.Width, texture.Height) / 2f;

            Particle particle = iterator.First;
            do
            {
                float scale = particle.Scale * inverseTextureWidth;          // Color * alpha is slow....
                graphicsContext.SpriteBatch.Draw(texture, particle.Position, new Color(particle.Color) * particle.Opacity, particle.Rotation, origin, particle.Scale);
            } while (iterator.MoveNext(ref particle));

            if (!this.IsSpriteBatchAlreadyRunning)
            {
                graphicsContext.SpriteBatch.End();
            }
        }