PDA

View Full Version : selection : hits not recorded



mithun_daa
02-10-2004, 11:35 AM
im having this really wierd problem where my hits are show in the selection buffer at times and at times they dont show. i still havent come across the pattern when this happens, but this is unusual.

shtHits = 0
glGetIntegerv glgViewport, viewport(0)
glSelectBuffer shtBUFSIZE, intSelectbuffer(0)
glRenderMode (GL_SELECT)

glInitNames
glPushName 0 'intializing the name stack

'setting the same geomety as for normal view
glMatrixMode (GL_PROJECTION)
glPushMatrix 'saving the original matrix

glLoadIdentity

gluPickMatrix dblX, viewport(3) - dblY, dblXDist, dblYDist, viewport(0)

'set Camera view, the same for picking as for viewing
gluPerspective msngFieldOfView, msngAspectRatio, mdblNearField, mdblFarField

glMatrixMode (GL_MODELVIEW)

glPushMatrix
my translations and rotations
draw all shapes
...

glPopMatrix
glFlush
shtHits = glRenderMode(GL_RENDER) 'hits = objects in hit

glPopMatrix 'restoring the original matrix

If shtHits > 0 Then

lngNameNum = 0
dblDist = 4294967295#

For intI = 0 To shtHits - 1

'find nearest
If (intSelectbuffer((intI) * 4 + 1) < dblDist) Then
dblDist = intSelectbuffer((intI) * 4 + 1)
lngNameNum = intSelectbuffer((intI) * 4 + 3)
End If

Next intI

End If


instead of renderin the whole scene everytime, i have a screen shot thatz rendered in a 2d othro mode. will that make any difference on selection. i think it wont cause the values in the selection buffer are generated when the same DLs are called when rendering mode is GL_SELECT.

[This message has been edited by mithun_daa (edited 02-10-2004).]

mikael_aronsson
02-10-2004, 10:12 PM
Hi !

As long as you make sure you do render the full scene when you are in selection mode it should not cause any problem.

mithun_daa
02-11-2004, 06:43 AM
Originally posted by mikael_aronsson:
Hi !

As long as you make sure you do render the full scene when you are in selection mode it should not cause any problem.



do i need to render the full scene in selection mode or do i render only the stuff that has names loaded onto the name stack? cause i have some part of the scene like the terrain that i dont want selected and the objects on the terrain are the ones that can be selected. currently im renderin only the objects in the selection mode.


also, i observed that usually, only the first time i select an object after i zoom in or out, there is a hit record and there are some values in the selection buffer. orelse the selection buffer is either filled with 0s or only the first 3 fields are filled and the the 4th field which contains the DL # is 0

it also gives different names for the same object at different times
[This message has been edited by mithun_daa (edited 02-11-2004).]

[This message has been edited by mithun_daa (edited 02-11-2004).]

mikael_aronsson
02-11-2004, 12:27 PM
Hi !

No you should not render stuff that should not be part of the hittest, if you do you can get some wacky hit records.

Mikael