Hello Everyone,
I am now having a problem making a SharedGroup. I use an extension of
ObjectFile to bring in a Scene.
Then I use getSceneGroup() to make a BG (named assemblyGroup) .
Then I use getNamedObjects() to store my Shape3D objects in a Hashtable
(named shapes).
When I need to re-use the geometry, I use shareGeom() (below) to make a
SharedGroup from an Assembly object.
This had worked in the past, but now new geometry is giving me the
MultipleParentException.
I have been unsuccessful trying a lot of things. Does anyone see my error?
Thanks,
Pierre
private void shareGeom(SharedGroup share, Assembly assembly)
{
Shape3D shape; // individual shape
Hashtable shapes; // collection of shapes in assembly
String curname; // the shape's current name
// enumerate the Shape3D objects for the assembly
shapes = assembly.getShapes();
Enumeration e = shapes.keys();
while (e.hasMoreElements()) {
curname = (String)e.nextElement();
System.err.println("Shape name= " + curname);
shape = (Shape3D)shapes.get(curname);
// remove shape from assembly
assembly.removeChildren();
// try to add current Shape3D object to the SharedGroup
try {
share.addChild(shape);
} catch (MultipleParentException mpe) {
System.err.println("The geometry named " + curname +
" has already been used ");
System.exit(1);
}
}
// compile the group
share.compile();
}// end shareGeom
public void removeChildren() {
System.err.println("Removing all children " );
for (int i=0; i<assemblyGroup.numChildren();i++) {
System.err.println("There goes child # " + i );
assemblyGroup.removeChild(i);
}
}
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".