We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Probem Multiple Rotation
Page Index Toggle Pages: 1
Probem Multiple Rotation (Read 445 times)
Probem Multiple Rotation
Jun 25th, 2008, 5:34pm
 
Hello

I'm actually working on a 3d particle system, drawn with OpenGl and texturing.

I apply a rotation on the X axis of the whole system with the following code (simplified):

pgl.beginGL();
gl.glTranslatef(width/2,height/2,100);
gl.glRotatef(rotateX, 1.0f, 0.0f, 0.0f);
system.draw();
pgl.endGL()

As I want each particles not to be rotated, I add the negative value to the rotation for each particles on the X-axis:

gl.glEnable( GL.GL_TEXTURE_2D );
pgl.bindTexture( particleTexture );
gl.glPushMatrix();
...
gl.glRotatef(-rotateX, 1.0f, 0.0f, 0.0f);
...
gl.glPopMatrix();
gl.glDisable( GL.GL_TEXTURE_2D );

It works fine in this case, the faces of the particles are not rotated.
But when I add a rotation on an other axis of the system :

gl.glRotatef(rotateX, 1.0f, 0.0f, 0.0f);
gl.glRotatef(rotateY, 1.0f, 1.0f, 0.0f);
system.draw();

and then...

gl.glPushMatrix();
...
gl.glRotatef(-rotateX, 1.0f, 0.0f, 0.0f);
gl.glRotatef(-rotateY, 0.0f, 1.0f, 0.0f);
...
gl.glPopMatrix();

.. . this method don't seems to be the good one.
Do you have any idea to keep the system's rotation and "invalidate" the particles'one?

Thanks
Re: Probem Multiple Rotation
Reply #1 - Jun 25th, 2008, 6:43pm
 
You have to apply them in the reverse order. So a rotateX then rotateY, has to be undone with a rotateY then rotateX.
Re: Probem Multiple Rotation
Reply #2 - Jun 25th, 2008, 6:56pm
 
Great !!!!

Thank you very much John.
Page Index Toggle Pages: 1