Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm relatively new to OpenGL and I'm clueless how to implement explosion. So could anyone give me some ideas how to start? Suppose the explosion occurs at location $(x, y, z)$, then I'm thinking of randomly generate a collection of vectors with $(x, y, z)$ as origin, then draw some particle (glutSolidCube) which move along this vector for some period of time, says after 1000 updates, it disappear. Is this approach feasible? A minimal example would be greatly appreciated.

share|improve this question
1  
If you're still using glutSolidCube, you aren't at the point where you should be making particle effects. –  Nicol Bolas Oct 19 '12 at 19:34

2 Answers 2

up vote 5 down vote accepted

You are on the right track.

Typically for particle effects, flat triangles or quads are used for the particles as opposed to something like glutSolidCube. Often the quad are billboarded so that they are always oriented to the camera (so you never see them edge on). Having said that, there is no reason why you can't use cubes for your particles (apart from performance)

The outline for a particle effect is something like this;

  1. create a buch of particles, each particle will have its own velocity, position etc (see below)

  2. each particle is drawn as a textured quad, usually blended, with transparent edges. The texture and colour of the quad depends on the effect you are trying to achieve.

  3. When the particles are spawned at they explosion point,they will be launched out a random velocities, they will be initially very small, but are scaled larger over time. Usually each particle will also have some random angular velocity so the will also rotate as they move away from the spawn point.

  4. As a particle grows older, at some point it will be forced to fade away, once it is are completely transparent they will be removed.

There are a lot of properties to control to get the effect you want

  • range of initial velocities
  • rate of spawning
  • response to gravity & wind
  • range of angular velocities
  • rate of fading
  • time to live
  • rate of growing
  • particle texture(s) [often same texture is used for all particles]
  • potentially many more

Here is another opengl particle effect tutorial in OpenGL/glut

share|improve this answer
    
Thanks a lot Ken ;) –  Chan Oct 26 '12 at 16:33

A direct answer would be pretty long so here is a link to a decent tutorial on such a thing.

http://nehe.gamedev.net/tutorial/particle_engine_using_triangle_strips/21001/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.