SimpleNode Viewer

Just a small snippet I wrote to find out what my server is actually doing, might be usefull for others as well.



   private void exportNodeTree(Spatial rootnode) {
      JFrame frame = new JFrame("Tree");
      frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
      DefaultMutableTreeNode masterdescriptor = new DefaultMutableTreeNode("Rootnode:" + rootnode);
      JTree tree = new JTree(masterdescriptor);
      frame.add(new JScrollPane(tree));
      addAllChilds(rootnode, masterdescriptor);
      frame.pack();
      frame.setVisible(true);
   }

   private void addAllChilds(Spatial parent,DefaultMutableTreeNode descriptor) {
      DefaultMutableTreeNode bdescr = new DefaultMutableTreeNode(parent);
      descriptor.add(bdescr);
      if(parent instanceof Node){
         Node node = (Node) parent;
         for(Spatial child:node.getChildren()){
            addAllChilds(child, bdescr);
         }
      }
   }

How do you sync this? Do you wait for the AWT thread in the openGL thread?

it#s more on demand, in my application i call it over a console command in the update()

So you call it via the EventQueue.invokeAndWait() then? I guess thats quite some overhead on the update() huh?

Well you shouldn't use it for something else than debugging ^^

So some overhead is not that much a problem, (well on larger scenegraphs a 0-2 second lag).