Quake-like particle explosions

Started by
8 comments, last by Julio 23 years, 10 months ago
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
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Advertisement
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
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
Alexbigshot@austin.rr.comFoolish man give wife grand piano. Wise man give wife upright organ.
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
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
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
__________________________Mencken's Law:"For every human problem, there is a neat, simple solution; and it's always wrong."
"Computers in the future may weigh no more than 1.5 tons."- Popular Mechanics, forecasting the relentless march of science in 1949
Look at Richard Bensons(Keebler) stuff on particle engines he did for xgdc it makes some cool stuff

This is the Particle Chamber demo
http://home.earthlink.net/~rbenson/ParticleChamber.zip

This is the PowerPoint presentation I did at XGDC 99 in PowerPoint format. ( Make sure you have PowerPoint before downloading )
http://home.earthlink.net/~rbenson/Particles.ppt


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





Im Always Bored--Bordem ICQ: 76947930
ok, thanks for the ideas. I''m checking out that demo right now Bordem. thanks again,
Joe

JoeMont001@aol.com
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
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
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


Please, let me do a just a little addenda...

To initialize the random number seed, use

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


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


Karmalaa

---[home page] [[email=karmalaa@inwind.it]e-mail[/email]]
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();}        

notice I used quads instead of glDrawPixel for speed optimizations.

JoeMont001@aol.com

Edited by - Julio on June 21, 2000 10:23:43 AM
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911

This topic is closed to new replies.

Advertisement