public void Update(IEnumerable <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { foreach (var particle in particles) { particle.Lifetime -= frameTime; } }
public void Update(Span <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { for (int i = 0; i < particles.Length; ++i) { particles[i].Rotation += particles[i].RotationSpeed * frameTime; } }
public void Update(Span <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { for (int i = 0; i < particles.Length; ++i) { var time = 1 - (particles[i].Lifetime / particles[i].ConstantLifetime); // If fading in if (time >= startFadeInTime && time <= endFadeInTime) { var t = (time - startFadeInTime) / (endFadeInTime - startFadeInTime); // Interpolate from startAlpha to constantAlpha particles[i].Alpha = ((1 - t) * startAlpha) + (t * particles[i].ConstantAlpha); } // If fading out if (time >= startFadeOutTime && time <= endFadeOutTime) { var t = (time - startFadeOutTime) / (endFadeOutTime - startFadeOutTime); // Interpolate from constantAlpha to end alpha particles[i].Alpha = ((1 - t) * particles[i].ConstantAlpha) + (t * endAlpha); } particles[i].Lifetime -= frameTime; } }
public void Update(IEnumerable <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { foreach (var particle in particles) { particle.Rotation += particle.RotationSpeed * frameTime; } }
public void Update(Span <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { for (int i = 0; i < particles.Length; ++i) { particles[i].Lifetime -= frameTime; } }
public void Update(IEnumerable <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { foreach (var particle in particles) { var time = 1 - (particle.Lifetime / particle.ConstantLifetime); // If fading in if (time >= startFadeInTime && time <= endFadeInTime) { var t = (time - startFadeInTime) / (endFadeInTime - startFadeInTime); // Interpolate from startAlpha to constantAlpha particle.Alpha = ((1 - t) * startAlpha) + (t * particle.ConstantAlpha); } // If fading out if (time >= startFadeOutTime && time <= endFadeOutTime) { var t = (time - startFadeOutTime) / (endFadeOutTime - startFadeOutTime); // Interpolate from constantAlpha to end alpha particle.Alpha = ((1 - t) * particle.ConstantAlpha) + (t * endAlpha); } particle.Lifetime -= frameTime; } }
public Particle Initialize(ref Particle particle, ParticleSystemRenderState particleSystemRenderState) { particle.ConstantRadius = radiusMin + ((float)random.NextDouble() * (radiusMax - radiusMin)); particle.Radius = particle.ConstantRadius; return(particle); }
public Particle Initialize(Particle particle, ParticleSystemRenderState particleSystemRenderState) { var distance = offsetMax - offsetMin; var offset = offsetMin + (distance * new Vector3((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble())); particle.Position = offset; return(particle); }
public Particle Initialize(Particle particle, ParticleSystemRenderState particleSystemRenderState) { var t = (float)random.NextDouble(); particle.ConstantColor = colorMin + (t * (colorMax - colorMin)); particle.Color = particle.ConstantColor; return(particle); }
public Particle Initialize(ref Particle particle, ParticleSystemRenderState particleSystemRenderState) { var lifetime = lifetimeMin + ((lifetimeMax - lifetimeMin) * (float)random.NextDouble()); particle.ConstantLifetime = lifetime; particle.Lifetime = lifetime; return(particle); }
public Particle Initialize(Particle particle, ParticleSystemRenderState particleSystemRenderState) { var alpha = random.Next(alphaMin, alphaMax) / 255f; particle.ConstantAlpha = alpha; particle.Alpha = alpha; return(particle); }
public Particle Initialize(ref Particle particle, ParticleSystemRenderState particleSystemState) { var radius = initialRadius + ((float)random.NextDouble() * thickness); var angle = GetNextAngle(); particle.Position += radius * new Vector3((float)Math.Cos(angle), (float)Math.Sin(angle), 0); return(particle); }
public void Update(IEnumerable <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { foreach (var particle in particles) { var time = 1 - (particle.Lifetime / particle.ConstantLifetime); if (time <= fadeInTime) { particle.Alpha = (time / fadeInTime) * particle.ConstantAlpha; } } }
public Particle Initialize(Particle particle, ParticleSystemRenderState particleSystemState) { var r = new Vector3( Simplex1D(particleSystemState.Lifetime * noiseScale), Simplex1D((particleSystemState.Lifetime * noiseScale) + 101723), Simplex1D((particleSystemState.Lifetime * noiseScale) + 555557)); particle.Velocity = outputMin + (r * (outputMax - outputMin)); return(particle); }
public void Update(Span <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { for (int i = 0; i < particles.Length; ++i) { var time = 1 - (particles[i].Lifetime / particles[i].ConstantLifetime); if (time <= fadeInTime) { particles[i].Alpha = (time / fadeInTime) * particles[i].ConstantAlpha; } } }
public void Update(Span <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { for (int i = 0; i < particles.Length; ++i) { var timeLeft = particles[i].Lifetime / particles[i].ConstantLifetime; if (timeLeft <= fadeOutTime) { var t = timeLeft / fadeOutTime; particles[i].Alpha = t * particles[i].ConstantAlpha; } } }
public void Update(IEnumerable <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { foreach (var particle in particles) { var timeLeft = particle.Lifetime / particle.ConstantLifetime; if (timeLeft <= fadeOutTime) { var t = timeLeft / fadeOutTime; particle.Alpha = t * particle.ConstantAlpha; } } }
public Particle Initialize(ref Particle particle, ParticleSystemRenderState particleSystemState) { if (shuffle) { particle.Sequence = random.Next(sequenceMin, sequenceMax + 1); } else { particle.Sequence = sequenceMin + (sequenceMax > sequenceMin ? (counter++ % (sequenceMax - sequenceMin)) : 0); } return(particle); }
public void Update(IEnumerable <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { foreach (var particle in particles) { var time = 1 - (particle.Lifetime / particle.ConstantLifetime); if (time >= startTime && time <= endTime) { var t = (time - startTime) / (endTime - startTime); var radiusScale = (startScale * (1 - t)) + (endScale * t); particle.Radius = particle.ConstantRadius * radiusScale; } } }
public void Update(Span <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { for (int i = 0; i < particles.Length; ++i) { var time = 1 - (particles[i].Lifetime / particles[i].ConstantLifetime); if (time >= startTime && time <= endTime) { var t = (time - startTime) / (endTime - startTime); var radiusScale = (startScale * (1 - t)) + (endScale * t); particles[i].Radius = particles[i].ConstantRadius * radiusScale; } } }
public Particle Initialize(ref Particle particle, ParticleSystemRenderState particleSystemState) { var noiseScale = (float)this.noiseScale.NextNumber(); var r = new Vector3( Simplex1D(particleSystemState.Lifetime * noiseScale), Simplex1D((particleSystemState.Lifetime * noiseScale) + 101723), Simplex1D((particleSystemState.Lifetime * noiseScale) + 555557)); var min = outputMin.NextVector(); var max = outputMax.NextVector(); particle.Velocity = min + (r * (max - min)); return(particle); }
public void Update(IEnumerable <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { foreach (var particle in particles) { var time = 1 - (particle.Lifetime / particle.ConstantLifetime); if (time >= fadeStartTime && time <= fadeEndTime) { var t = (time - fadeStartTime) / (fadeEndTime - fadeStartTime); // Interpolate from constant color to fade color particle.Color = ((1 - t) * particle.ConstantColor) + (t * colorFade); } } }
public void Update(IEnumerable <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { var acceleration = gravity * frameTime; foreach (var particle in particles) { // Apply acceleration particle.Velocity += acceleration; // Apply drag particle.Velocity *= 1 - (drag * 30f * frameTime); particle.Position += particle.Velocity * frameTime; } }
public void Update(Span <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { var acceleration = gravity * frameTime; for (int i = 0; i < particles.Length; ++i) { // Apply acceleration particles[i].Velocity += acceleration; // Apply drag particles[i].Velocity *= 1 - (drag * 30f * frameTime); particles[i].Position += particles[i].Velocity * frameTime; } }
public void Update(Span <Particle> particles, float frameTime, ParticleSystemRenderState particleSystemState) { for (int i = 0; i < particles.Length; ++i) { var time = 1 - (particles[i].Lifetime / particles[i].ConstantLifetime); if (time >= fadeStartTime && time <= fadeEndTime) { var t = (time - fadeStartTime) / (fadeEndTime - fadeStartTime); // Interpolate from constant color to fade color particles[i].Color = ((1 - t) * particles[i].ConstantColor) + (t * colorFade); } } }
public Particle Initialize(Particle particle, ParticleSystemRenderState particleSystemRenderState) { var particleCount = Math.Min(inputMax, Math.Max(inputMin, particle.ParticleCount)); var t = (particleCount - inputMin) / (float)(inputMax - inputMin); var output = outputMin + (t * (outputMax - outputMin)); switch (fieldOutput) { case 3: particle.Radius = scaleInitialRange ? particle.Radius * output : output; break; } return(particle); }
public Particle Initialize(Particle particle, ParticleSystemRenderState particleSystemState) { var input = particle.GetVector(inputField); var offset = new Vector3( Lerp(offsetMin.X, offsetMax.X, (float)random.NextDouble()), Lerp(offsetMin.Y, offsetMax.Y, (float)random.NextDouble()), Lerp(offsetMin.Z, offsetMax.Z, (float)random.NextDouble())); if (outputField == ParticleField.Position) { particle.Position += input + offset; } else if (outputField == ParticleField.PositionPrevious) { particle.PositionPrevious = input + offset; } return(particle); }
public Particle Initialize(ref Particle particle, ParticleSystemRenderState particleSystemState) { var value = PiOver180 * (degrees + degreesMin + ((float)random.NextDouble() * (degreesMax - degreesMin))); if (randomlyFlipDirection && random.NextDouble() > 0.5) { value *= -1; } if (fieldOutput == ParticleField.Yaw) { particle.RotationSpeed = new Vector3(value, 0, 0); } else if (fieldOutput == ParticleField.Roll) { particle.RotationSpeed = new Vector3(0, 0, value); } return(particle); }
public Particle Initialize(Particle particle, ParticleSystemRenderState particleSystemRenderState) { var randomVector = new Vector3( ((float)random.NextDouble() * 2) - 1, ((float)random.NextDouble() * 2) - 1, ((float)random.NextDouble() * 2) - 1); // Normalize var direction = randomVector / randomVector.Length(); var distance = radiusMin + ((float)random.NextDouble() * (radiusMax - radiusMin)); var speed = speedMin + ((float)random.NextDouble() * (speedMax - speedMin)); var localCoordinateSystemSpeed = localCoordinateSystemSpeedMin + ((float)random.NextDouble() * (localCoordinateSystemSpeedMax - localCoordinateSystemSpeedMin)); particle.Position = direction * distance; particle.Velocity = (direction * speed) + localCoordinateSystemSpeed; return(particle); }
public Particle Initialize(ref Particle particle, ParticleSystemRenderState particleSystemRenderState) { var degrees = degreesOffset + degreesMin + ((float)random.NextDouble() * (degreesMax - degreesMin)); if (randomlyFlipDirection && random.NextDouble() > 0.5) { degrees *= -1; } if (fieldOutput == 4) { // Roll particle.Rotation = new Vector3(particle.Rotation.X, particle.Rotation.Y, degrees * PiOver180); } else if (fieldOutput == 12) { // Yaw particle.Rotation = new Vector3(particle.Rotation.X, degrees * PiOver180, particle.Rotation.Z); } return(particle); }