Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: gluLookAt problems seeing two objects

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    6

    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!
    Attached Files Attached Files

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2013
    Posts
    10
    Try to change the code to be like this:

    Code :
    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();

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    6
    This did not change the display. Thanks.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    Code :
    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
    Code :
    glTranslatef(0.0,-1.0,0.0)
    to put the object below

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    6
    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 Originally Posted by maxxjr View Post
    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!

  6. #6
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    Have you setup your perspective view?

  7. #7
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    6
    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.

    Quote Originally Posted by tonyo_au View Post
    Have you setup your perspective view?

  8. #8
    Junior Member Newbie
    Join Date
    Jul 2009
    Posts
    6

    Answer found


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •