Jump to content
  • Advertisement

Archived

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

penetrator

Particle System

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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".

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites
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)...



Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!