Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

DerVisH

HOW TO????: Vertex Selection

This topic is 5758 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!