1. ## Particle System problems

I have leanred how to make a particle system through the NeHe example (By the way, I have converted the tutorial to GLUT version, so if anyone wants the GLUT source code I can give it to you, send me and email). Anyway, The particle system works great, but for the first few moments of the program the particles seem to come in bursts instead of as a continuous wave. ill post the code
glDisable(GL_LIGHTING);
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, texture[2]);
for(loop = 0; loop < MAX_PARTICLES; loop++){
if(particle[loop].life <= 0.0){
particle[loop].active = 1;
particle[loop].life = 1.0;
particle[loop].x = marble.x;
particle[loop].y = marble.y;
particle[loop].z = marble.z;
particle[loop].xi = (rand()%60)-30.0;
particle[loop].yi = (rand()%60)-30.0;
particle[loop].zi = (rand()%60)-30.0;
if(marble.xi > 0.0){
particle[loop].xg = -5.0;
}
if(marble.xi < 0.0){
particle[loop].xg = 5.0;
}
else{
particle[loop].xg = 0.0;
}

}
if(particle[loop].active == 1){
glColor4f(1.0, 0.5, 0.0, particle[loop].life);
x = particle[loop].x;
y = particle[loop].y;
z = particle[loop].z - 5.0;
glTexCoord2f(0.0, 0.0); glVertex3f(x-0.05, y-0.05, z);
glTexCoord2f(0.0, 1.0); glVertex3f(x-0.05, y+0.05, z);
glTexCoord2f(1.0, 1.0); glVertex3f(x+0.05, y+0.05, z);
glTexCoord2f(1.0, 0.0); glVertex3f(x+0.05, y-0.05, z);
glEnd();
particle[loop].x += particle[loop].xi/3000;
particle[loop].y += particle[loop].yi/3000;
particle[loop].y += particle[loop].zi/3000;
particle[loop].xi += particle[loop].xg;
particle[loop].yi += particle[loop].yg;
particle[loop].zi += particle[loop].zg;

}
}
glEnable(GL_LIGHTING);

sorry for the crappy formatting. Can some1 tell me how to get the particles to act uniformly and not burst in thebeginning and only later to flow continuously.

2. ## Re: Particle System problems

Assuming that each particle starts with a life of zero, and when the particle is emitted, you assign it a life value.

Now, you probably do something like this. Each time the system is updated, you loop through the entire system and emits new particles out of those whos life is zero. This will, when starting the system the first time, emit all particles at the same time, since all particles has a life of zero.

Instead, before you loop through the system, get a random number N, say between 0 and 10. Then you loop throught the system as usual, but stops when you haev emitted N particles.

Then you can prevent the system from emitting too many particles at a time.

Be aware though. Setting the range and life too low might cause the system not to reach it's maximum numbers of particles.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•