PDA

View Full Version : Objects disappear when rotating



metalac
08-22-2008, 01:45 PM
Hey guys,

I'm having an issue where the 3 lines that I draw disapear as I rotate the scene. It's a pretty simple model of 3 lines(think x-y-z axis), but sometimes I have all 3 show up and sometimes only 1, 2 or none show up. It all depends how I rotated it. The code bellow shows the code:



glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45.0, 1.0, 0.0001, 100000.0);

glMatrixMode(GL.GL_MODELVIEW);
glLoadIdentity();
glTranslatef(x, y, z);
glRotatef(rotx, 1.0f, 0.0f, 0.0f);
glRotatef(rotz, 0.0f, 0.0f, 1.0f);

glLineWidth(5.0f);
glColor3f(1,0,0);
glBegin(GL.GL_LINES);
glVertex3f(x1, y1, z1);
glVertex3f(x2, y1, z1);
glVertex3f(x1, y1, z1);
glVertex3f(x1, y2, z1);
glVertex3f(x1, y1, z1);
glVertex3f(x1, y1, z2);
gl.glEnd();


Can anyone see anything wrong with this?

dletozeun
08-22-2008, 03:07 PM
what are the x, y, and z values in the glTranslatef call? If they are all 0 this could explain why sometimes you don't see any line.

I don't know how long are your lines, but try something like:

glTranslatef(0.0, 0.0, -10.0)

Where 10.0 is just an arbitrary value, but should be negative to move your lines in front of the viewpoint.

metalac
08-22-2008, 03:57 PM
Numbers are already like that. It's a pretty large model, so z is more like -1000.0. I can't really narrow down as to where the problem is, since it's completely random. I could see if it was clipping the lines at near and far plane, but what happens is that if i'm looking straight ahead on a vertical line and then rotate left or right ever so slightly, it might not draw after the rotation.