PDA

View Full Version : picking + pusmatrix



JeeTriX
05-20-2002, 11:01 PM
I want to perform picking on some objects that have their own local co÷rdinate system.
To draw those local objects, i push & pop a transformation-matrix and draw the objects as if they were in the origin.

My problem:
if i use the same transformations in glRenderMode(GL_SELECT); to build a selection buffer the selection does not work. Is this because those transformations are not supported in GL_SELECT? Does anyone know this problem and what can i do about it?

p.s.: The selection works ok with absolute coordinates, so without using the local coordinatesystem.

tnx in advance http://www.opengl.org/discussion_boards/ubb/smile.gif

[This message has been edited by JeeTriX (edited 05-21-2002).]

V-man
05-21-2002, 12:49 PM
They should work. You can debug by rendering the area you cliked on. Are you using gluPickMatrix? If so, then maybe the problem lies there.

It went something like

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPickMatrix(...); <-- what's in here?
glFrustum or glOrtho
......


V-man

JeeTriX
05-21-2002, 10:44 PM
I know they should work because if they don't, they would be pointless. But i had already a decent amount of problems with selection due to the lack of openGL support on the matrox i've been testing on, so i would not be astonished if this was a known problem...

Anyway, i'll paste some of the code to make sure all my calls are right:

glGetIntegerv(GL_VIEWPORT, viewport);
glSelectBuffer(256,selectBuf);
glRenderMode(GL_SELECT);
glInitNames();
glPushName(0);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
gluPickMatrix(x,(viewport[3]-y),15.0,10.0,viewport);
gluPerspective(45.0,ww/wh,1.0,250.0);
..
..
glPushMatrix();
glLoadName(cadTmp->GetID());
glTranslatef(ori.GetX(),ori.GetY(),ori.GetZ());
glRotatef(cadTmp->GetCoordinateSystem()->GetRotationZ(),0.0,0.0,1.0);
glRotatef(cadTmp->GetCoordinateSystem()->GetRotationX(),1.0,0.0,0.0);
glRotatef(cadTmp->GetCoordinateSystem()->GetRotationY(),0.0,1.0,0.0);
...
..(here i draw)..
..
glPopMatrix();
...
glPopMatrix();
glFlush();
GLint hits = glRenderMode(GL_RENDER);

...
http://www.opengl.org/discussion_boards/ubb/smile.gif

How can i render the area i clicked on?

[This message has been edited by JeeTriX (edited 05-22-2002).]

V-man
05-22-2002, 03:00 PM
If you want to render, just remove the glRenderMode commands you got there, and repaint the scene when you click.

But I dont see a problem with the code. You can try the red book examples to see if they work.

V-man

JeeTriX
05-22-2002, 11:58 PM
Whatever it may be that keeps me away from selcting my objects, i'm gonna ignore it & do raytracing http://www.opengl.org/discussion_boards/ubb/smile.gif i'm on it for 2 days now, i can't even see what i draw in that selection buffer... i'll assume the mode is not supported perfectly on my card...

V-man
05-23-2002, 04:49 PM
What is your card + driver exactly?

V-man