Skip to main content

Component3D.removeAllChildren() - does it work right?

4 replies [Last post]
albrecht
Offline
Joined: 2005-07-11

hi,
in the mentioned method, the children are cast to Component3D. but i thought a component3d can also have geometry as a child (org.jdesktop.lg3d.sg.Shape). so i am getting an exception when i try do remove all children.

public void removeAllChildren() {
if(transparencyManager != null) {
int num = numChildren();
for (int i = 0; i < num; i++) {
Component3D child = (Component3D)getChild(i);
transparencyManager.removeGraph(child);
}
}
((Component3DWrapper)wrapped).removeAllChildren();
}

ps.
thx for the zbuffer-solution
pps.
how do i format code in this posts?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
paulby
Offline
Joined: 2003-06-13

Component3D can indeed have children of Shape3D or any other Node. What exception are you getting ?

To format code in the forum use \[code\] source \[\\code\]

paulby
Offline
Joined: 2003-06-13

Oops, brain in gear, it's a class cast exception

paulby
Offline
Joined: 2003-06-13

Here is the fix

[code]
public void removeAllChildren() {
if(transparencyManager != null) {
int num = numChildren();
for (int i = 0; i < num; i++) {
Node child = getChild(i);
transparencyManager.removeGraph(child);
}
}
((Component3DWrapper)wrapped).removeAllChildren();
}

[/code]

Please test it and let me know if you have any problems

paulby
Offline
Joined: 2003-06-13