Jump to content
  • Advertisement
Sign in to follow this  
guvidu

Object selection and Multiple Viewports

This topic is 4328 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!