Removing Children

Hey Everyone,

I’ve gotten the basic hang of Java3D, but one thing that still puzzles me is how to remove a child from a group after it becomes live / compiled. Once a node is added as a child to a Group, and becomes live, can it never be removed?

For instance, I might have laser blasts in a game, and instead of recycling, say I’d want to destroy them after they’ve performed their duty. Instead of being cheap and setting their transparency to zero, conceptually, how might I be rid of them?

Thanks. :slight_smile:

Just remove them. But you must set the right capability bits on creation (on each node) or Java3d wont let you. I think it’s ALLOW_DETACH or something. Never understood what good capability bits are for, they are so annoying.

You can only attach or detach a BranchGroup, and the capability bits must be set to ALLOW_DETACH:

myBG.setCapability( BranchGroup.ALLOW_DETACH );
myBG.clearCapabilityIsFrequent( BranchGroup.ALLOW_DETACH );

The capability bits make a big difference in performance, most especially if used in conjunction with BranchGroup.compile().

Ah, okay. :slight_smile:

So, hypothetically, if I had a scene where 40 laser blasts were shot, and I wanted them all removed, they would have to have been under a BranchGroup – with the proper capability bits set, of course.