OpenGL selection code...

Started by
-1 comments, last by iNsAn1tY 21 years, 9 months ago
I'm writing a map maker, and getting pretty close to the point of actually finishing the damn thing. However, one thing eludes me: how do I select the objects I've created using the mouse? Now, I've tried to use the selection buffer (glRenderMode(GL_SELECT), gluPickMatrix, etc.), but have so far had no success. I name my objects (with glLoadName) with their array numbers (which are unique), and then use the method in the OpenGL SuperBible to attempt to pick them. But, the wrong object is often selected where two objects overlap. I know the hit records are there (I tried with two overlapping boxes, and got two records back, as expected), but the z values seem like nonsense, even after I've decoded them by dividing by 232-1. I can't use them to do anything other than tell me which object is closest to the viewport. After my code (based on the SuperBible example) failed, I pretty much copied the code from both NeHe's tutorial and the one from GameTutorials.com, but both of them failed too. I am coding in VB, and I think this might be to blame. I've checked my code over and over again, comparing it to all three C examples I have, and nothing is out of place. I think one of the problems might be that the OpenGL data type GLuint is defined as VB data type Long, and the selection buffer requires an unsigned integer. The prototype is glSelectBuffer(size As GLsizei, Buffer As GLuint) I was thinking (but haven't put much serious thought into it yet) that if the selection buffer method doesn't work very well for overlapping objects, I could use the stencil buffer to simulate the selection buffer. I was wondering, though, how something like gmax handles selection of objects. I've never had any problems selecting objects in gmax, or any other OpenGL-based graphics system, including Valve's Hammer editor or q3radiant, which I'm basing my map maker on. Thanks in advance to anyone who can provide a robust selction system... Movie Quote of the Week:

"I've seen things you people wouldn't believe. Attack ships
on fire off the shoulder of Orion. I watched C-beams glitter
in the dark near the Tannhauser gate. All those moments will
be lost in time, like...tears in rain. Time to die."
- Roy Batty, Blade Runner. Try http://uk.geocities.com/mentalmantle - DarkVertex Coming Soon! [edited by - iNsAn1tY on July 25, 2002 3:51:33 PM]
My opinion is a recombination and regurgitation of the opinions of those around me. I bring nothing new to the table, and as such, can be safely ignored.[ Useful things - Firefox | GLee | Boost | DevIL ]

This topic is closed to new replies.

Advertisement