More particle confusion

Started by
12 comments, last by Dr Pain 22 years, 4 months ago
I''m really confused. Hopefully I''m just doing something stupid and can''t see it. Below is the source for my particle collision routine, followed by a screenshot of it in action. The TestEntityCollision routine draws a box from LastLocation to Location. As can be seen in the screenshot, LastLocation is always exactly equal to Location (verified in the debugger), except for the leading particle, which has LastLocation always equal to (0,0,0). It seems as if the current particle''s LastLocation is being set to the previous particle''s Location, and the leading particle never gets its LastLocation set. What am I missing here?
  
void TestParticleCollision(void *particle)
   {
   PR_PARTICLE *  theParticle;

   theParticle = (PR_PARTICLE *)particle;
   if (collisionMgr.TestEntityCollision(NULL, &theParticle->LastLocation, &theParticle->Location, 10.0f) == TRUE)
      PR_RemoveParticle(theParticle->Index);

   theParticle->LastLocation = theParticle->Location;
   }
  
Advertisement
Unless you draw the box inside the test particle collision (or test entity collision) routine, the last and current position will be the same because of this:

theParticle->LastLocation = theParticle->Location;

Don''t know about the first one
Author of Power Render (http:/www.powerrender.com)
I am drawing the box inside the TestEntityCollision routine.

Perhaps I should explain further. The TestEntityCollision routine builds an OOBB between the objects start and end locations. The 10.0f passed in is the width of the object, and right now the height is fixed at 500. So the red lines you see here at each particle is actually a box of height 500 and width 10 and depth 0.

Edited by - Dr Pain on November 14, 2001 7:19:05 AM
Any idea what''s going on?
Well, I think the problem is that the particles are not moving like I''d expect at all. It appears that each particle is stationary until it expires, then it is reused at some other location, not necessarily the next in the path. I could see this happening by printing out each particle''s Index above it.

Chris, can you give a little insight as to how the particle system works internally?

Thanks,
Dave
I don''t know what you''re doing exactly but typically you have an emitter (not a particle) that moves around and creates particles behind it. The particles could be stationary, fall to the ground, bounce, etc.

If you want to use the particle system for projectiles you want to check the movement of the emitter, not the particles that it creates.
Author of Power Render (http:/www.powerrender.com)
So I guess you''re saying the particle collision callback is useless and that particles will always pass though walls and other objects?
No. I''m saying you probably are moving the emitter but not the particles in this case.

If you want particles to move, either turn on gravity for them or use a random velocity value. Also the movement flag must be turned on. Particles don''t have the same velocity as the emitter creating them otherwise they would just pile up on the same location.

Author of Power Render (http:/www.powerrender.com)
Hmmm... so are you saying that the direction vector passed to PR_CreateEmitter() defines how the emitter moves? I was assuming that was how the particle would move. Well that would explain what I''m seeing. I guess I should read the documentation more closely, since it does say that.

What I want is a (not-necessarily) stationary emitter that creates moving particles. I''ve called PR_SetParticleMovement with TRUE, but I don''t see how to set the velocity vector for the particle itself. There is a PR_CreateParticle function that takes a direction vector, but it doesn''t seem appropriate to be calling that.

So how do I set the velocity of the particles? I would want to define the vector when creating the emitter, rather than within the definition of the emitter.

Thanks again
So does anyone know how to give a particle velocity (not the emitter)? It''s still not obvious to me.

This topic is closed to new replies.

Advertisement