I'a currently writing an application requiring picking (selection). I've
read the red book chapter 13 on this subject and still some questions
remain.
My concern is not about how to make it work (it already does). It's
rather on how to make it more efficient.
A typical program will have a section such as:
{...
glSelectBuffer(BUFSIZE, selectBuf);
(void) glRenderMode(GL_SELECT);
glInitNames();
glPushName((GLuint) 0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix(...);
(lists of projection matrix transform commands)
(scene is redrawn here)
glPopMatrix();
glFlush();
hits = glRenderMode(GL_RENDER);
processHits(hits, selectBuf);
...}
The question is what is the minimum set of 'drawing' commands necessary
to make picking work? The book does not address this issue.
What about calls such as
-those to set current colors, normals or textures?
-glDrawPixels
-glDrawArray
-glLight
-glFog
-glMaterial
-glShadeModel
-GLU and GLUT functions...
And what about other commands affecting the state of the OpenGL server
(what is the minimal necessary state that works with picking)?
-states turned off by glDisable such as
-GL_ALPHA_TEST, GL_BLEND, GL_CULL_FACE, GL_DEPTH_TEST, GL_DITHER, GL_FOG,
GL_LIGHTi, GL_LIGHTING, GL_SCISSOR_TEST, GL_STENCIL_TEST...
-glCullFace
-glDepthFunc
-glFrontFace
Basically, I managed to eliminate all function calls execpt glVertex and
the scene' related MODELVIEW transforms. Similarly, I deacticated
lightling and smooth shading (costly computation-wise) as well as
culling. And picking works. But is this particular of my specific OpenGL
library or is this standard behavior?
Logically, one would assume that to calculate cursor intersection with
drwan objects, a library would only need to rebuild (redraw invisibly)
the 'geometry' of the object, regardless of its color, texture and
surface normals... But does OlpenGL work this way?
Thanks.
Please answer by Email.
I have considered using a PB extension and if()ing all of the shading,
normal and other illumination calls;
drawing only flat picking id's.
"Christian Langis" <christia...@nrc.ca> wrote in message
news:3D80F87A...@nrc.ca...
I have not measured the speed difference, but I usually disable almost
everything when drawing picking geometry. All you need is the vertices and
polygon definition, so no texture on normal stuff is needed.
Also, depending in the application you should do initial tests using
ray-sphere or ray-box intersection (or anything else coarse culling
technique applicaple to you). This will speed up the test very much
when you have scenes with many polygons.
--memon
cos(pi),sin(pi) lddoW 6Jo'3p15u1@uow3w
uow3W uow3w~/6Jo'3p15u1'mmm
to make it more effient, use the standard technique or using spatial
devision (right term?) anyway where u devide your scene up with a
octree, X-tree, bsp etc or even simpler (but maybe slower with
complicated scenes) just stick a bounding sphere around each object.
then run either a ray or a box (for selecting a retangluar region)
through that finding out what nodes the ray/box intersects + perform the
selection tests on that, ie youve narrowed down the number of tests to
do, this will increase speed dramatically 10x quicker should be no trouble
Just because you asked, the term is spatial subdivision
-- Nuclear / the Lab --