Results 1 to 8 of 8

Thread: gluUnProject

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Derry, NH
    Posts
    126

    gluUnProject

    It looks like gluUnProject does not offer the right OpenGL 3D coordinates if the drawing objects are rotated. gluUnProject does not have rotation matrix as a parameter. Please let me know if I am wrong. Is their anyway to get the 3D coordinates in a rotated scenery? Do we have to use glMultMatrix to multiply the coordinates we get from gluUnProject with the inverse matrix of rotation?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Feb 2002
    Posts
    374

    Re: gluUnProject

    Originally posted by Rong Yao:
    It looks like gluUnProject does not offer the right OpenGL 3D coordinates if the drawing objects are rotated. gluUnProject does not have rotation matrix as a parameter. Please let me know if I am wrong. Is their anyway to get the 3D coordinates in a rotated scenery? Do we have to use glMultMatrix to multiply the coordinates we get from gluUnProject with the inverse matrix of rotation?
    gluUnProject maps screen coordinates (2D) to object coordinates (3D). And since it gets the modelview matrix as an input parameter it handles the rotations correctly. But it does not give you rotated coordinates of your objects as it is not designed to do such thing.
    There is a way to get the rotated 3D coordinates but it does not involve glMultMatrix or gluUnProject. A search on this forum should give you the answer. And perhaps you want to ask google about the red book.
    Hope I got your question right, perhaps you tell us what you want to do and we can help more.




    [This message has been edited by satan (edited 07-23-2003).]

  3. #3
    Member Contributor
    Join Date
    Jan 2001
    Location
    Irving TX USA
    Posts
    58

    Re: gluUnProject

    If you have MFC I have a demo on my site that might help you. I'm trying to allow the user to drag objects around the screen and click-drag to draw. gluProject and gluUnProject do about 90% of what I need so I'm going to have to do some more math, but if you're curious as to the effects of rotation on the returned values it should help you.

    daltxcoltsfan.tripod.com/OpenGL/OpenGL.htm

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Derry, NH
    Posts
    126

    Re: gluUnProject

    Thank you all.

  5. #5
    Senior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Derry, NH
    Posts
    126

    Re: gluUnProject

    I downloaded your files. However, I cannot compile it. Below is the error message:
    fatal error RC1015: cannot open include file 'res\ProjectAndUnprojectDemo.rc2'
    Could you please help me to solve the problem? Thanks a lot!


    Originally posted by DalTXColtsFan:
    If you have MFC I have a demo on my site that might help you. I'm trying to allow the user to drag objects around the screen and click-drag to draw. gluProject and gluUnProject do about 90% of what I need so I'm going to have to do some more math, but if you're curious as to the effects of rotation on the returned values it should help you.

    daltxcoltsfan.tripod.com/OpenGL/OpenGL.htm

  6. #6
    Member Contributor
    Join Date
    Jul 2002
    Location
    Seri Kembangan, Selangor, Malaysia
    Posts
    92

    Re: gluUnProject


  7. #7
    Senior Member Regular Contributor
    Join Date
    Jan 2001
    Location
    Derry, NH
    Posts
    126

    Re: gluUnProject

    Is there any easy way to detect if my mouse is on any object in the drawing or not?

  8. #8
    Member Contributor
    Join Date
    Jul 2002
    Location
    Seri Kembangan, Selangor, Malaysia
    Posts
    92

    Re: gluUnProject

    Hi,


    A long line will be created at z axis when the mouse was clicked on the screen. The intersection point of the line and objects will be calculated. Coordinates (x,y,z) of the object that you have clicked are equal to the intersection point.

    please refer to red book in page 152.. how to get the near clipping z value and far clipping z value.

    Hope it can help.

Similar Threads

  1. gluUnProject
    By Raiden in forum OpenGL: Linux
    Replies: 1
    Last Post: 04-11-2005, 09:33 AM
  2. gluUnProject
    By Amir in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 12-10-2004, 01:53 PM
  3. Example of gluUnProject
    By jirkamelich in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-11-2002, 08:53 AM
  4. gluUnProject
    By mphanke in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-24-2002, 08:28 AM
  5. Once again, gluUnProject...
    By Tanus in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 09-08-2001, 05:35 PM

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