Results 1 to 3 of 3

Thread: Evaluate mouse point in 3D scene ?

  1. #1
    Junior Member Newbie
    Join Date
    May 2001
    Location
    VietNam
    Posts
    9

    Evaluate mouse point in 3D scene ?

    Dear,
    Please tell me how to caculate a current mouse point (mouse_x, mouse_y, mouse_z) in 3D scene.
    Thanks.

  2. #2
    Junior Member Newbie
    Join Date
    May 2001
    Posts
    3

    Re: Evaluate mouse point in 3D scene ?

    I don't know if tis little code example answers your question... At the end, you have the obyect coordinates under your mous-cursor in ox, oy, oz...

    GLint realy=viewport[3]-(GLint)y-1;

    //Get the z value under the mousecursor
    glReadPixels(x, realy, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depth);

    gluUnProject((GLdouble) x, (GLdouble) realy, depth, mvmatrix, projmatrix, viewport, &ox, &oy, &oz);

    Cheers

  3. #3
    Member Contributor bsperlin's Avatar
    Join Date
    Feb 2001
    Location
    VA
    Posts
    67

    Re: Evaluate mouse point in 3D scene ?

    This leads into some work I'm doing in stereo where I have made a 3d cursor that travels around the viewing space. Using picking I can get the closest poly in a straight line between the viewer and the cursor, but have had a hard time getting the farther, hidden polys in the same line. The depth reported by picking is hard for me to convert to the same measure as the cursor depth. The picking depths are numbers between 1 and 2. I would like to pick a hidden poly with the cursor when they are both out of sight. Has anybody done this?
    Barry

Similar Threads

  1. Using the mouse in OpenGL scene
    By williajl40 in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-16-2016, 03:07 PM
  2. Mouse in 3D scene
    By RBator in forum OpenGL: Windows
    Replies: 8
    Last Post: 07-22-2011, 09:35 AM
  3. Convert mouse point to box2d point in opengl
    By Apoptyzm in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-16-2009, 01:25 PM
  4. rotation of the scene with the mouse ??
    By Qbic in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 11-29-2003, 08:46 AM
  5. Evaluate mouse point in 3D scene ?
    By tranckhanh in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 05-25-2001, 05:25 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