public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var radiusSq = Radius * Radius;
            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var localPos = particle->Position - particle->TriggerPos;

                var distSq = localPos.LengthSquared();
                var normal = localPos.ToAxis().ToVector2();

                if (Inside)
                {
                    if (distSq < radiusSq) continue;

                    SetReflected(distSq, particle, normal);
                }
                else
                {
                    if (distSq > radiusSq) continue;

                    SetReflected(distSq, particle, -normal);
                }

            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var velocityThreshold2 = VelocityThreshold * VelocityThreshold;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var velocity2 = particle->Velocity.X * particle->Velocity.X +
                                particle->Velocity.Y * particle->Velocity.Y;
                var deltaColor = VelocityColor - StationaryColor;

                if (velocity2 >= velocityThreshold2)
                {
                    VelocityColor.CopyTo(out particle->Color);
                }
                else
                {
                    var t = (float)Math.Sqrt(velocity2) / VelocityThreshold;

                    particle->Color = new HslColor(
                        deltaColor.H * t + StationaryColor.H,
                        deltaColor.S * t + StationaryColor.S,
                        deltaColor.L * t + StationaryColor.L);
                }
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var left = particle->TriggerPos.X + Width * -0.5f;
                var right = particle->TriggerPos.X + Width * 0.5f;
                var top = particle->TriggerPos.Y + Height * -0.5f;
                var bottom = particle->TriggerPos.Y + Height * 0.5f;

                var xPos = particle->Position.X;
                var yPos = particle->Position.Y;

                if ((int)particle->Position.X < left)
                {
                    xPos = particle->Position.X + Width;
                }
                else if ((int)particle->Position.X > right)
                {
                    xPos = particle->Position.X - Width;
                }

                if ((int)particle->Position.Y < top)
                {
                    yPos = particle->Position.Y + Height;
                }
                else if ((int)particle->Position.Y > bottom)
                {
                    yPos = particle->Position.Y - Height;
                }
                particle->Position = new Vector2(xPos, yPos);
            }
        }
 public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
 {
     while (iterator.HasNext)
     {
         var particle = iterator.Next();
         particle->Opacity = 1.0f - particle->Age;
     }
 }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var delta = FinalScale - InitialScale;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Scale = delta * particle->Age + InitialScale;
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var rotationRateDelta = RotationRate * elapsedSeconds;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Rotation += rotationRateDelta;
            }
        }
Exemplo n.º 7
0
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var drag = -DragCoefficient * Density * particle->Mass * elapsedSeconds;

                particle->Velocity = new Vector2(
                    particle->Velocity.X + particle->Velocity.X * drag,
                    particle->Velocity.Y + particle->Velocity.Y * drag);
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var vector = Direction * (Strength * elapsedSeconds);

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Velocity = new Vector2(
                    particle->Velocity.X + vector.X * particle->Mass,
                    particle->Velocity.Y + vector.Y * particle->Mass);
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var delta = FinalHue - InitialHue;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Color = new HslColor(
                    delta * particle->Age + InitialHue,
                    particle->Color.S,
                    particle->Color.L);
            }
        }
Exemplo n.º 10
0
        public void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var diff = Position + particle->TriggerPos - particle->Position;

                var distance2 = diff.LengthSquared();

                var speedGain = _gravConst * Mass / distance2 * elapsedSeconds;
                // normalize distances and multiply by speedGain
                particle->Velocity += diff.ToAxis() * speedGain;
            }
        }
        public unsafe void Update(float elapsedseconds, ParticleBuffer.ParticleIterator iterator)
        {
            var delta = new HslColor(FinalColor.H - InitialColor.H,
                                   FinalColor.S - InitialColor.S,
                                   FinalColor.L - InitialColor.L);

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                particle->Color = new HslColor(
                    InitialColor.H + delta.H * particle->Age,
                    InitialColor.S + delta.S * particle->Age,
                    InitialColor.L + delta.L * particle->Age);
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {

            while (iterator.HasNext)
            {
                var particle = iterator.Next();

                var left = particle->TriggerPos.X + Width * -0.5f;
                var right = particle->TriggerPos.X + Width * 0.5f;
                var top = particle->TriggerPos.Y + Height * -0.5f;
                var bottom = particle->TriggerPos.Y + Height * 0.5f;

                var xPos = particle->Position.X;
                var xVel = particle->Velocity.X;
                var yPos = particle->Position.Y;
                var yVel = particle->Velocity.Y;

                if ((int)particle->Position.X < left)
                {
                    xPos = left + (left - xPos);
                    xVel = -xVel * RestitutionCoefficient;
                }
                else if (particle->Position.X > right)
                {
                    xPos = right - (xPos - right);
                    xVel = -xVel * RestitutionCoefficient;
                }

                if (particle->Position.Y < top)
                {
                    yPos = top + (top - yPos);
                    yVel = -yVel * RestitutionCoefficient;
                }
                else if ((int)particle->Position.Y > bottom)
                {
                    yPos = bottom - (yPos - bottom);
                    yVel = -yVel * RestitutionCoefficient;
                }
                particle->Position = new Vector2(xPos, yPos);
                particle->Velocity = new Vector2(xVel, yVel);
            }
        }
        public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
        {
            var velocityThreshold2 = VelocityThreshold * VelocityThreshold;

            while (iterator.HasNext)
            {
                var particle = iterator.Next();
                var velocity2 = particle->Velocity.LengthSquared();

                float h;
                if (velocity2 >= velocityThreshold2)
                {
                    h = VelocityHue;
                }
                else
                {
                    var t = (float)Math.Sqrt(velocity2) / VelocityThreshold;
                    h = MathHelper.Lerp(StationaryHue, VelocityHue, t);
                }
                particle->Color = new HslColor(h, particle->Color.S, particle->Color.L);
            }
        }