Skip to main content

TransformGroup remove child

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
blabloeblabloebla
Offline
Joined: 2010-04-10

I've created an simple java3d application.

Now I can't do "removeChild" of the transformgroup.

{

BranchGroup objRoot = new BranchGroup();
TransformGroup objTrans = new TransformGroup();
objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Sphere s = new Sphere();

objTrans.addChild(s);

}

{
onkeypress(
objTrans.removeChild(s);
);
}

When I do that it doesn't work, can someone help me?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
interactivemesh
Offline
Joined: 2006-06-07

Hi,

only a BranchGroup can be added to or removed from a live and/or compiled Java 3D scene graph and if corresponding capability bits are set. Wrapping a Node with a BranchGroup allows to add and remove arbitrary Nodes, e.g. TransformGroup and Shape3D.

 BranchGroup sphereBranch = new BranchGroup();<br />
sphereBranch.setCapability(BranchGroup.ALLOW_DETACH);<br />
Sphere s = new Sphere();<br />
sphereBranch.addChild(s);<br />
objTrans.addChild(sphereBranch);<br />
//<br />
void onkeypress() {<br />
  sphereBranch.detach();<br />
}<br />

See javadoc of Group and BranchGroup. August