public override void OnParticlesActivated(Span <int> particlesIndex) { if (ParticleEngine.NativeEnabled) { return; } fixed(Particle *particleArr = Emitter.Particles) { for (int i = 0; i < particlesIndex.Length; i++) { Particle *particle = &particleArr[particlesIndex[i]]; startColors[particle->ID] = particle->Color; if (!IsRandom) { continue; } randEndColors[particle->ID] = new Vector4( Between(end1.X, end2.X, Random.Next(0.0f, 1.0f)), Between(end1.Y, end2.Y, Random.Next(0.0f, 1.0f)), Between(end1.Z, end2.Z, Random.Next(0.0f, 1.0f)), Between(end1.W, end2.W, Random.Next(0.0f, 1.0f))); } } }
public void Get(float uniformRatio, out Vector2 position, out Vector2 velocity) { // Return random position and rotation within rectangle if not edge only. if (!EdgeOnly) { position = new Vector2(Random.Next(Size.X), Random.Next(Size.Y)) - Size / 2.0f; velocity = Random.NextUnitVector(); return; } // Continue if the emission is edge only. float totalLength = (Bounds.Z * 2.0f) + (Bounds.W * 2.0f); float len = Uniform ? uniformRatio * totalLength : Random.Next(totalLength); // Get position from rectangle edges from specified length. Vector4 bounds = Bounds; if (len < bounds.Z) { // Up. position = new Vector2(bounds.X + len, bounds.Y); velocity = UpDirection; } else if (len < bounds.W + bounds.Z) { // Right. len -= bounds.Z; position = new Vector2(bounds.X + bounds.Z, bounds.Y + len); velocity = RightDirection; } else if (len < bounds.Z + bounds.W + bounds.Z) { // Down. len -= bounds.W + bounds.Z; position = new Vector2((bounds.X + bounds.Z) - len, bounds.Y + bounds.W); velocity = DownDirection; } else { // Left. len -= bounds.Z + bounds.W + bounds.Z; position = new Vector2(bounds.X, (bounds.Y + bounds.W) - len); velocity = LeftDirection; } position -= Center; // Flip velocity if inwards. if (Direction == EmissionDirection.In) { velocity = -velocity; } // Randomize velocity if there is no emission direction. else if (Direction == EmissionDirection.None) { velocity = Random.NextUnitVector(); } }
public override void OnParticlesActivated(Span <int> particlesIndex) { if (IsRandom) { for (int i = 0; i < particlesIndex.Length; i++) { rand[particlesIndex[i]] = Random.Next(0.0f, 1.0f); } } }
private void RegenerateRandom() { if (!IsRandom || Emitter == null) { return; } rand = new float[Emitter.ParticlesLength]; for (int i = 0; i < rand.Length; i++) { rand[i] = Random.Next(0.0f, 1.0f); } }
public override void OnParticlesActivated(Span <int> particlesIndex) { for (int i = 0; i < particlesIndex.Length; i++) { int index = particlesIndex[i]; startLits[index] = Emitter.Particles[index].Color.W; if (!IsRandom) { continue; } rand[particlesIndex[i]] = Random.Next(0.0f, 1.0f); randEndLits[i] = Between(end1, end2, rand[i]); } }
public override void OnParticlesActivated(Span <int> particlesIndex) { if (ParticleEngine.NativeEnabled) { return; } if (!IsRandom) return; fixed(Particle *particleArr = Emitter.Particles) { for (int i = 0; i < particlesIndex.Length; i++) { Particle *particle = &particleArr[particlesIndex[i]]; rand[particle->ID] = Random.Next(0.0f, 1.0f); } } }
public override void OnParticlesActivated(Span <int> particlesIndex) { if (ParticleEngine.NativeEnabled) { return; } fixed(Particle *particleArr = Emitter.Particles) { for (int i = 0; i < particlesIndex.Length; i++) { Particle *particle = &particleArr[particlesIndex[i]]; startAlphas[particle->ID] = particle->Color.W; if (!IsRandom) { continue; } randEndAlphas[particle->ID] = Between(end1, end2, Random.Next(0.0f, 1.0f)); } } }
public override void OnParticlesActivated(Span <int> particlesIndex) { for (int i = 0; i < particlesIndex.Length; i++) { int index = particlesIndex[i]; startColors[index] = Emitter.Particles[index].Color; if (!IsRandom) { continue; } rand[particlesIndex[i]] = new Vector4( Random.Next(0.0f, 1.0f), Random.Next(0.0f, 1.0f), Random.Next(0.0f, 1.0f), Random.Next(0.0f, 1.0f)); randEndColors[i] = new Vector4( Between(end1.X, end2.X, rand[i].X), Between(end1.Y, end2.Y, rand[i].Y), Between(end1.Z, end2.Z, rand[i].Z), Between(end1.W, end2.W, rand[i].W)); } }