Yes, OrderedGroup is broken. I submitted hte following program to the
discussion group once earlier and didn't get a response so I'm sending it
again and I also have sent it directly to the 'Java 3D beta program'. I
think that the bug was initially reported much earlier by someone else and
that the Java3D team said that it will be fixed in the upcoming v. 1.2.1.

I apologize if this bug has already been reported. Just in case it hasn't,
I'm providing a test program to illustrate it. In this program an
OrderedGroup generates an IndexOutOfBoundsException when a grandchild is
detached and then replaced. The exception doesn't seem to occur in the case
of a child -- at least not in my tests.

/*******OrderedGroupBug.java********/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import com.sun.j3d.utils.applet.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;

public class OrderedGroupBug extends Applet{
        public OrderedGroupBug(){
                setLayout(new BorderLayout());
                Canvas3D c = new Canvas3D(
SimpleUniverse.getPreferredConfiguration() );
                add( "Center", c );
                final Scene scene = new Scene();

                SimpleUniverse u = new SimpleUniverse( c );
                u.getViewingPlatform().setNominalViewingTransform();
                u.addBranchGraph( scene );
                Button b1 = new Button( "Toggle Child" );
                b1.addActionListener( new ActionListener(){
                        public void actionPerformed( ActionEvent e ){
                                scene.toggleChild();
                        }
                });
                add( "North", b1 );
                Button b2 = new Button( "Toggle Grandchild" );
                b2.addActionListener( new ActionListener(){
                        public void actionPerformed( ActionEvent e ){
                                scene.toggleGrandchild();
                        }
                });
                add( "South", b2 );
        }
        public static void main( String[] args ){
                new MainFrame( new OrderedGroupBug(), 256, 256 );
        }
        class Scene extends BranchGroup{
                OrderedGroup OG = new OrderedGroup();{
                        OG.setCapability( Group.ALLOW_CHILDREN_WRITE );
                        OG.setCapability( Group.ALLOW_CHILDREN_EXTEND );
                }
                BranchGroup BG1 = new BranchGroup();{
                        BG1.setCapability( BranchGroup.ALLOW_DETACH );
                        BG1.setCapability( Group.ALLOW_CHILDREN_WRITE );
                        BG1.setCapability( Group.ALLOW_CHILDREN_EXTEND );
                }
                BranchGroup BG2 = new BranchGroup();{
                        BG2.setCapability( BranchGroup.ALLOW_DETACH );
                }
                public Scene(){
                        super();
                        addChild( OG );
                        OG.addChild( BG1 );
                        BG1.addChild( BG2 );
                        BG2.addChild( new ColorCube( 0.2f ));
                }
                public void toggleChild(){
                        if( BG1.isLive() ){
                                BG1.detach();
                        }else{
                                OG.addChild( BG1 );
                        }
                }
                public void toggleGrandchild(){
                        if( BG2.isLive() ){
                                BG2.detach();
                        }else{
                                BG1.addChild( BG2 );
                        }
                }
        }
}

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

Reply via email to