Sign in to follow this  
guvidu

Object selection and Multiple Viewports

Recommended Posts

Hy there. Im doing an application with 6 orho2d vieports and 1 perspective vieport i want to do my selection in the perspective vieport before i put the multiple vieports everything went ok - my object were selected. application working fine. Now it doesnt select my object. What can i do to select my object in the perspective vieport? Here is my Object Selection function: int RetrieveObjectID(int x, int y) { int objectsFound = 0; int viewportCoords[4] = {0}; unsigned int selectBuffer[32] = {0}; glSelectBuffer(32, selectBuffer); glGetIntegerv(GL_VIEWPORT, viewportCoords); glMatrixMode(GL_PROJECTION); glPushMatrix(); glRenderMode(GL_SELECT); glLoadIdentity(); gluPickMatrix(x, viewportCoords[3] - y, 2, 2, viewportCoords); gluPerspective(45.0f,(float)g_rRect.right/(float)g_rRect.bottom,0.1f,150.0f); glMatrixMode(GL_MODELVIEW); DrawGLScene(); objectsFound = glRenderMode(GL_RENDER); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); if (objectsFound > 0) { unsigned int lowestDepth = selectBuffer[1]; int selectedObject = selectBuffer[3]; for(int i = 1; i < objectsFound; i++) { if(selectBuffer[(i * 4) + 1] < lowestDepth) { lowestDepth = selectBuffer[(i * 4) + 1]; selectedObject = selectBuffer[(i * 4) + 3]; } } return selectedObject; } return 0; } Thanks!

Share this post


Link to post
Share on other sites
What coordinate system are the mouse coordinates in? If they're not expressed in relation to the viewport in which you wish to select your objects, the pick matrix may not be being constructed correctly.

Share this post


Link to post
Share on other sites
Hmmm - you got me there.
I dont know
I have the function that i call my objectID
and

int WndProc i have

int objectID = 0;

case WM_LBUTTONDOWN:
{
objectID = RetrieveObjectID(LOWORD(lParam), HIWORD(lParam));

switch(objectID)
{
case RotateID_O:
{
if(!RotationInCourse)
{
Rotate_O = true; RotationInCourse = true; m_angle = 0;
}
}break;
...............................................
...............................................

Thats it.



Have i answer to your question?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this