PDA

View Full Version : Seleciting - Picking vertices - shoot-through



Uther_Pendragon
07-31-2001, 12:41 AM
Hi,

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 ?

Uther

Uther_Pendragon
07-31-2001, 05:51 AM
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 ;-)

Uther

bgs
07-31-2001, 12:49 PM
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

zed
07-31-2001, 04:59 PM
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.

Uther_Pendragon
07-31-2001, 10:22 PM
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)
{
glPushAttrib(GL_DEPTH_BUFFER_BIT);
glClear( GL_DEPTH_BUFFER_BIT );

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 );
}
glEnd();

glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);

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

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


glEnd();
glPopName();
}

glPopAttrib();
}
////////////////////////////////////////

Uther_Pendragon
08-03-2001, 03:52 AM
Problem still not solved :-(

Any ideas ?

zed
08-03-2001, 05:45 PM
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.

Uther_Pendragon
08-05-2001, 09:27 PM
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 http://www.opengl.org/discussion_boards/ubb/wink.gif

KurtCob
08-09-2001, 02:39 AM
Hmmm

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 ?

Tnks
Best regards
Kurt