PDA

View Full Version : Particle Engine Question



Gammastrahler
08-06-2002, 09:39 AM
Hi, i have coded a simple particle engine to simulate fire. The particles are all camera-aligned. But the problem is, since the fire is placed in a 3D world, but goes only in the X and Y dimension, if i walk around the fire and look down the X axis, the fire looks like a thin line.

therefore, i additionally need to align the entire particle system (not just the particles) to always face the camera. can someone give me an idea of how to do that?

thanks
Gammastahler

timfoleysama
08-06-2002, 09:47 AM
Rather than try to camera-align a 2D particle effect, it would probably be better to just make a 3D effect. Whatever code you are using to generate and evolve the fire particles along the X and Y axes could probably be applied to the Z axis as well.

One of the nice benefits of using a particle system is that they give a feeling of 'volume' that old-fashioned sprite explosions/effects lacked. If you camera-align your system, then you are taking away this benefit.

Gammastrahler
08-06-2002, 10:15 AM
i have tried this method already but it looks like a rectangular volume.

iNsaNEiVaN
08-06-2002, 10:40 AM
tim, did you mean billboarding?

timfoleysama
08-06-2002, 08:27 PM
No, I wasn't really referring to billboarding. Billboarding is what makes the individual particles be camera-aligned, but I would not reccommend trying to do the same to the particle system.

Gammastrahler, if your fire effect looks like a rectangular solid when put in three dimensions, then you should probably change your code to generate the particles radially. For example, rather than:

newParticle.x = SPREAD*(2*randomFloat() - 1)
newParticle.z = SPREAD*(2*randomFloat() - 1)

write something like:

radius = SPREAD*(2*randomFloat() - 1)
angle = randomFloat()*2*PI
newParticle.x = radius*cos( angle )
newParticle.z = radius*sin( angle )

This assumes that you use the y axis as 'up' for your fire system, and that you control the distribution of particles in that dimension differently...

indice
08-07-2002, 03:04 AM
try this, before drawing

float mat[16];
glGetFloatv(GL_MODELVIEW_MATRIX, mat);
mat[0] = mat[5] = mat[10] = 1;
mat[4] = mat[8] = mat[1] = mat[9] = mat[2] = mat[6] = 0;
glLoadMatrixf(mat);