Re: Delaunay and Java3D

Hi Desiree,

> Hi, thanks for your help, I found a Shap3D there, but I have problems
> detaching it:
> 
> public void displayChanged(DisplayEvent e) {
>         if (e.getId() == DisplayEvent.TRANSFORM_DONE) {
>             System.out.println("displaychanged");
>             BranchGroup branchGroup = renderer.getBranch();
>             branchGroup.detach();
>             Enumeration enum = branchGroup.getAllChildren();
>             System.out.println(branchGroup);
>             while(enum.hasMoreElements()) {
>                 Object o;
>                 o = enum.nextElement();
>                 if (o instanceof BranchGroup) {
>                     System.out.println((BranchGroup) o);
>                 }
>                 if (o instanceof Shape3D) {
>                     System.out.println((Shape3D) o);
>                     Shape3D shape3d = (Shape3D) o;
> 
>                     // GIS3DView machen und fuellen
>                     GIS3DView gis3dView = new GIS3DView(true);
>                     Layer3D layer3d = new Layer3D();
>                     layer3d.addShape(shape3d);
>                     gis3dView.addLayer(layer3d);
> 
>                     GisTermService s = GisTerm.lookupService("GisTerm");
>                     JTabbedPane p = gisTerm.getTabbedPane();
>                     p.add("VisAD",gis3dView);
>                     p.setSelectedComponent(gis3dView);
> 
>                 }
>             }
>         }
> 
> I get the following exception:
> 
> displaychanged
> javax.media.j3d.BranchGroup@5f4bfc
> javax.media.j3d.Shape3D@75b4d1
> javax.media.j3d.MultipleParentException: Group.addChild: child already has
> a par
> ent
>         at
> javax.media.j3d.GroupRetained.checkValidChild(GroupRetained.java:374)
> 
>         at javax.media.j3d.GroupRetained.addChild(GroupRetained.java:383)
>         at javax.media.j3d.Group.addChild(Group.java:261)
>         at gis.services.gis3D.Layer3D.addShape(Layer3D.java:140)
>         at
> app.gwvis.TerrainListener.displayChanged(TerrainListener.java:51)
>         at visad.DisplayImpl.notifyListeners(DisplayImpl.java:430)
>         at visad.DisplayImpl.notifyListeners(DisplayImpl.java:413)
>         at visad.DisplayImpl.doAction(DisplayImpl.java:1025)
>         at visad.ActionImpl.run(ActionImpl.java:198)
>         at visad.util.ThreadPool$ThreadMinnow.run(ThreadPool.java:86)
> ...

I'm not sure, but this looks like a bug in Java3D, since you
are calling branchGroup.detach() before you add() its descendant
Shape3D to another scene graph.  You may need to get the
GeometryArray from the Shape3D and copy its coordinates, normals
and colors into a new GeometryArray and put that in a new Shape3D.
I think the GeometryArray will be a TriangleStripArray.

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html


  • 2000 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: