Dear All:

i have a branch Group with three children. All the children are also branch
Groups which also contains 3D graphs like;

BranchGroup createSceneGraph(Vector hix)
    {
        BranchGroup objRoot = new BranchGroup();
        objRoot.setCapability(BranchGroup.ALLOW_DETACH);
        objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
                objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_WRITE);
                objRoot.setCapability(BranchGroup.ALLOW_CHILDREN_EXTEND);

        for(int k =0;k<3;k++)
                {
                System.out.println("k="+k );
                objRoot.addChild(makeOneGraph(k,hix));
                }
        return objRoot;
    }

i need some help with how to read and display the second and third children.

this is the method i wrote:

private void showChildren(boolean boon)
{
        if(boon != false && isRunning() )
        {

        //java.util.Enumeration enumChild = scene.getAllChildren();
        //if (enumChild.hasMoreElements())
        if (scene!=null)
        {
                //System.out.println("enum size="+enumKids);
        BranchGroup brg = (BranchGroup) scene.getChild(1);
                if (brg instanceof BranchGroup )
                 {
                        //brg.detach();
                         GraphicsConfigTemplate3D template = new
GraphicsConfigTemplate3D();
        GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice device = env.getDefaultScreenDevice();
        GraphicsConfiguration config =
device.getBestConfiguration(template);
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
                Canvas3D canvax = new Canvas3D(config);
                canvax.addMouseListener(this);
                u2 = new SimpleUniverse(canvax);

                pickCanvas = new PickCanvas(canvax, brg);
                pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
                pickCanvas.setTolerance(0.0f);
                canvas.setCursor(new Cursor(Cursor.HAND_CURSOR));

                // cannot share cannot share canvas with multiple views.

                // get the view
                //view = u.getViewer().getView();
                //view.addCanvas3D(canvas);

                // This will move the ViewPlatform back a bit so the
                // objects in the scene can be viewed.
                ViewingPlatform viewingPlatform = u.getViewingPlatform();
                viewingPlatform.setNominalViewingTransform();

        // add an orbit behavior to move the viewing platform
        OrbitBehavior orbit = new
OrbitBehavior(canvas,OrbitBehavior.STOP_ZOOM);
        orbit.setSchedulingBounds(bounds);
        viewingPlatform.setViewPlatformBehavior(orbit);

                u2.addBranchGraph(brg);

        JFrame f = new JFrame("test");
        f.getContentPane().add(canvax,"Center");
        f.setBounds(100,100,400,400);
        f.setVisible(true);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                }
        }


        }
}

and this  is the ERROR:


all children=3
javax.media.j3d.MultipleParentException: Locale.addBranchGraph: Branch Group
already has a parent
        at javax.media.j3d.Locale.addBranchGraph(Locale.java:158)
        at
com.sun.j3d.utils.universe.SimpleUniverse.addBranchGraph(SimpleUniverse.java
:356)
        at GraphicDisplay.showChildren(GraphicDisplay.java:1144)

I am really out of ideas, any help will be reaaly Appreciated.
i am 98& done.

Isaac

===========================================================================
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".

Reply via email to