Now I use View.pick(Canvas3D c, int x, int y, int w, int h) can return which node and which texture I clicked.How to know which model or object it is?
the following is my click code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| if (pick_sync!=null) { synchronized (pick_sync) { if (pick) { PickRenderResult[] results = view.pick(view.getCanvas3D(0), pick_x, pick_y, 3, 3); if (results == null) { } else { for (int i = 0; i < results.length; i++) { if (!mib.pick) break; Node[] nodes = results[i].getNodes(); for (int j = 0; j < nodes.length; j++) { System.out.println(" You click nodes " + j); if (nodes[j] != null) { Node parent = nodes[j].getParent(); while (true) { if (parent == null) break; if (parent instanceof FaceGroup) break; parent = parent.getParent(); } if (parent!=null) { ((FaceGroup)parent).doClick(); } mib.pick = false; } } } mib.pick = false; } } } } |