/// <summary> /// /// </summary> /// <param name="system"></param> /// <param name="emitter"></param> /// <param name="x"></param> /// <param name="y"></param> /// <param name="minks">Minimum Spring Constant</param> /// <param name="maxks">Maximum Spring Constant</param> /// <param name="minkd">Minimum Dampening Constant</param> /// <param name="maxkd">Maximum Dampening Constant</param> /// <param name="minrest">Minimum Rest Length</param> /// <param name="maxrest">Maximum Rest Length</param> public Meatball(ParticleSystem system, Emitter emitter, double x, double y, double minks, double maxks, double minkd, double maxkd, double minrest, double maxrest, bool anchored) { // create thre particles mParticles[0] = new Particle(); mParticles[0].IsAnchor = anchored; // anchors the first particle if so desired mParticles[1] = new Particle(); mParticles[2] = new Particle(); // update the particles Update(emitter, x, y); // Create the spring between particles 0 and 1 Spring s = new Spring(); s.ThisParticle = mParticles[0]; s.ConnectedParticle = mParticles[1]; s.SpringConstant = ParticleSystem.random.NextDouble(minks, maxks); //1.0, 4.0); s.DampingConstant = ParticleSystem.random.NextDouble(minkd, maxkd); //0.10, 0.30); s.RestLength = ParticleSystem.random.NextDouble(minrest, maxrest); //1.0, 6.0); mParticles[0].Connections.Add(s); mParticles[1].Connections.Add(s); //system.Forces.Add(s); // Create the spring between particles 0 and 2 s = new Spring(); s.ThisParticle = mParticles[0]; s.ConnectedParticle = mParticles[2]; s.SpringConstant = ParticleSystem.random.NextDouble(minks, maxks); //1.0, 4.0); s.DampingConstant = ParticleSystem.random.NextDouble(minkd, maxkd); //0.10, 0.30); s.RestLength = ParticleSystem.random.NextDouble(minrest, maxrest); //1.0, 6.0); mParticles[0].Connections.Add(s); mParticles[2].Connections.Add(s); //system.Forces.Add(s); // Create the spring between particles 1 and 2 s = new Spring(); s.ThisParticle = mParticles[1]; s.ConnectedParticle = mParticles[2]; s.SpringConstant = ParticleSystem.random.NextDouble(minks, maxks); //1.0, 4.0); s.DampingConstant = ParticleSystem.random.NextDouble(minkd, maxkd); //0.10, 0.30); s.RestLength = ParticleSystem.random.NextDouble(minrest, maxrest); //1.0, 6.0); mParticles[1].Connections.Add(s); mParticles[2].Connections.Add(s); //system.Forces.Add(s); // Add the particles to the system system.Particles.Add(mParticles[0]); system.Particles.Add(mParticles[1]); system.Particles.Add(mParticles[2]); }
/// <summary> /// Add a particle to the system /// </summary> /// <param name="system"></param> /// <param name="particle"></param> public override void AddParticle(ParticleSystem system, Particle particle) { base.AddParticle(system, particle); // pick a random X between X1 and X2 // then get the corresponding y double x = ParticleSystem.random.NextDouble(X1, X2); particle.Position = new Point(x + ParticleSystem.random.NextDouble(MinPositionOffset, MaxPositionOffset), LinearEquation(x) + ParticleSystem.random.NextDouble(MinPositionOffset, MaxPositionOffset)); }
/// <summary> /// Add a particle to the system. /// </summary> /// <param name="system"></param> /// <param name="particle"></param> public override void AddParticle(ParticleSystem system, Particle particle) { base.AddParticle(system, particle); // overwrite the position based on the emitters X and Y position particle.Position = new Point(this.X + ParticleSystem.random.NextDouble(MinPositionOffset, MaxPositionOffset), this.Y + ParticleSystem.random.NextDouble(MinPositionOffset, MaxPositionOffset)); }
/// <summary> /// Generate the particles by calling AddPartcle for a number of meatbals equal to /// the MaxParticles divided by three. /// </summary> /// <param name="system"></param> public override void GenerateParticles(ParticleSystem system) { //base.GenerateParticles(system); int totalConnections = MaxParticles; if (Meatball.NumberOfConnections > 0) totalConnections = MaxParticles / Meatball.NumberOfConnections; // Init the particles for the emitter Particle p = null; for (int i = 0; i < totalConnections; i++) { AddParticle(system, p); } }
/// <summary> /// Create a meatball which adds three particles with springs to the system. /// </summary> /// <param name="system"></param> /// <param name="particle"></param> public override void AddParticle(ParticleSystem system, Particle particle) { //base.AddParticle(system, particle); // ignore the base double x = ParticleSystem.random.NextDouble(X1, X2); Meatball meatball = new Meatball(system, this, x, LinearEquation(x), MinSpringConstant, MaxSpringConstant, MinDampeningConstant, MaxDampeningConstant, MinRestLength, MaxRestLength, true); // add each particle to the dictionary and its associated meatball. foreach (Particle p in meatball.Particles) { mMeatballs.Add(p, meatball); } }
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) { switch (connectionId) { case 1: this.FireParticleSystem = ((PlayGround.Engine.Controls.ParticleSystem)(target)); return; case 2: #line 38 "..\..\SandBox.xaml" ((System.Windows.Controls.Button)(target)).MouseEnter += new System.Windows.Input.MouseEventHandler(this.MyButtonMouseEnter); #line default #line hidden #line 38 "..\..\SandBox.xaml" ((System.Windows.Controls.Button)(target)).MouseLeave += new System.Windows.Input.MouseEventHandler(this.MyButtonMouseLeave); #line default #line hidden return; case 3: this.GooParticleSystem = ((PlayGround.Engine.Controls.ParticleSystem)(target)); return; case 4: #line 67 "..\..\SandBox.xaml" ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.MyButtonClicked); #line default #line hidden return; } this._contentLoaded = true; }
/// <summary> /// Generates the particles for an emitter, called once at creation by the Particle System. /// </summary> /// <param name="system"></param> public virtual void GenerateParticles(ParticleSystem system) { // Init the particles for the emitter for (int i = 0; i < MaxParticles; i++) { Particle mParticle = new Particle(); UpdateParticle(mParticle); this.AddParticle(system, mParticle); system.Particles.Add(mParticle); } }
/// <summary> /// Method which is used to perform additional processing when adding a particle to the system for the /// first time. /// </summary> /// <param name="system"></param> /// <param name="particle"></param> public virtual void AddParticle(ParticleSystem system, Particle particle) { }