FilterGus
- My
Homepage
(c) Mauro Marinilli September 1998
Scene Graph Viewer 0.1
for Java3D 1.1 beta01
|
Java3D, the 3D API for Java enables
3D applications with new features like 3D on the Web, and a high level
approach to 3D programming. This package is one of the first developed
for this API and represents the core of a library of classes aimed at developing
a fully Java-implemented Java3D editor facility. This is anyway an early
release and most of its functionalities are just sketched or even not yet
fully available from Javasoft. Future releases will come as soon as new
features will be provided.
Here is a screenshot from the Viewer class, as you can see
nodes by now are tagged laconically with their toString() method.
figure 1. a screenshot from the Viewer
A Java package for visualizing VirtualUniverse
instances with a tree-like interface using the Swing JTree class. A set
of classes that build a tree model out of a Java3D scene graph. This not
just for looking at it, but also for editing, building and generating full
working scenes (The model is bidirectional).
This current release anyway has not editing features because of not
yet resolved problems with the 1.1_beta01 Java3D API.
Unzip the file in
a new directory and be sure to have Java1.2beta4 with Java3D
1.1 beta01 working and launch Viewer for a GUI front end.
Using it with existing scenes
|
When you use it pay attention to obtain all the
needed capabilities from every node, otherwise it won't work; for instance,
just after a objNode object statement, write also:
objNode.setCapability(objNode.ALLOW_CHILDREN_READ);
That is unpractical in this early release, because
you need to code it for every Node instance in your code! As soon
as serialization and robust cloning will be available (and documented)
this boundary will be overcome.
As a simple procedure, following these steps to see
the SceneGraph from your Java3D scene:
-
make sure every node has its property set for being readable from the tree
model
-
call one of the classes described below, the one that better matches your
needs, or even MainFrame as well, giving as the constructor parameter
your VirtualUniverse instance, fully readable or editable as you
need.
In the package is also shipped a HelloTree
class modified, so just launch it.
a brief class description
|
-
AbstractTreeModel a convenience class for implementing the
TreeModel (see the Java Swing Tutorial)
-
TreeModelSupport a convenience class for implementing the
TreeModel (see the Java Swing Tutorial)
-
SceneTreeModel the model itself, given a VirtualUniverse instance
creates a TreeModel's one to be drawn as a 2D, tree-like representation.
As described by the Swing team (last month) a tree model can be either
build anew or just created adapting a pre-existing tree data structure.
The latter was the simplest solution in this case, even if it needed more
code and some ad-hoc solutions that will be expanded in next releases.
-
SceneTreePanel the (scrollable) panel where the JTree is layed
out. You can use this class to put the panel on your own frames.
-
Viewer an example frame that uses the SceneTreePanel
that uses itself the core SceneTreeModel.
-
InfoDialog an utility class for MainFrame
-
SerializeVU an utility class for serializing VirtualUniverses.
Just use it in your code when your VirtualUniverse is ready, the constructor
serializes it with the toString() for a file name (instanceof@HashCode).
Doesn't work due to an actual lack in the feature, see known
problems.
-
ViewerSplitPanel is an utility class that displays a tree and
the VirtualUniverse that it represents near it. It has not been
fully implemented because when you select different nodes in the JTree
you expect to see the scene from that node down in the hierarchy
but this implied cloning it for a clean design, and without this feature
you need to detach branches (so do maiming the JTree!) because they can
have only one father, etc. etc. Hence, for sake of simplicity it
was all postponed to next, sounder API releases.
To summarize, TreeModelSupport handles the Listeners, those classes
responsible for handling specialized events in the Swing architecture model
(a modified MVC ).It's just a matter of visiting each of them, stored in
a list and fire their notification methods. Its work is general and could
be used and reused for different tree model needs.
Then comes SceneTreeModel that implements all the remaining
methods needed for carving out a tree of any object, in Swing's programmer's
view:
getRoot, getChild, getChildCount, isLeaf, indexOfChild, valueForPathChanged
After you have had a tree model of your data structure (here the VirtualUniverse
class, any VirtualUniverse) it's just a layering exercise,
to make from it a JTree , and with the JTree a JPanel, and with the JPanel
a JFrame, each class providing more and more accessory methods suited for
their respective levels. Of course you can get rid of all this proliferation
and make it out with one or two classes, but you know...
-
Sept.1998 written the essential classes and the UI fully working.
the I/O operations (loading especially) are not working due to unresolved
problems
(Finally, thanks to Professor Marco Schaerf for its kind attention
& patience with this clumsy first release)
-
the cloneTree methods seems to be bound throwing nullPointer
exceptions on leaf nodes in all the examples classes bundled with this
release.This problem needs further work.
It is essential to clone objects for manipulating them as needed but
actually I don't know if it is my or their fault.
-
serialization is not implemented yet from Javasoft and this makes useless
the input/output facilities unless next releases will be available.
-
sadly, being serialization still unavailable the only way to load in VirtualUniverses
is hard coding it in the source file, using the VU class that
provides easy connection, being an Applet subclass. Future release
will provide dinamic loading via ClassLoader.
-
Also another temporary bug is accessing the nodes up to the ViewingPlatform
one (the node selected in figure 1), because for easy
of development all the examples subclass SimpleUniverse making unaccessible
the capabilities bits of this node.
-
Finally, documentation lacks. As this is a very early version and will
be changed in the future, but being alsoa very useful library both for
Swing JTree's and Java3D's learning I decided to publish this right now.
For any question please email me.
(c) Mauro Marinilli September 1998
Java, Java3D, etc. are trademarks of SUN Microsystems inc.