Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Get vertex 3D coordinates

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie
    Join Date
    Jul 2013

    Question Get vertex 3D coordinates

    Is there a function which can return a vertex x, y, z coordinates if I use the mouse to select a specific vertex? I found a function which returns the x and y coordinates of the mouse, i.e. void glutMotionFunc(void (*func)(int x, int y)); but the x and y coordinates of the mouse aren't the same as the x and y coordinates of the vertex. More specific, I need to find this function in order to get a certain distance from the initial vertex to the final vertex position after I pull it using the mouse. Sorry if the post doesn't contain enough information, or information written in a basic language, but I am new to OpenGL and I am trying to learn as many things as possible. I have found a way to implement what I need, but using VTK functions, i.e. :

    where MoveActor->GetPosition()[0] is the x coordinate of the moved vertex, MoveActor->GetPosition()[1] is the y coordinate of the moved vertex etc. Position[0], [1], [2] are the initial vertex x,y and z coordinates, and d[0], [1], [2] are the distance's x, y and z coordinates.
    Waiting for some help. Thanks a lot for your time, guys .

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2012

    What you need to do is convert the 2D screen coordinates (Mouse X,Y) to world coordinates.
    Google for opengl camera unproject coordinates. If you are using GLM, you could use glm::unProject() or use gluUnProject.


  3. #3
    Junior Member Newbie
    Join Date
    Jul 2013
    Thanks, I wrote the function using gluUnProject.

Posting Permissions

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