heygirls_uk
07-03-2004, 04:05 AM
I'm attempting to translate a cylinder so that its center is at the origin, and then make it rotate. However, the origin appears to be
moving with the translation so that the leftmost end of the cylinder is always at the origin. How can I rotate the cylinder with its center at the origin? Is it possible to rotate it within its own local coordinate space (i.e. its center already at local origin)?
The code I'm using is:
Gl.glPushMatrix();
Gl.glLoadIdentity();
//translate center of cylinder to origin
Gl.glTranslatef(-1.25f, 0.0f, 0.0f);
Gl.glRotatef(a, 0.0f, 1.0f, 0.0f);
Glu.gluQuadricNormals(q1, Glu.GLU_SMOOTH);
Glu.gluQuadricDrawStyle(q1, Glu.GLU_FILL);
Glu.gluQuadricOrientation(q1, Glu.GLU_INSIDE);
Glu.gluQuadricTexture(q1, Gl.GL_TRUE);
Gl.glTranslatef(0.0f, 0.0f, 0.0f);
Glu.gluCylinder(q1, 0.6, 0.6, 2.5, 25, 25);
Gl.glPopMatrix();
Gl.glFlush(); Thanks for any suggestions
moving with the translation so that the leftmost end of the cylinder is always at the origin. How can I rotate the cylinder with its center at the origin? Is it possible to rotate it within its own local coordinate space (i.e. its center already at local origin)?
The code I'm using is:
Gl.glPushMatrix();
Gl.glLoadIdentity();
//translate center of cylinder to origin
Gl.glTranslatef(-1.25f, 0.0f, 0.0f);
Gl.glRotatef(a, 0.0f, 1.0f, 0.0f);
Glu.gluQuadricNormals(q1, Glu.GLU_SMOOTH);
Glu.gluQuadricDrawStyle(q1, Glu.GLU_FILL);
Glu.gluQuadricOrientation(q1, Glu.GLU_INSIDE);
Glu.gluQuadricTexture(q1, Gl.GL_TRUE);
Gl.glTranslatef(0.0f, 0.0f, 0.0f);
Glu.gluCylinder(q1, 0.6, 0.6, 2.5, 25, 25);
Gl.glPopMatrix();
Gl.glFlush(); Thanks for any suggestions