Skip to main content

Updating the BranchGroup in a PickCanvas

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2010-11-11

Whenever the user first clicks on the scene, the PickObject returns the Shape3D without a problem. There's some manipulation that is done to the scene. Once the user chooses to pick another Shape3D object in the scene, there is an error when trying to retrieve that object with the PickCanvas object:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Picking can only work if BranchGroup is alive
at com.sun.j3d.utils.picking.PickTool.pickGeomAllSorted(
at com.sun.j3d.utils.picking.PickTool.pickGeomClosest(
at com.sun.j3d.utils.picking.PickTool.pickClosest(
Here's some example code of what I am doing. All Shape3D objects have been set with the folIowing capabilities:
// Enable picking
PickTool.setCapabilities(shape, PickTool.INTERSECT_FULL);
Here's the wrapper class, GraphicsPick, to wrap PickCanvas:
public class GraphicsPick extends MouseAdapter {
private final PickCanvas pickCanvas;

public GraphicsPick(Canvas3D canvas, BranchGroup root) {
pickCanvas = new PickCanvas(canvas, root);

public void mouseClicked(MouseEvent mouseEvent) {
PickResult result = pickCanvas.pickClosest();
if (result == null) {
System.out.println("Nothing picked");
} else {
System.out.println("x = " + mouseEvent.getX() + " y = " + mouseEvent.getY());
Primitive prim = (Primitive) result.getNode(PickResult.PRIMITIVE);
Shape3D shape = (Shape3D) result.getNode(PickResult.SHAPE3D);
// manipulate shape3D object


Any help would be greatly appreciated. Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2010-11-11

I forgot to mention that I manipulate the Shape3D object whenever the user does a pick on the canvas. The first time goes fine, but the second time just returns the error above.
I was thinking that this was due to associcating the Canvas3D object with mutliple GraphicsPick (my wrapper class), but trying to limit this action didn't help since i get the same error. I assume the scenes are alive since I see them on the canvas as I'm attempting to pick a Shape3D object from the scene.
Any help would be greatly appreciated.