Original Post
🔒 Locked
Ray Picking
Advertisement
Well, I don't have a link, but here's basically what you do.
Now intersect the ray defined by fX,fY,fZ -> tX,tY,tZ with your objects and if there is an intersection, select.
[edited by - ataru on March 19, 2003 4:59:34 PM]
GLint viewport[4];
GLdouble mvmatrix[16], projmatrix[16];
glGetIntegerv(GL_VIEWPORT, viewport);
glGetDoublev(GL_MODELVIEW_MATRIX, mvmatrix);
glGetDoublev(GL_PROJECTION_MATRIX, projmatrix);
GLint realy;
double fX,fY,fZ;
double tX,tY,tZ;
realy = viewport[3] - (SCREENY - (GLint)RmouseY) - 1;
gluUnProject((GLdouble)RmouseX, (GLdouble)realy, 0.0, mvmatrix, projmatrix, viewport,
&fX, &fY, &fZ);
gluUnProject((GLdouble)RmouseX, (GLdouble)realy, 1.0, mvmatrix, projmatrix, viewport,
&tX[0], &tY[1], &tZ[2]);
Now intersect the ray defined by fX,fY,fZ -> tX,tY,tZ with your objects and if there is an intersection, select.
[edited by - ataru on March 19, 2003 4:59:34 PM]
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement