internal override void ApplyForce(NewParticleRenderer particleRenderer, float time, ref Particle p) { Vector3 forcePos; this.GetForcePosition(particleRenderer, time, ref p, out forcePos); var distance = Vector3.DistanceSquared(forcePos, p.Position); if (this.IsRanged && distance > this.rangeSquared) { return; } if (this.IsSolid && distance < this.Cutout) { p.Velocity = Vector3.Zero; p.Forces = Vector3.Zero; Vector3.Lerp(ref p.Position, ref forcePos, this.CutoutLerp, out p.Position); ////p.Position = forcePos; } else { if (this.IsRanged && distance > this.rangeSquared) { return; } var distanceVector = (forcePos - p.Position); distanceVector.Normalize(); var f = this.Gravity * time * distanceVector; if (this.Decay) { float d; if (this.IsRanged) { d = (1 - (distance / this.rangeSquared)); f *= (d * d); } else { d = (1 / distance); f *= (d * d); } } p.Forces += f; } }
internal override void ApplyForce(NewParticleRenderer particleRenderer, float time, ref Particle p) { if (this.currentRenderer != particleRenderer || this.samplesDirty) { this.currentRenderer = particleRenderer; this.RefreshCache(); } if (this.currentParticleIndices == null) { return; } base.ApplyForce(particleRenderer, time, ref p); }
internal override void ApplyForce(NewParticleRenderer particleRenderer, float time, ref Particle p) { var distance = Vector3.DistanceSquared(this.transform.Position, p.Position); if (this.IsRanged && distance > this.rangeSquared) { return; } var f = time * this.Amount * this.transform.WorldTransform.Forward; if (this.Decay) { var d = (1 - (distance / this.rangeSquared)); f *= (d * d); } p.Forces += f; }
internal override void ApplyForce(NewParticleRenderer particleRenderer, float time, ref Particle p) { var distance = Vector3.DistanceSquared(this.transform.Position, p.Position); if (this.IsRanged && distance > this.rangeSquared) { return; } var up = this.transform.WorldTransform.Up; var r = this.transform.Position - p.Position; var v = Vector3.Cross(up, r); v.Normalize(); float factor = 0; if (this.Decay) { ////if (this.IsRanged) ////{ //// factor = 1 / (1 + (distance / this.Force)); ////} ////else ////{ ////} factor = 1 / (1 + (distance / this.Force)); } else { factor = this.Force; } var f = v * factor; p.Forces += f; ////p.Velocity = Vector3.Lerp(p.Velocity, f, 0.03f); }
protected override void GetForcePosition(NewParticleRenderer particleRenderer, float time, ref Particle p, out Vector3 pos) { pos = this.transformedSphereSamples[this.currentParticleIndices[p.Id]]; }
protected abstract void GetForcePosition(NewParticleRenderer particleRenderer, float time, ref Particle p, out Vector3 pos);
protected override void GetForcePosition(NewParticleRenderer particleRenderer, float time, ref Particle p, out Vector3 pos) { pos = this.transform.Position; }
internal abstract void ApplyForce(NewParticleRenderer particleRenderer, float time, ref Particle p);
protected override void ResolveDependencies() { base.ResolveDependencies(); this.particles = this.Owner.FindComponentInParents <NewParticleRenderer>(); }