Dead branchgroups still visible?

How is it possible to have branchgroups that are not live but are part of a visible scene?

A bit more checking - it only happens when I have left and returned to the Java3D panel - it then creates the scengraph completely correctly, but somehow destroys it between creating and displaying it and performing any picking on it - the MousePressed action finds the branchgroup null.

Can anyone suggest a reason for this seemingly inexplicable behaviour?

As far as i know, if a BG is visible, then it ‘lives’, and this by definition (the reciprocal isn’t true).

Do you mean what’s displayed changes when the window lose focus and gain it again?!? ??? :o ???

I suppose, you don’t see what you expected, or even nothing, right? Then:

  1. how can you know the scene is correctly created when you see the wrong result?
  2. If it is truly correctly build and added, have you checked some usual “forgot-things” (lights, view, adding BG somewhere, obsolete transforms…)?
  3. If it’s an animated scene, maybe ongoing behaviors is the reason of unexpected results(?)

Does it happen when you click on visible objects, or the place they should without seeing them?
(And the flag ENABLE_PICK_REPORTING flag is set i suppose)

These are just thoughts…
…I think it needs some more details to help you out.
Cheers

This is what is confusing me. The scene is created entirely correctly - looking exactly the same as it did when I left it. It displays perfectly and the rotation behaviour responds as expected. It is only when I click on the canvas to perform some kind of picking that the error occurs.

The class I am working from maintains the root branchgroup internally while it exists. A watch in the debugger following that branchgroup finds it correct and live until the beginning of the mouseClicked method (the class implements MouseListener) whereupon the branchgroup is recorded as Null. There is only one method in the class that can make it null and that is not being called - or at least it’s breakpoints aren’t triggered.

The only thing I can think of is that because I am recycling the same Canvas3D, due to previously mentioned problems with it drawing a huge black rectangle if I created a new one, the picking methods are somehow trying to use the old Canvas3D.

When I remove my class I call this method- is there any way traces of the pickCanvas could be being maintained after this?

public void roomClear()
{
        System.err.println("\n***We are clearing this room!\n***");
        Viewer[] ox = ourView.getViewers();
        for( int p=0;p<ox.length;p++)
                 ox[p].getView().removeAllCanvas3Ds();
        ourView.detach();
        ourBG.detach();
        ourView = null;
        ourBG = null;
}

Alright then, I have fixed it, largely thanks to writing the above post.

I was adding the object to the Canvas3D as a mouselistener but I was never removing it, so although I thought I was getting rid of it, I was keeping that one reference and when I created a new one it kept trying to use the old one instead. A Canvas.removeMouseListener(this) did the trick.