PDA

View Full Version : picking again.....



03-15-2002, 01:43 AM
here is my code for a picking method with the mouse. when i have an object picked i try to move it but all the objects move. i know this is to do with the pushMatrix and pop matrix but i thought i had that done. am i calling them in the wrong place or what am i doing wrong. thanks.

GLuint selectBuff[BUFSIZE];
GLint hits, viewport[4];
glSelectBuffer(BUFSIZE, selectBuff);
glGetIntegerv(GL_VIEWPORT, viewport);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glRenderMode(GL_SELECT);
glLoadIdentity();
gluPickMatrix(x, viewport[3]-0.1,0.1, viewport);

glOrtho(0, 0, 0, 0, 0, 0);
glMatrixMode(GL_MODELVIEW);

displayfn();

hits=glRenderMode(GL_RENDER);

printf ("hits = %d\n", hits); glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

if(hits > 0)
picked = selectBuff[3];

then i have something like

if(picked){
glTranslatef(0.5,0.5,0.5);
}

Furrage
03-15-2002, 05:34 AM
As pointed out in your last post you need to save before trying to translate a single object and restore it afterwards.

i.e
if(picked){
glPushMatrix();
glTranslatef(0.5,0.5,0.5);
glPopMatrix();
}

[This message has been edited by Furrage (edited 03-15-2002).]