Archived

This topic is now archived and is closed to further replies.

More particle confusion

This topic is 5873 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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;
   }
  

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Think of a rocket as the emitter and a smoke trail as the particles. You don''t check the smoke for collisions, you check the rocket.

If you have a stationary gun, make it fire an emitter and create some kind of particle effect trail. If you want a single particle make the emitter create a new particle every frame, and the particle lasts for 1 frame.


Share this post


Link to post
Share on other sites
Ok, but now think of when that rocket emitter strikes a wall, and spawns an explosion emitter. The particles from that emitter will go through the wall.

Or, consider a fountain. An emitter is set up to generate particles in an semi-random upward vector with gravity applied. How do you give these particles that movement vector?

Share this post


Link to post
Share on other sites
The particles routines in the character system are a bit better and allow you to aim the particle stream in a direction. This funtionality isn''t available in the main library particle routines. They only allow you to make particles with random or no velocity.

Share this post


Link to post
Share on other sites