private Vector3 GetForce(Particle particle) { float distFromWall = boundingSphere.Radius - (particle.Position - boundingSphere.Center).LengthSquared(); float distFromSphere = (particle.Position - spherePosition).LengthSquared(); //Vector3 force = Vector3.Zero; Vector3 force = rng.NextVector3(-0.0005f, 0.0005f, -0.0005f, 0.0005f); //Vector3 force = 5f / (distFromWall) * Vector3.Normalize(boundingSphere.Center - particle.Position); force += sphereSign * 500f / (distFromSphere + 20000) * Vector3.Normalize(particle.Position - spherePosition); //force += 0.01f * Vector3.Transform(force, deltayprQ); return force; }
private Color GetParticleColor(Particle particle) { var vel = particle.Velocity.Length(); vel /= 100f; return FromHsl(MathHelper.Lerp(0.75f, 0.1f, MathHelper.Clamp(vel, 0, 1)), particle.Saturation, MathHelper.Clamp(vel, 0.4f, 0.6f)); }
private void ResetParticles() { while (particles.Count < particleCount) SpawnParticles(); for (int i = 0; i < particles.Count; ++i) { particles[i] = new Particle(new Vector3(0, 0, 0), rng.NextVector3(0.1f, 5f), particles[i].Mass, particles[i].Saturation); } }