Results 1 to 2 of 2

Thread: Particle System problems

  1. #1
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Sydney, NSW, Australia

    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
    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].fade = (rand()%10)/1000.0 + 0.04;
    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;
    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);
    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;
    particle[loop].life -= particle[loop].fade;


    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.
    :: Sleep is a poor substitute for caffeine ::

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000

    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.

Similar Threads

  1. Particle system help
    By EchoDolphin in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-11-2018, 10:23 AM
  2. Particle System
    By Unresolved External in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-30-2011, 08:56 AM
  3. Particle System
    By micetta2482 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-14-2010, 11:05 AM
  4. Particle System API
    By cochondinde in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 02-20-2005, 03:37 AM
  5. Particle System
    By Coluna in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-13-2003, 09:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean