Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

QUESTION: cursor picking with OpenGL

6 views
Skip to first unread message

Christian Langis

unread,
Sep 12, 2002, 4:26:34 PM9/12/02
to
Howdy.

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.

Dr d b karron

unread,
Sep 13, 2002, 1:25:39 AM9/13/02
to
good questions.
I am interested in the answer too.

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...

Mikko 'memon' Mononen

unread,
Sep 13, 2002, 9:59:15 AM9/13/02
to
On Fri, 13 Sep 2002 05:25:39 GMT, Dr d b karron <ca...@thorn.net> wrote:
>good questions.
>I am interested in the answer too.
>
>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.

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

zed

unread,
Sep 13, 2002, 3:38:06 PM9/13/02
to
Dr d b karron wrote:
> good questions.
> I am interested in the answer too.
>
> 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...
>
>>Howdy.
>>
>>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.

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

John Tsiombikas

unread,
Sep 14, 2002, 9:19:25 AM9/14/02
to
> to make it more effient, use the standard technique or using spatial
> devision (right term?)

Just because you asked, the term is spatial subdivision

-- Nuclear / the Lab --


0 new messages