vivekd
10-23-2005, 02:26 AM
Below is my code for drawing 2 cones. But when I rotate it, the 2nd cone always overlaps the 1st cone. Actually when rotated beyond 180 degrees, the 1st cone should overlap the 2nd one. Any suggestions or clues for avoiding this problem?
//1st Cone
GL.glLoadIdentity();
GL.glPushMatrix();
GL.glTranslatef(0.0f, -1.0f, -5.0f);
GL.glRotatef(xrot, 1.0f, 0.0f, 0.0f);
GL.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
GL.glColor3f(1.0f,0.0f,0.0f);
GL.gluCylinder(this.cone, 0.5f, 0.0f, 3.0f, 32,1);
//2nd Cone
GL.glTranslatef(1.5f, 0.0f, 0.0f);
GL.glColor3f(0.0f,1.0f,0.0f);
GL.gluCylinder(this.cone, 0.5f, 0.0f, 2.0f, 32,1);
GL.glPopMatrix();
GL.glFlush();
//1st Cone
GL.glLoadIdentity();
GL.glPushMatrix();
GL.glTranslatef(0.0f, -1.0f, -5.0f);
GL.glRotatef(xrot, 1.0f, 0.0f, 0.0f);
GL.glRotatef(yrot, 0.0f, 1.0f, 0.0f);
GL.glColor3f(1.0f,0.0f,0.0f);
GL.gluCylinder(this.cone, 0.5f, 0.0f, 3.0f, 32,1);
//2nd Cone
GL.glTranslatef(1.5f, 0.0f, 0.0f);
GL.glColor3f(0.0f,1.0f,0.0f);
GL.gluCylinder(this.cone, 0.5f, 0.0f, 2.0f, 32,1);
GL.glPopMatrix();
GL.glFlush();