Advertisement

HOW TO????: Vertex Selection

Started by September 14, 2002 07:07 AM
4 comments, last by DerVisH 22 years, 5 months ago
Hey long Time reader first time poster, Does anyone know how to basically do Vertex Selection. Im using glut to catch mouse calls then use the location to find the Vertex at that location if any... I have tryed Picking Selection and the Feedback buffer but i cant determin how to get out the vertex within the picked matrix. Thanks for any opinions, Peter Beardsley
Do you render points or triangles ?

Do you use gluPickMatrix ?


The generic solution to pick a vertex is :
1) use the selection buffer, and be sure you allocate enough bytes in the selection buffer
2) reduce the rendering viewport to a few pixels around the place you clicked with mouse (thanks to gluPickMatrix)
3) render your vertexes independently (GL_POINTS, not GL_TRIANGLES and not GL_LINES) and bind a different 'name' for each vertex with functions like glPushName and glLoadName
4) finish the rendering by calling glRenderMode(GL_RENDER) and get the returned value to know how many hits you had, so that you can decode the selection buffer


What kind of problems do you encounter ? it picks a wrong vertex (vertex in another place than where you clicked in the screen) ? it picks all vertexes no matter where you click with your mouse ? you have to be very precise to pick a vertex ? you would like to pick the "nearest" vertex but when two vertexes are projected very close (to the screen) you can't determine which is the nearest vertex to pick ?

[edited by - vincoof on September 14, 2002 2:10:06 PM]
Advertisement
You might consider rendering small spheres with the center of your vertex for improving the probability the user hits the ''point'' and the actual sphere. Of course, hitting a sphere with the radius YOU can define will give him a much better chance of selecting it, thus selecting the vertice.

Cheers.

" Do we need us? "


Ionware Productions - Games and Game Tools Development

You might consider rendering small spheres with the center of your vertex for improving the probability the user hits the ''point'' and the actual sphere. Of course, hitting a sphere with the radius YOU can define will give him a much better chance of selecting it, thus selecting the vertice.

Cheers.

" Do we need us? "


Ionware Productions - Games and Game Tools Development

I am using TRIANGLES to draw a height map for terrain,

gluPickMatrix appears to define the loaded name as all the objects between the calls to begin and end. Is this right?

If this is true then i will have to redraw the scene Slightly closer to the view only drawing each point on the height map inderpendantly, as POINTS then test them.

Is this the accepted way?
HellRiZZer: The problem with spheres is that you can not define a generic size that will work as you want. With points, you just have to call glPointSize. Moreover, it's not really the point size that determines the "probability to hit the vertex", it's the size of the small window you get around the point where the mouse clicked.
As a final encouragement to render points instead of spheres, rendering points is MUCH faster than rendering spheres and it's easier to call { glBegin(GL_POINTS); glVertex3f(1.f, 2.f, 3.f); glVertex2f(5.f, 0.f, 3.f); glEnd(); } than calling { glPushMatrix(); glTranslatef(1.f, 2.f, 3.f); glutSphere(...); glPopMatrix(); glPushMatrix(); glTranslatef(5.f, 0.f, 3.f); glutSphere(...); glPopMatrix(); }
sorry !


quote:
gluPickMatrix appears to define the loaded name as all the objects between the calls to begin and end. Is this right?

For what I understand, no it's not right.
Would you please post the lines of code where you use gluPickMatrix (and a few more lines before/after) ?
I think it'd be the best way to check if you're using it correctly.

[edited by - vincoof on September 16, 2002 2:36:05 AM]

This topic is closed to new replies.

Advertisement