Pierre,
I'm not sure I understand your code completely (given that I only gave
it a quick glance). But two things pop to my mind immediately.
1) It seems that each time through your loop you attempt to remove ALL
children from the Assembly.
2) When you are removing children you are counting up through your
children (but keep in mind that the number of children is reducing each
time you remove one).
I don't think there is enough information in what you sent to detect
where you are getting a multiple parent.
- John Wright
Starfire Research
"Pondrom, Pierre L" wrote:
>
> 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".
===========================================================================
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".