Trying to get a hold of the way pickers work

Lawrence Werner rendawg at plinet.com
Wed Sep 22 05:42:00 EDT 1999


I am trying to get one of the pickers to work in selecting a subset of actors, and the selection that I am getting does not seem to make sense, given the location of the pointer.

Here is what I am trying to accomplish...

I am using VTK to render buildings in three dimensions.  I have set it up so that each main part of a building is its own actor (i.e. - the north wall, each window on the north wall, the roofs, the doors, etc etc).  I want to have it set up so that when the user clicks on the right mouse button a popup menu shows up with all of the parts of the building that it is over (including potentially those on the other side of the building) listed for selection to obtain specific data on that specific part.  For some reason the list that I am getting doesn't make sense so I am a little confused as to why.

I am calling the picker's Pick routine manually and am passing in the mouse points and the renderer (code snippet below)

void CViewGeometry::OnRButtonDown(UINT nFlags, CPoint point) 
{
      CPD2Doc* pDoc = (CPD2Doc*)GetDocument();
      CRect cRect;
      GetWindowRect(&cRect);
      CMenu menu;
      if (menu.CreatePopupMenu())
      {
         // Here we have to do the following
         // #1 -> Perform the Picker action to get the Actors that intersect
         // #2 -> Loop through all of the components and references to get the CVtkComponentData objects
         // #3 -> Populate the Pop-up menu with the Name of each object
         pDoc->m_pPicker->Pick( point.x, point.y, 0.0,Renderer);
         pDoc->m_pPicker->SetTolerance(0.01);
         vtkActorCollection* pActorColl = pDoc->m_pPicker->GetActors();
         int iNumActors = pActorColl->GetNumberOfItems();

         int iNumPicked = pDoc->PopulatePickedComponents( pActorColl );

         for( int i = 0; i < iNumPicked; i++ )
         {
            menu.AppendMenu(MF_STRING, (UINT)pDoc->m_aPickedComponents[i]->GetRefIndex(), 
			     pDoc->m_aPickedComponents[i]->GetName() );
         }

         menu.TrackPopupMenu(TPM_CENTERALIGN | TPM_RIGHTBUTTON,
             point.x+cRect.left, point.y+cRect.top,
             AfxGetMainWnd()); // use main window for cmds
      }
      vtkMFCView::OnRButtonDown(nFlags, point);
}	

Now I have done a debug build of VTK and stepped into it and I think I may have stumbled onto something but am unsure.  Am I correct in assuming that the ray used to determine which points/cells to pick goes from the camera's position to the selection point (which is basically computed by converting the x and y points passed in along with the camera's focal point z-position).  Doesn't this mean, however, that if you use the standard ResetCamera() method in vtkRenderer, you will never get the back half of the building, since the ResetCamera() method tries to center the focal point inside the objects being rendered?  

Even so, this still doesn't explain why when I select some places on the building I don't get any selections at all. Could this also have something to do with having the FocalPoint of the camera inside the building as opposed to outside and behind?  

Any insight to this would be most appreciated.

TIA,
Lawrence "Renny" Werner



-----------------------------------------------------------------------------
This is the private VTK discussion list.  Please keep messages on-topic.
Check the FAQ at: <http://www.automatrix.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at gsao.med.ge.com>.  For help, send message body containing
"info vtkusers" to the same address.     Live long and prosper.
-----------------------------------------------------------------------------





More information about the vtkusers mailing list