Particle System

Started by
4 comments, last by penetrator 22 years, 7 months ago
I found some tutorials about particle systems, but the point is that, since they are made up of gl_quads, when i rotate the camerara i arrive to point that quads are seen from the point where they are flat ... glHorizon_Project

www.web-discovery.net

Advertisement
I was about to post this same question but I thought I''d expand on this post instead. I render the Particle Engine as an effect for a solid 3d Object. I want this object to rotate in all 3 dimensions, but I run into the following problem:

I rotate my 3D object about the X axis, then about the Y axis. I then have to translate down the Y axis to place the particle engine in the proper location (I''m rendering a rocket with an engine effect). Rotating the particle engine about the Z axis is no problem (as 2D textures remain facing towards the camera), but when I rotate it around the Y axis our 2D quads with our 2D textures get rotated and this just doesn''t look good.

Unfortunately, I''m not math minded enough to be able to translate the two glRotatef''s into XYZ coordinates (probably using some polar coordinates with sin and cosin...) so that I can just use one glTranslatef to move the particle Engine in the proper position (as I don''t really need to rotate it around the Z or Y axis).

What is recomended in this situation?

"It''''s better to be though of as insane than to eat your next door neighboors and remove all doubt".
"It''s better to be thought of as insane than to eat your next door neighboors and remove all doubt".
PapaJosh, i tried also to rotate the quads so they always face properly, but you can see it is such a fake. I''d be happier to have a real 3d particle engine which is more good looking, IMO.

glHorizon_Project



www.web-discovery.net


I think what you want to use is billboarding so that the quads follow the camera round as it rotates. That way you will never see the sides

~StevE~
the other option is to "unrotate" all the glRotatef()''s that you performed before your current position. For example:

if you perform the following to get to your current position:

glRotatef ((GLfloat) nAngle, 0.0f, 0.0f, 1.0f);
glRotatef ((GLfloat) nAngle2, 0.0f, 1.0f, 0.0f);
glRotatef ((GLfloat) nAngle3, 1.0f, 0.0f, 0.0f);
glTranslatef(0.0f, 1.0f, 0.0f);

then perform the following right before you render your particle engine. This works for me (and looks good):

glRotatef ((GLfloat) nAngle3, 1.0f, 0.0f, 0.0f);
glRotatef ((GLfloat) nAngle2, 0.0f, 1.0f, 0.0f);
glRotatef ((GLfloat) nAngle, 0.0f, 0.0f, 1.0f);

"It''''s better to be thought of as insane than to eat your next door neighboors and remove all doubt".
"It''s better to be thought of as insane than to eat your next door neighboors and remove all doubt".
You want billboarding. The method I use is this:

float matrix[16];

glPushMatrix();
glTranslatef(particle->x,particle->y,particle->z);
glGetFloatv(GL_MODELVIEW_MATRIX, matrix);

glLoadIdentity();

glTranslatef(matrix[12],matrix[13],matrix[14]);

... draw quad ...

glPopMatrix();

Works like a charm. You can add a glRotatef(particle->roll, 0.0, 0.0, 1.0) to keep them from all having the same orientation on the screen if you want. Right before the draw. Any scales would happen right before the draw as well.

I think this might only work if you''re doing all your transformations in the MODELVIEW_MATRIX (as opposed to splitting them up into MODELVIEW and PROJECTION(?) matrices)...



This topic is closed to new replies.

Advertisement