Archived

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

Quake-like particle explosions

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

Recommended Posts

hey everybody, I know how to do a simple particle engine, but I was wondering how the made those particle explosions in quake. were they random or pre-defined paths? The reason I ask is I think if I tried to make a random one (random directions) then it would turn out totally lop-sided. Any ideas? Thanks, Joe JoeMont001@aol.com

Share on other sites
Yeah, they''re random. Predefined paths would be a bit overdone for something that''s so small you probably couldn''t follow it anyway .

I don''t see why it should be lopsided, though. My particle engine uses random path''s just fine.

--TheGoop

Share on other sites
Hey. Are you doing a 2D or 3D game? I could give you the code that I used to do particles in my game, Extreme Guerrillas. I used code from Andre LaMothe''s book Tricks of the Windows Game Programming Gurus and modified it a little. They''re only 2D particles, but making it 3D would just mean adding another variable.

Alex

Share on other sites
Mine's 3d using OpenGL. Is there any technique to make the random number, um, less random and more spread out? (Like in Quake)

JoeMont001@aol.com

Edited by - Julio on June 18, 2000 9:21:04 PM

Share on other sites
If you want some control over your "random" numbers, make your own random number generator. There are lot''s of examples around the net, most of them for assembler...
But as far as I know here are some basic mathematical properties:

If you want the "random" particle positions to spread out more, generate the number in a space half of the cube of the space you want to fill with the explosion then double all the co-ordinates. I think this is what you want to do.

For example, if you want 20 particles spread out within a vitrual 100 units cubed space, then I would call the center 0,0,0 and go + 50 and - 50 from the center on each axis.

So now you could create a random number for the Y co-ord between -25 and positive 25 and the same for x and for y. Double all of these co-ords and then plot them!

The reason I get a smaller number than the max and then double is like this. If you plot 20 random pixels on a screen 800x600 you can easily see that it''s not always very even plotting around the screen, if you plot 20 random pixels within a 20x20 pixel surface, the probability of them being more even is much higher, so then I multiply all of those random pixels co-ords by 2 or 3 and then plot them you''ll get a more even distribution.

Just my idea, makes sense to me, but then again I think up a lot of things which only make sense to me... but give it a try!
See ya,
Ben

Share on other sites
Look at Richard Bensons(Keebler) stuff on particle engines he did for xgdc it makes some cool stuff

This is the Particle Chamber demo

This is the PowerPoint presentation I did at XGDC 99 in PowerPoint format. ( Make sure you have PowerPoint before downloading )

This is the PowerPoint presentation I did at XGDC 99 in HTML format ( kinda slow over a 56.6 ) http://home.earthlink.net/~rbenson/ParticleHTML/Particles.htm

Share on other sites
ok, thanks for the ideas. I''m checking out that demo right now Bordem. thanks again,
Joe

JoeMont001@aol.com

Share on other sites
to get a random number, just call srand(GetTickCount()) then do rand()%(N+1)
That will give you a random number between 0 an N

Share on other sites
quote:
Original post by SeanHowe

to get a random number, just call srand(GetTickCount()) then do rand()%(N+1)
That will give you a random number between 0 an N

To initialize the random number seed, use

    srand((unsigned int)time(NULL));

... just to be ANSI C compliant as much as possible...

Karmalaa

Share on other sites
Thanks guys, my particle explosion looks great. I'll post my source so everyone can check it out.
  int ParticleInit(float x, float y, float z){ for(int index=0; index<1000; index++) { explosion[index].y_rotation=rand()%360; explosion[index].x_rotation=rand()%180+1; explosion[index].x=x; explosion[index].y=y; explosion[index].z=z; } return 0;}...//some stufffor(int index=0; index<1000; index++){exlosion[index].x+=cos(explosion[index].y_rotation)*.02;explosion[index].z+=sin(explosion[index].y_rotation)*.02;explosion[index].y+=sin(explosion[index].x_rotation)*.02;glColor3f(1.0f,0.0f,0.0f);glBegin(GL_QUADS);glVertex3f(explosion[index].x-.006,explosion[index].y,explosion[index].z);glVertex3f(explosion[index].x-.006,explosion[index].y-.006,explosion[index].z);glVertex3f(explosion[index].x+.006,explosion[index].y-.006,explosion[index].z);glVertex3f(explosion[index].x+.006,explosion[index].y,explosion[index].z);glEnd();}

JoeMont001@aol.com

Edited by - Julio on June 21, 2000 10:23:43 AM

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631766
• Total Posts
3002233
×