<DIV>When you rotate your scene, it is the camera that rotates not the actor itself. So if the picker project a ray from the camera, it is not neccessary from the origin (0,0,0) cause your camera position has changed. The ray should be from the current possition of the camera to the object.</DIV>
<DIV> </DIV>
<DIV>This is my understanding of the picker. I am not sure if it is true though. </DIV>
<DIV> </DIV>
<DIV>BTW: if you use vtkcellpointer, do you eliminate the problem of getting the point from the back surface?</DIV>
<DIV> </DIV>
<DIV>Thank you!</DIV>
<DIV> </DIV>
<DIV> Luke</DIV>
<DIV> </DIV>
<DIV> <BR><BR><B><I>安 继业 <an_jiye@hotmail.com></I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid"><BR>Hi.<BR><BR>I have understood why the picking results are not as expected. Here are the <BR>explanations.<BR><BR>There is a section in the vtk textbook introducing the picking functions of <BR>vtk. Unfortunately, I only have the 2nd edition for vtk 2.0. But I think <BR>the principle should be the same. Here I quote some contents from it.<BR><BR>"The Visualization Toolkit provides four classes to perform actor, point, <BR>cell and world point picking. These are the classes vtkPicker, <BR>vtkPointPicker, vtkCellPicker and vtkWorldPointPicker. These pickers vary <BR>in speed and functionality as described in the following."<BR><BR>"The object vtkPicker intersects a ray defined from camera position to a <BR>screen (i.e., pixel coordinate) against the bounding box of all pickable <BR>and nontransparent actors. (An actor is pickable if its Pickable instance <BR>variable is true.) The
result of the vtkPicker pick operation is to return <BR>a list of the actors whose bounding box is intersected. The actor closest <BR>to the camera position is also returned."<BR><BR>"The object vtkPointPicker intersects the ray against the points defining <BR>each actor, and returns the point coordinate closest to the camera <BR>position, as well as the actor that the point belongs to. Since screen <BR>resolution prevents precise selection of a point, a tolerance around the <BR>ray must be specified. The tolerance is expressed as a fraction of the <BR>rendering window size. (Rendering window size is measured across the window <BR>diagonal) Points must lie within this tolerance to be picked."<BR><BR>==========================================================================================<BR><BR>According to the above introduction to vtkPointPicker, my problems can be <BR>easily explained.<BR><BR>First, the returning points y coordinate is not necessarily one of the 1, <BR>20, 39
and 49. This is because I set the camera position to (0, 0, 0). So <BR>when I perform a picking, the ray is from origin to the cursor position. It <BR>doesn't run parallel with the y-axis.<BR><BR>Second, I will get one or two points as a result. This is because the <BR>vtkPointPicker will return both the point coordinate closest to the camera <BR>position, and the actor that the point belongs to. When these two points <BR>are actually the same, one point is returned.<BR><BR>Third, the points from the back surface are picked sometimes. This is <BR>because the vtkPointPicker only pick the points defining each actor. So the <BR>ray will traverse all the surfaces, no matter it is front or back. If it <BR>doesn't intersect any points on the front surface, a back surface point <BR>will be returned of course. And do not forget that the ray comes from the <BR>origin (0, 0, 0).<BR><BR>Combining the second and third situation, you will probably get two points. <BR>And neither of them is on
the front surface.<BR>==========================================================================================<BR><BR><BR>Let's go on with other vtk pickers.<BR><BR>"The object vtkCellPicker intersects the ray with the cells defining each <BR>actor, and returns the point of intersection, as well as the actor that the <BR>cell belongs to. If you are trying to select a unique actor, vtkCellPicker <BR>is the object to use because it performs surface (or cell) intersection. <BR>Picking actors using vtkPicker can yield undesirable results because of the <BR>overlap of bounding boxes; the same is true of vtkPointPicker because of <BR>tolerance problems. Unfortunately, vtkCellPicker is the slowest object of <BR>the three because of greater computational requirements."<BR><BR>==========================================================================================<BR><BR>So I decided to use vtkCellPicker for my picking application. Since the <BR>camera affects the picking results
directly. Remember to manipulate it <BR>carefully. In my application, I set its position to ahead of the screen, <BR>and at the middle of the z-axis, (32, -1, 46.5). Also I set the focal point <BR>to (32, 63, 46.5), which lies in the center of the back most surfaces in my <BR>former example. It works well for picking if user does not change the <BR>camera or actor positions by vtkRenderWindowInteractor. But if this <BR>happens, I still don't know how to deal with it.<BR>==========================================================================================<BR><BR><BR>For completeness, please allow me to introduce vtkWorldPointPicker at last.<BR><BR>"The calss vtkWorldPointPicker returns the (x,y,z) coordinate value of a <BR>pick in the rendering window. To determine this information, it combines <BR>the display (x,y) values with the z-buffer depth values. Of all the pickers <BR>it is the fastest, but it cannot determine the actual cell, point or actor <BR>that is selected. (Note:
on some system z-buffer operations are inoperative <BR>and this object will not function properly)"<BR><BR><BR>Hope this will help some newbie who are performing picking in vtk, just <BR>like me.<BR><BR>Best Regards,<BR>Jiye An<BR><BR>_________________________________________________________________<BR>与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn <BR><BR>_______________________________________________<BR>This is the private VTK discussion list. <BR>Please keep messages on-topic. Check the FAQ at: <HTTP: vtkfaq cgi-bin public.kitware.com><BR>Follow this link to subscribe/unsubscribe:<BR>http://www.vtk.org/mailman/listinfo/vtkusers</BLOCKQUOTE><p><hr SIZE=1>
Do you Yahoo!?<br>
<a href="http://us.rd.yahoo.com/mailtag_us/*http://antispam.yahoo.com/tools?tool=1">Yahoo! Mail SpamGuard</a> - Read only the mail you want.</a>