View Full Version : getting vertex data

07-14-2004, 05:49 AM
as i didnt get the help i needed in the beginners forum i try here again :)
and just for that start i CANT use glut functions so i cant use something like GLUunproject() to solve my problem..

ok here we go hehe:


hi guys i need your help

i got a simple problem...
i got a 3d model displayed...
now want i want is, clicking on the model with the mouse and getting the coordinates of the nearest vertex to the mouse pointer.

in other words i need a selection-vertex function which is included in every 3d modelling pogramm.

i know i have to caculate from 2d mouse coords to 3d model coords.. but i dont know how?!?!

have you got any tutorials on this ??
or can you write me the basics?

p.s. i cannot use any glut functions only opengl!
glut is not allowed in my c++ code (dont ask why :) )

Kilam Malik
07-14-2004, 08:26 AM
So you have to do the same as the gluunproject function does. It is simple matrix multiplication. Just have a look at the input parameters of the gluunproject. It's two matrices and the viewport. Shouldn't be to hard to figure out the reverse matrix.
An easier way would be to download the MESA source code, which is a software implementation of OpenGL. You'll sure find the gluunproject source code there.


07-14-2004, 09:18 AM
Maybe you can project all vertices in software and find closest one to mouse?


07-14-2004, 09:25 AM
Yeah, yeah, yeah - do that, do it, go on. Genius.

07-14-2004, 05:06 PM
Im pretty sure he will try to do quad or area selection?

OK.. there is a another solution... make a "ray" viewer -> mouse and for each vertex calc distance from "ray". Keep closest vertex...


Kilam Malik
07-15-2004, 03:05 AM
Ehm... another thing -> GLUT != GLU. You can of course use gluunproject without using GLUT.


07-15-2004, 05:39 AM
That's what i was going to say. gluUnproject is in GLU, not in GLUT, so why couldn't you use it ?


07-16-2004, 07:12 AM
sorry my fault glu isnt glut i know now :)

thx for your help guys i try to use gluunproject or at least look at its code

07-19-2004, 03:25 AM
Maybe you should wonder what links will give google if you type "mouse selection opengl".

I guess you will find what you need ... if not, have a closer look . And if still not, go on opengl.org (second result in google) for such basic topics.