<div dir="ltr"><div>Seems strange. When you do the picks, log xPtr[0] and yPtr[0] to make sure that the picks are occurring at the expected location.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 23, 2016 at 11:11 AM, Lonni Besançon <span dir="ltr"><<a href="mailto:lonni.besancon@gmail.com" target="_blank">lonni.besancon@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello everyone,<br>
<br>
I'm facing a weird issue.<br>
I've followed the vtkPicker example given here<br>
<<a href="http://www.itk.org/Wiki/VTK/Examples/Cxx/Interaction/Picking" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/VTK/Examples/Cxx/Interaction/Picking</a>> to suit my<br>
needs.<br>
<br>
I have a scene, with one renderer and two actors.<br>
One of them is removed from the scene at some point (it's a volume) so it<br>
does not count when I'm using the picker.<br>
The other one is a vtkActor containing a plane.<br>
<br>
Now I'm using android and based on the VolumeRender code, I added a small<br>
chunk of code to the onMotionEvent native function (called when fingers are<br>
placed on the screen of the device).<br>
<br>
In case you don't want to browse through the examples and the code, here is<br>
what the native function does:<br>
<br>
/JNIEXPORT void JNICALL<br>
Java_com_kitware_VolumeRender_VolumeRenderLib_onMotionEvent(JNIEnv * env,<br>
jobject obj, jlong udp,<br>
jint action,<br>
jint eventPointer,<br>
jint numPtrs,<br>
jfloatArray xPos, jfloatArray yPos,<br>
jintArray ids, jint metaState)<br>
{<br>
struct userData *foo = (userData *)(udp);<br>
<br>
int xPtr[VTKI_MAX_POINTERS];<br>
int yPtr[VTKI_MAX_POINTERS];<br>
int idPtr[VTKI_MAX_POINTERS];<br>
<br>
/*vtkSmartPointer<vtkTransform> t = vtkSmartPointer<vtkTransform>::New();<br>
double * origin = foo->plane->GetOrigin();<br>
origin[2] += 0.3 ;<br>
foo->plane->SetOrigin(origin);*/<br>
<br>
// only allow VTKI_MAX_POINTERS touches right now<br>
if (numPtrs > VTKI_MAX_POINTERS)<br>
{<br>
numPtrs = VTKI_MAX_POINTERS;<br>
}<br>
<br>
// fill in the arrays<br>
jfloat *xJPtr = env->GetFloatArrayElements(xPos, 0);<br>
jfloat *yJPtr = env->GetFloatArrayElements(yPos, 0);<br>
jint *idJPtr = env->GetIntArrayElements(ids, 0);<br>
for (int i = 0; i < numPtrs; ++i)<br>
{<br>
xPtr[i] = (int)xJPtr[i];<br>
yPtr[i] = (int)yJPtr[i];<br>
idPtr[i] = idJPtr[i];<br>
}/<br>
<br>
So I just added this small piece of code to try and detect when the user is<br>
placing his/her finger on my planeActor:<br>
<br>
/vtkSmartPointer<vtkPropPicker> picker<br>
=vtkSmartPointer<vtkPropPicker>::New();<br>
int* clickPos = foo->Interactor->GetEventPosition();<br>
picker->Pick(xPtr[0], yPtr[0], 0, foo->Renderer);<br>
<br>
if(picker->GetActor() == foo->planeActor){<br>
LOGW("Plane Picked ********************");<br>
// Case of the seeding point positionning<br>
}<br>
else{<br>
LOGW("#################### Outside of plane");<br>
}/<br>
<br>
Now when I check my logcat while having my finger on the plane I get<br>
something like:<br>
/W/NativeVTK(29678): Plane Picked ********************<br>
W/NativeVTK(29678): #################### Outside of plane<br>
W/NativeVTK(29678): #################### Outside of plane<br>
W/NativeVTK(29678): #################### Outside of plane<br>
W/NativeVTK(29678): Plane Picked ********************/<br>
<br>
When my finger is not located on my plane, this is correctly detected, but<br>
it's on it would appear to trigger both events.<br>
<br>
Would you mind giving me some explanations on that matter?<br>
<br>
Thanks in advance<br><br>
</blockquote></div><br></div></div>