PDA

View Full Version : a selection question



rom
08-08-2001, 12:49 PM
does someone knows if it possible to rotate a camera and select object in real time ? my program allow you selection only if you translate but if you rotate the scene there is no results : no hits are sended to the program by opengl.thanks for your answer

mikael_aronsson
08-08-2001, 01:46 PM
Hi !

Yes that's no problem, I think you make a mistake somewhere in your selection code, possibly when you setup the projection/modelview matrix, make sure you have selected the correct matrix before you set it up and son on.

Mikael

rom
08-10-2001, 12:39 AM
here is my selection routine i don't see the mistake, can someone help me

#define BUFSIZE 512
void pickObjets(int x,int y)
{
GLuint selectBuf[BUFSIZE];
GLint hits;
GLint viewport[4];

glGetIntegerv (GL_VIEWPORT, viewport);

glSelectBuffer (BUFSIZE, selectBuf);
(void) glRenderMode (GL_SELECT);

glInitNames();
glPushName(-1);

glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
gluPickMatrix ((GLdouble) x, (GLdouble) (viewport[3] - y),5.0, 5.0, viewport);
gluPerspective(45.0,(wwidth)/(wheight),1,2000);

/* glTranslatef (-eye[0], -eye[1], -eye[2]-50); //use to move the camera
glRotatef (rot[0], 1.0, 0.0, 0.0);
glRotatef (rot[1], 0.0, 1.0, 0.0);
glRotatef (rot[2], 0.0, 0.0, 1.0);*/
Dessine(GL_SELECT);
glFlush ();

hits = glRenderMode (GL_RENDER);

glMatrixMode (GL_PROJECTION);

glPopMatrix();
glMatrixMode(GL_MODELVIEW);
afficheSel (hits, selectBuf);
}