Currently I do it this way. It returns the picked Shape3D. Checkpos is the xy-position on the screen you want to check for hits:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| View mYourview = ... this is your view object.
public Node pickit(Point checkpos) { PickRenderResult[] result = mYourview.pick(mYourview.getCanvas3D(0), checkpos.x, checkpos.y, 2, 2); if (result == null) { return null; } Node node = null; int zbest = 0; for (int i = 0; i < result.length; i++) { PickRenderResult restmp = result[i]; int zmin = restmp.getZMin(); if (zmin < zbest) { zbest = zmin; node = restmp.getNodes()[0]; } } System.out.println(result.length + " hit objects."); return node; } |