All,
I have been developing a Java 3D scenegraph viewer for my book "Java 3D
Programming". I have put quite a bit of time and effort into the tool
[Java3DTree] and I feel that it will be generally useful to the Java 3D
community.
I've taken a lot trouble to make Java3dTree very easy to integrate into
existing codebases *and to extend*.
For example:
1. create you scenegraph
BranchGroup scene = sg.createSceneGraph();
2. create the scengraph viewer
(a pop-up JFrame with a JTree)
Java3dTree j3dTree = new Java3dTree();
3. apply the capabilities required by the viewer to read the scenegraph
(note, can start at any point in the scenegraph or not at all)
j3dTree.recursiveApplyCapability( scene );
4. add the scenegraph to the universe
u.addBranchGraph(scene);
5. create the tree view to reflect the scenegraph
j3dTree.updateNodes( u );
To flesh out the functionality of the tool we need to include more
information for each Node in the scenegraph: I.e.
- Materials
- Appearance
- Bounds
- Sounds
etc., etc.
I have architected the tool such that reporting the information for the
various sub-components of Nodes can be easily accomplished by a distributed
team of developers.
For example:
public class Group_Info extends ObjectInfo
{
private static final int[] m_kCapabilityArray =
Group.ALLOW_CHILDREN_READ,
Group.ALLOW_COLLISION_BOUNDS_READ };
public Group_Info()
{
}
java.util.Enumeration getChildren( Object obj )
{
return ((Group) obj).getAllChildren();
}
public int[] getCapabilityBits()
{
return m_kCapabilityArray;
}
public String getInfo( Object obj )
{
String szText = super.getInfo( obj );
insertSectionBreak( szText );
return szText + "Group Information";
}
}
The example class above is all that is required to create a Node in the
JTree for a Group, and set the capability bits on the Group such that its
children can also be explored.
All that is required to display the information for the Group is to overide
the "getInfo" method and return a String with the information to be
displayed.
The "Group_Info" class is automatically (!) used to display information for
all Group nodes in a scenegraph and all nodes derived from Group without
their own, more specialized, _Info class. To register Group_Info one must
merely add one line of code to Java3dTree:
addObjectInfoTableItem( "javax.media.j3d.Group" );
So, if people are interested in writing Material_Info, Bounds_Info,
Appearance_Info etc. (which should not take more than an hour each), we
could very quickly have a very useful scenegraph viewer for the whole Java
3D community (less than a week if several people chip in).
I have stubbed definitions for most of the Scenegraph derived scenegraph
nodes.
I have attached a JPEG of Java3dTree in action to whet your appetites! The
lower frame is where the "getInfo" text will go.
Please email me at: [EMAIL PROTECTED] if you are interested in
contributing.
Sincerely,
Daniel Selman
[EMAIL PROTECTED]
http://www.tornadolabs.com
j3dtree.jpg