- I have a scene with a lot of polygons.
- I am sucessfully getting a selectionbuffer.
- The selection buffer is working correctly if I select all the polygons that are “hit”.
- The problem is to pick/select only the nearest polygon.
I am playing with the z1 and z2 values that are in the selectionbuffer but the problem is that sometimes the nearest polygon has the greatest max(z1,z2) and sometimes it is the opposite being the nearest polygon the one with min(z1,z2).
What am i missing here?
I think the problem is in the picking part and not in the processing hits part as i mentioned before.
Const BUFSIZE As Integer = 512
Dim selectBuf(BUFSIZE) As Integer
Dim hits As Integer
Dim viewport(3) As Integer
Dim Projection(16) As Double
' create 5x5 pixel picking region near cursor location
gluPickMatrix(e.X, viewport(3) - e.Y, 5 , 5, viewport)
'render the scene in gl_select mode:
hits = glRenderMode(GL_RENDER)
glPopMatrix() ' /* Restore projection matrix */
Any idea of what is wrong??