I threw this together in a few minutes and thought others could use it too. It takes in a node and prints out an html list of all the children, and their children’s children. It then automatically opens it up in your web browser. Good for a quick debug of what is in your scene.
[java]
/**
Print all children from this node on down
*/
public static void printNode(Node node) {
String html = “<!DOCTYPE html><html>”;
html = html + mineNode(node);
html = html+"</html>";
try {
File f = File.createTempFile(“node”, “.html”);
FileWriter fw = new FileWriter(f);
fw.write(html);
fw.flush();
fw.close();
Desktop.getDesktop().open(f);
} catch (IOException ex) {
Logger.getLogger(this.getClass().getName()).log(java.util.logging.Level.SEVERE, “Error writing html file”, ex);
}
}
private static String mineNode(Node parent) {
String s = parent.getName()+"<br><ul>";
if (parent.getChildren().isEmpty())
return parent.getName();
else {
for (Spatial child : parent.getChildren()) {
if (child instanceof Node) {
s = s + “<li>”+mineNode((Node)child)+"</li>";
} else {
s = s + “<li>”+child.getName()+"</li>";
}
}
}
s = s + “</ul>”;
return s;
}[/java]
EDIT: I fixed the error log so it doesn’t include my class, and added the doctype.