Results 1 to 3 of 3

Thread: gluUnProject / gluPerspective / glTanslatef problem

  1. #1
    Member Contributor
    Join Date
    Apr 2002
    Posts
    52

    gluUnProject / gluPerspective / glTanslatef problem

    Hi,

    I used gluUnprojet to pick up the object coordinates where the user clicked in my window..

    I do not arrive to obtain the good values.

    - I calculate at the beginning of the program a Z value that will place the camera in order to see all the object Z=-431 for the object I'm actually using. After the user can change the Z value in order to give a zoom impression on the object. I use glTranslate for moving the camera..

    - I set up the the gluperspective like this:
    glu.gluPerspective(Angle_View_Degree, width/height, 10.0f, 500.0f);
    in order to zoom on the object. If I give a Z value between -10 and -500 I can see the object.

    - The gluUnproject is initialised like this:
    glu.gluUnProject((double)X,(double)Y,depthbuffer[0],mvmatrix,projmatrix,viewport,x,y,z)
    I don't think the problem comes from here..

    Now with this configuration I can't get the corrects object points and Z=421...

    I think there is something I don't understand in the configuration of gluPerspective combined with changing the Z value with glTranslate..

    Anyone has an idea
    Thanks for your help
    Mat

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jan 2002
    Location
    Kingston, Jamaica, W.I.
    Posts
    282

    Re: gluUnProject / gluPerspective / glTanslatef problem

    The z in gluUnproject should be between 0 and 1 and is scaled by OpenGL such that 0 maps to zNear (10 in your case) and 1 maps to zFar (500 in your case). So the z you would want to use is something like (421 - 10) / (500 - 10).

    [This message has been edited by Furrage (edited 05-07-2002).]

  3. #3
    Member Contributor
    Join Date
    Apr 2002
    Posts
    52

    Re: gluUnProject / gluPerspective / glTanslatef problem

    Originally posted by Furrage:
    The z in gluUnproject should be between 0 and 1 and is scaled by OpenGL such that 0 maps to zNear (10 in your case) and 1 maps to zFar (500 in your case). So the z you would want to use is something like (500 - 421) / (500 - 10).
    Hi I just noticed that and I tried to put my zFar at -250 and put the value of z at 0.5 but it did not work !! But it worked correctly if I use zFar -500 and z at 1 or zFar -10 and z at 0 !!

    It must be proportionaly normaly !!

    Thanks for your help
    Mat

Similar Threads

  1. gluPerspective glTranslation problem
    By donmitz in forum OpenGL: macOS
    Replies: 4
    Last Post: 12-21-2012, 04:47 PM
  2. depth problem caused by changing gluperspective
    By brennt in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 08-23-2009, 12:21 PM
  3. gluPerspective problem
    By Ehsan Nekooee in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 08-14-2009, 02:02 PM
  4. gluPerspective problem, with real numbers to work with
    By halo in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-22-2006, 04:38 PM
  5. Problem with gluPerspective view?
    By HanWu in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 06-18-2005, 10:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean