Can anyone help me?
I tryed this code and the VM throws a MultipleParentExeption
…
ObjectFile file = new ObjectFile();
Hashtable objects;
try {
objects = file.load(url).getNamedObjects();
}
catch (FileNotFoundException e) {
System.err.println(e);
System.exit(1);
}
catch (ParsingErrorException e) {
System.err.println(e);
System.exit(1);
}
catch (IncorrectFormatException e) {
System.err.println(e);
System.exit(1);
}
Enumeration e = objects.keys();
while(e.hasMoreElements()) {
String name = (String)e.nextElement();
Shape3D part = (Shape3D)objects.get(name);
if (name.equals(“gun”)) {
System.out.println(“set gun”);
this.gun = new TransformGroup();
this.gun.addChild(part);
}else if (name.equals(“body”)) {
System.out.println(“set body”);
this.robotbody = new TransformGroup();
this.robotbody.addChild(part);
}else if…
}
…
=>
set gun
javax.media.j3d.MultipleParentException: Group.addChild: child already has a parent
at javax.media.j3d.GroupRetained.checkValidChild(GroupRetained.java:440)
at javax.media.j3d.GroupRetained.addChild(GroupRetained.java:449)
at javax.media.j3d.Group.addChild(Group.java:266)
at engine.object.Robot.init(Robot.java:60)
at engine.object.Robot.(Robot.java:36)
at engine.object.ObjectManager.addRobot(ObjectManager.java:41)
at engine.Metaversum.createSceneGraph(Metaversum.java:134)
at engine.Metaversum.init(Metaversum.java:71)
at engine.Metaversum.(Metaversum.java:54)
at engine.Driver.main(Driver.java:50)
Exception in thread “main”
Is it not possible to split a obj file in different Transformgroups?
If yes, please let me know.