[PyOpenGL-Users] Need help about Picking
Brought to you by:
mcfletch
From: Marco A. <mar...@ex...> - 2010-05-24 15:11:10
|
Hi, I followed a lot of tutorials about picking and I decided to use the Selection Buffer. Now, the code that I wrote works as attended but I am in trouble to discover "the nearest object". In fact, I wrote in my code(as I successfully learned at http://pyopengl.sourceforge.net/documentation/opengl_diffs.html) : . hits = glRenderMode(GL_RENDER) for record in hits: min_depth, max_depth, names = record . and I tried to obtain the lower value of "min_depth" (= "the nearest object") but the result is no correct: the reason is that all my returned values of min_depth are identical. Probably it is perhaps caused by a truncated internal representation - I am not sure, I am a novice in python too -, or by a bad pyopengl configuration. For example, at page http://www.dei.isep.ipp.pt/~matos/cg/docs/manual/gluPerspective.3G.html I read: "roughly log2r bits of depth buffer precision are lost. Because r approaches infinity as zNear approaches 0, zNear must never be set to 0." and I used "gluPerspective(45, 1.0*width/height, 0.05, 100.0)" with the value "0.05" near to 0. I tried to change "0.05" in "1.0" but I obtain the bad effect that my model disappear soon when I zoom into ). Can you suggest me the correct way to calculate the lower value of "min_depth"? Or can you suggest me a alternative method to simulate a pick? I'd like to avoid color based method. Thank you for your help. Marco Avellino |