gluLookAt problems seeing two objects

I am drawing two objects: a cone and a torus beneath the base of the cone. If I orient the camera with gluLookAt, so that it points to the base of the cone, I do not see the torus.

If I look at the shapes from the side, using gluLookAt like this:
gluLookAt (5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

I see that the point of the cone is oriented along the positive z axis, and I see the torus offset to the right.

If I move the camera to the negative z-axis, looking back toward the origin, I only see the cone.

gluLookAt (0.0, 0.0, -5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

I am very much beginning here, and am likely making some fundamental mistake. I am trying to extend examples I have found online for positioning the camera, but seem to be missing something here. My code is attached.

Any suggestions on what I am doing wrong?

Thanks!

Try to change the code to be like this:


glPushMatrix();
		glColor3f(0.0,0.0,1.0);
		glTranslatef(0.0, 2.0, 0.0);
		glutSolidTorus(0.15, 0.25,10,10);
	glPopMatrix();

	glPushMatrix();
		glTranslatef(0.0,0.0,1.0);
		glColor3f(1.0, 0.5, 0.0);
		glutSolidCone(0.5,2.0,20,20);
	glPopMatrix();


This did not change the display. Thanks.

glTranslatef(0.0,0.0,1.0)

places the object behind the other in the xz-plane along the + z-axis

Be default “up” is in + y-axis

use

glTranslatef(0.0,-1.0,0.0)

to put the object below

The other issue that I have, possibly related, is that “zooming out” does not seem to impact size.

The cone + torus look the same size whether the camera is at 1,1,1 or 10,10,10.

Any suggestions?

Thanks,

[QUOTE=maxxjr;1257839]I am drawing two objects: a cone and a torus beneath the base of the cone. If I orient the camera with gluLookAt, so that it points to the base of the cone, I do not see the torus.

If I look at the shapes from the side, using gluLookAt like this:
gluLookAt (5.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

I see that the point of the cone is oriented along the positive z axis, and I see the torus offset to the right.

If I move the camera to the negative z-axis, looking back toward the origin, I only see the cone.

gluLookAt (0.0, 0.0, -5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

I am very much beginning here, and am likely making some fundamental mistake. I am trying to extend examples I have found online for positioning the camera, but seem to be missing something here. My code is attached.

Any suggestions on what I am doing wrong?

Thanks![/QUOTE]

Have you setup your perspective view?

Perspective view took care of the second issue…the objects now scale as I “zoom” in and out with the camera (by changing the eye coordinates in gluLookAt).

I still have the issue where if I move the camera position so that the torus should be in front of the cone, I only see the cone. I added GLUT_DEPTH to glutInitDisplayMode, and GL_DEPTH_BUFFER_BIT to glClear, but behavior is still the same.

Found the answer here: