|  | 
 
  
    | 
      
        |  Author | Topic: beginner particle systems?  (Read 3647 times) |  |  
  
    | 
      
        | 
          
            | lunetta 
 
       
 | 
              
                | beginner particle systems? «  on: Mar 31st, 2005, 5:39am »
 |  |  Hi
 
 I need to build some example-sketches for my projects with particle systems;
 
 I need to build "simple" things; particle field responding to a gravity pole, or to a repeller pole, or assuming a certain shape like a circle.
 
 I have already seen a lot of examples like this around; but I browsed around and could only find much much more complex stuff.
 
 Does anyone has recommendations of sketches or theory pages to point me to?
 
 Really Grateful for any link
 |  
            |  |  |  |  
  
    | 
      
        | 
          
            | kurol 
 
 
 | 
              
                | Re: beginner particle systems? « Reply #1 on: Mar 31st, 2005, 10:03am »
 |  |  I'm new to this too, I think this tutorial (also found on tutorial page) is a good starting place if you're a n00b like me.
 |  
            | I hate programming . . .
     |  |  |  
  
    | 
      
        | 
          
            | st33d 
 
    
 | 
              
                | Re: beginner particle systems? « Reply #2 on: Mar 31st, 2005, 3:42pm »
 |  |  Eskimoblood pointed me to a lingo script that could be deciphered to create gravity effects.
 
 The trick seemed to be concentrating on the x and y acceleration separately and leaving a space around the mouse where gravity is killed so the particle isn't accelerated too hard.
 
 Code:
 | | particle [] p = new particle [10];
 void setup(){
 for(int i = 0; i < p.length; i++){
 p[i] = new particle(random(400),random(400),random(10));
 }
 size (400,400);
 }
 void loop(){
 background (255);
 for(int i = 0; i<p.length; i++){
 p[i].gmove();
 p[i].draw();
 }
 line(mouseX,0,mouseX,height);
 }
 class particle{
 float x,y,thisMass,xVelocity;
 particle (float x, float y, float thisMass){
 this.x = x;
 this.y = y;
 this.thisMass = thisMass;
 xVelocity = 0;
 }
 void gmove(){
 float mouseMass = 5;
 float distX = mouseX - x;
 //introduce the y and use pythagoras for the distance with two axises
 /*
 float distY = mouseY - y;
 float dist = sqrt(sq(distX) + sq(distY));
 */
 float dist = abs(distX); //remove this line for two axises
 //kill acceleration to create an orbit if too near mouse
 if (dist < 15){
 dist = 15;
 }
 //gravity equations - x axis only so you can pick it apart
 float grav = (thisMass * mouseMass) / sq(dist) * 5;
 float xGrav = grav * (distX/dist);
 float xAccel = xGrav / thisMass;
 xVelocity += xAccel;
 x += xVelocity;
 /*
 float yGrav = grav * (distY/dist);
 float yAccel = yGrav / thisMass;
 yVelocity += yAccel;
 y += yVelocity;
 */
 }
 void draw(){
 ellipse(x-5,y-5,10,10);
 }
 }
 
 | 
 | 
 |  
            | 
              
                | « Last Edit: Mar 31st, 2005, 3:45pm by st33d » |  |  I could murder a pint.
 |  |  |  
  
    | 
      
        | 
          
            | lunetta 
 
       
 | 
              
                | Re: beginner particle systems? « Reply #3 on: Mar 31st, 2005, 4:24pm »
 |  |  nice! thanks
 |  
            |  |  |  |  
  
    | 
      
        | 
          
            | kurol 
 
 
 | 
              
                | Re: beginner particle systems? « Reply #4 on: Mar 31st, 2005, 10:15pm »
 |  |  Here's my 1st attempt at making a class and particles.
 particleman
 
 When you click around the black box, particles will start ejecting from the mouse cursor.
 |  
            | I hate programming . . .
     |  |  |  
  
    | 
      
        | 
          
            | st33d 
 
    
 | 
              
                | Re: beginner particle systems? « Reply #5 on: Mar 31st, 2005, 11:25pm »
 |  |  Top dollar. I may have to try implementing that Kurol. I've been wondering how to get some fun action out of my motion reactive particles below. A bouncy spawner would be cool.
 
 http://www.st33d.net/processing/mfeed.pde
 |  
            | I could murder a pint.
 |  |  |  
 |