We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › pf Particle Type not found & whatz a P3D
Page Index Toggle Pages: 1
pf Particle Type not found & whatz a P3D ? (Read 865 times)
pf Particle Type not found & whatz a P3D ?
Dec 23rd, 2005, 7:49pm
 
I am attempting to learn more...
sometimes I run into something that I just cannot see...
like I tried to run a prog and got this error

Error: Type "Particle" was not found.


so how can particle not be found ? Is it a Library?
and also why is "P3D" entered after declaring the "stage size"

such as size(640, 480, P3D);


//the whole code is
//
Particle[] ptcls;
int n_ptcls;
int h = 0;

void setup()
{
 size(640, 480, P3D);
 background(random(255), random(255), random(255));  
 noStroke();
 n_ptcls = 50 + (int)random(150);
 ptcls = new Particle[n_ptcls];
 if(random(1) > 0.5)
 {
   h = (int)(25 + random(220));
 }
 else
 {
   h = 0;
 }
 
 for(int i = 0; i < n_ptcls; i++)
 {
   ptcls[i] = new Particle(random(width), random(height), 5 + random(10), h);  
 }      
}

void draw()
{
 for(int i = 0; i < n_ptcls; i++)
 {
   if(i == 0)
   {
     //ptcls[i].Interact(mouseX, mouseY);
     ptcls[i].Interact(ptcls[n_ptcls-1].x, ptcls[n_ptcls-1].y);
   }
   else
   {
     ptcls[i].Interact(ptcls[i-1].x, ptcls[i-1].y);
     for(int j = 0; j < n_ptcls; j++)
     {
       int k = 0;
       float vx = 0;
       float vy = 0;      
       if(i != j)
       {
         float dx = ptcls[i].x - ptcls[j].x;
         float dy = ptcls[i].y - ptcls[j].y;
         float d = sqrt(dx*dx + dy*dy);
         if(d < ptcls[i].r * 2)
         {
           vx += ptcls[j].vx;
           vy += ptcls[j].vy;
           k++;
           if(d < ptcls[i].r)
           {
               ptcls[i].x += dx * 0.02;
               ptcls[i].y += dy * 0.02;
               ptcls[j].x += -dx * 0.02;
               ptcls[j].y += -dy * 0.02;
           }
         }
         if(k != 0)
         {
           ptcls[i].vx += vx / (float)k * 0.05;
           ptcls[i].vy += vy / (float)k * 0.05;
           ptcls[i].vx *= 0.99;
           ptcls[i].vy *= 0.99;
         }
       }
     }
   }
   
   ptcls[i].Render();  
 }
}

...........................

Thnaks lots....

right now ... as yoy can tell, I am not much of a coder ..
but I do enjoy it...

mostly I try to take apart and understand other folks wonderful efforts

thanks!
Re: pf Particle Type not found & whatz a P3D ?
Reply #1 - Dec 27th, 2005, 2:07pm
 
P3D is used when you need to use a 3d coordinate system.
In this case it would be quite enough without P3D, and you have functions like smooth and strokeweight available when you don't use it..

You don't seem to have the class called Particle in your code.. you'll either have to find the one you got the idea from, or write your own..
something like
Code:

class Particle
{
float x,y;
float vx,vy;
Particle(float x, float y, float vx, float vy)
{
this.x = x;
this.y = y;
this.vx = vx;
this.vy = vy;
}

void Interact(somethingsomething)
{
do stuff here
}
}


regards

-seltar
Re: pf Particle Type not found & whatz a P3D ?
Reply #2 - Dec 29th, 2005, 4:00pm
 
regarding the P3D thing.. this is where "find in reference" becomes useful. since it's used in the size() command, select the word "size", right-click and select "find in reference" from the menu, which will turn up more background on P3D.

as for the Particle class, that depends on where you got the code.. it's another file (or set of files) that you're missing.
Page Index Toggle Pages: 1