
Picking Facets in Feedback Mode
I''m trying to pick only parts of an object drawn on screen. What I do is that first I do a straightforward picking usig GL_SELECT mode and then render the picked object in GL_FEEDBACK mode. The problem is that the coordinates returned in the feedback buffer are in window coordinates and I need to know their position on the actual picked object. I tried using gluUnproject but it seems that either it doesn''t work, or I got my matrices all mixed up. Just for info, the series of transformations to get to the current object is below, in pseudo-code:
//Setup projection
glMatrixMode( GL_PROJECTION );
glLoadIdentity();
if in selection or feedback mode : gluPickMatrix(...);
gluPerspective(...);
//Setup global world transformations
glMatrixMode( GL_MODELVIEW );
glLoadIdentity();
glTranslatef( xshift, yshift, zshift-4.0);
glRotatef( vAng, 1.0, 0.0, 0.0 );
glRotatef( hAng, 0.0, 1.0, 0.0 );
//Draw each individual object
for each object:
glPushMatrix();
glTranslatef( Ox, Oy, Oz );
glRotatef( rotX, 1.0, 0.0, 0.0 );
glRotatef( rotY, 0.0, 1.0, 0.0 );
glRotatef( rotZ, 0.0, 0.0, 1.0 );
glScalef( scaleX, scaleY, scaleZ );
drawObject();
glPopMatrix();
What I do is after getting the feedback array, I re-apply all the previous transformations (projection and modelview from scratch) and then gluUnproject() the coordinates in the buffer. This gives me really weird coordinates. I also tried to glReadPixels with the GL_DEPTH_COMPONENT that gives a different z value before using gluUnProject, but that''s even worse! Is there something I''m doing wrong? Is there an easier way to manually calculate the coordinates (I''m somehow not really good at matrix transformations)? Or is there simply an easier way to pick specific facets of an object without having to pick them individually in GL_SELECT mode? I don''t have access to the object''s drawing methods so I can''t pushName() the individual elements and GL_SELECT them

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement