Seleciting - Picking vertices - shoot-through


I’m writing a modeling package and I implemented a mechanism to select vertices or a group of vertices.

Everything works fine, but the annoying thing is that the selection always seems to ‘shoot-through’ my meshes.

Is there a way I can select only ‘visible’ vertices ?


Made temp solution by getting the bounding box and calculating the average depth.

It’s not the perfect solution, but it allows me to continue though.

Still hoping that someone can provide me with a better solution :wink:


Hi there,
I you mean it’s picking verticies from the other side of the mesh, use the normals of the verticies to see if the vertex is pointing towards or away from the screen. This is assuming you have normals for your verticies…

  • Brian

a posible method is once u have the vertices. draw them again with say glDepthFunc( GL_EQUAL) if they get drawn ie they pass the depth test , then they can be seen else there is geometry obscutring them so they fail the depth test.

I tested the trick with the depth buffer (see code below), but it doesn’s seem to work.

Am I doing something wrong here ?
…or does the depth test has no effect on the name stack ?

void draw3d_select(void)

int i = 0;
glBegin( GL_POINTS );
for (i=0; i < ss->nrPoints; ++i )
glVertex3f( (float) data[ i ]->x,
(float) data[ i ]->y,
(float) data[ i ]->z );


for (i=0; i < ss->nrPoints; ++i )
glBegin( GL_POINTS );

  glVertex3f( (float) data[ i ]-&gt;x,
	  (float) data[ i ]-&gt;y,
	  (float) data[ i ]-&gt;z  );


Problem still not solved :frowning:

Any ideas ?

well for all the selected vertices.
run a line segment from each vertice to the camera + check if this linesegment intersects any polygons in the scene if so then the vertice cant be seen from the camera.

Thanx… I’ll solve it this way…

Still I think there should be some kind of link between the depth buffer and the pushing of names.
Maybe something for the next OpenGl version


Hello guys …

I was searching about selection, and I found this, will it not be possible to control witch is the correct vertex working with the Z value from the hit ?

Just an idea, if not, can some one correct me , why we can’t use this ?

Best regards