> From: "Abed M. Hammoud" <[EMAIL PROTECTED]>
>
> I am using the VRML97 loader to display a .wrl file. What I would like
> to do is add a button to the loader that will allow the user to add
> a node to the scence when the button is clicked. (The button could be
> a menu item, etc...) This seems to be simple but begin knew to Java3D
> I am having problems getting it done.
The simplest way to do this is to have the VRML content and the new nodes be
separate scene graphs. The VRML scene would be one BranchGraph attached to the
locale and the new nodes would be other BranchGroups that get added to the
locale. This works fine unless you want to make the new nodes be attached to
the VRML scene graph.
For example, if you have VRML scene with a chair in and you want the new node to
be a model of a person sitting in the chair. You can make this case work by
making the VRML file have an "attachment point" for the new node. The chair
could have a Transform node in the right location with DEF name:
Group { # this holds the chair and the person
children [
Shape {...} # this is the chair
DEF Chair_seat Transform {
# the new nodes will be children of this node
}
}
}
The VRML loader will make a TransformGroup for the "Chair_seat" Transform node
and will store it in the DEF table. After loading the scene, you can get the
mount point using the named object table:
VrmlScene scene = vrmlLoader.load(url);
Hashtable defTable = scene.getNamedObjects();
TransformGroup seat = (TransformGroup) defTable.get("Chair_seat");
Set the capability bits on the chair's TransformGroup to allow children to be
added after the scene is made live. Then attach the VRML scene to the locale.
When the user hits the button, add the a BranchGroup containing the new nodes to
the TransformGroup (remember that only BranchGroups can be added to a live scene
graph).
Hope this helps,
Doug Gehringer
Sun Microsystems
=====================================================================
To subscribe/unsubscribe, send mail to [EMAIL PROTECTED]
Java 3D Home Page: http://java.sun.com/products/java-media/3D/