Hi!


I'm working on an application that builds up a data structure containing
some Java3D Nodes (Boxes etc.), but also instances of other classes. The J3D
Node instances in this structure are not part of any SceneGraph, but there
is a method that traverses the data structure and produces a SceneGraph.
This is accomplished by calling cloneTree() on each Node.

This seems to work fine, but the strange thing is that the performance of
the traverse method becomes worse and worse when it is being called
repeatedly. The problem seems to be cloneTree() and I've made this little
test program to demonstrate it:

// Test.java
import java.applet.Applet;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.*;
import java.awt.*;
import java.util.*;

public class Test extends Applet {

    private Box box = new Box();

    public Test() {
        Button btnTest = new Button("Test");
        btnTest.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                // Try un-commenting next line and see what happens!
                // box = new Box();
                System.out.println("Started: " +
                                   Calendar.getInstance().getTime());
                for (int i = 0; i < 100; i++) {
                    box.cloneTree();
                }
                System.out.println("Stopped: " +
                                   Calendar.getInstance().getTime() +
                                   "\r\n");
                System.gc();
            }});
        add(btnTest);
    }

    public static void main(String[] args) {
        Frame frame = new MainFrame(new Test(), 100, 40);
    }

}
// End of Test.java

The program creates a Box and clones it 100 times every time the user hits
the button. Here is a sample transcript that illustrates the problem:

C:\>java Test
Started: Fri Apr 21 16:43:49 GMT+02:00 2000
Stopped: Fri Apr 21 16:43:53 GMT+02:00 2000

Started: Fri Apr 21 16:43:57 GMT+02:00 2000
Stopped: Fri Apr 21 16:44:03 GMT+02:00 2000

Started: Fri Apr 21 16:44:08 GMT+02:00 2000
Stopped: Fri Apr 21 16:44:22 GMT+02:00 2000

Started: Fri Apr 21 16:44:59 GMT+02:00 2000
Stopped: Fri Apr 21 16:45:28 GMT+02:00 2000

Started: Fri Apr 21 16:46:19 GMT+02:00 2000
Stopped: Fri Apr 21 16:47:13 GMT+02:00 2000

As you can see, what initially took four seconds takes almost a minute when
it's run the fifth time! I wonder if this is a bug in Java3D, or if I'm just
missing something important. Hope you can help me out with this one...

Regards,


Are Meisfjord

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

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