Dean,

Presumably this is related to your previous post! ;-)

I have attached a modified version of SimpleVrml97Viewer (from the Java 3D
VRML source) that not only integrates J3dTree but retrieves the name of a
VRML object when you click on it with the mouse.

The file was modified originally by Juergen Neubauer, I added J3dTree and
fixed a couple of problems with the picking.

Adding J3dTree support basically involves three steps:
1. Create the tree object (m_Java3dTree)
2. Call m_Java3dTree.recursiveApplyCapability( branchGroup ) at some point
before the scene goes live
3. Call m_Java3dTree.updateNodes( universe ) to display the scenegraph in
the tree.

The only problem is with scenes that have been compiled before J3dTree can
get a crack at them with the recursiveApplyCapability call (which sets all
the _READ capabilities that it requires). The VRML loader is polite however
and does not compile the scenegraph before it returns it to you so you
shouldn't have any problems.

If you have any difficulty drop me a line with the source and I should be
able to help out.

Sincerely,

Daniel Selman

[EMAIL PROTECTED]
http://www.tornadolabs.com

> -----Original Message-----
> From: Discussion list for Java 3D API
> [mailto:[EMAIL PROTECTED]]On Behalf Of Dean Keeler
> Sent: 17 January 2000 13:56
> To: [EMAIL PROTECTED]
> Subject: Re: [JAVA3D] getting shape from vrml and finding the points
>
>
> How can I get Daniel Selmans tree object program to allow me to see what
> classes are in my VRML file?
>
> Thanks,
>
> Dean
> ----- Original Message -----
> From: SUBSCRIBE JAVA3D-INTEREST Nazrul <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, January 12, 2000 2:34 PM
> Subject: Re: [JAVA3D] getting shape from vrml and finding the points
>
>
> > Well, if you have the shape DEF'd in the vrml file, it will be easier =)
> > Let us say that the DEF'd object's name is CubeShape
> >
> > do
> > Hashtable hash = Scene.getNamedObjects();
> > Object rootObj = hash.get("CubeShape");
> >
> > file://now you must start doing some testing
> > file://usually the rootObj will be a branchgroup, test it first
> >
> > if (rootObj instanceof BranchGroup){
> > BranchGroup bgRoot = (BranchGroup)objRoot;
> >
> >         file://next, the next child is usually a transform group, but
> again, it could
> > also be the shape right         file://underneath it
> >
> >         Object childObject = bgRoot.getChild(0);
> >         if (childObject instanceof TransformGroup)
> >         {
> >                 TransformGroup tgRoot = (TransformGroup)childObject;
> >                 file://now, again, the next item should be the child
> >                 Object tmpObject = tgRoot.getChild(0);
> >
> >                 if (shapeObject instanceof Shape3D)
> >                 {
> >                         Shape3D shapeObject = (Shape3D)tmpObject;
> >
> >                         file://now get the geometry
> >                         Geometry geomShape = shapeObject.getGeometry();
> >                         file://yeah, you now have the geometry
> >                 }
> >         }
> > }
> >
> > now, the problem here is that, you never know if the child to parent
> > relationships are going to be like this.  You could use Daniel Selman's
> tree
> > object, load up the vrml object, see how the tree structure looks to get
> to your
> > vrml shape, and then write the code to get to it.  Or, you
> could do almost
> > exactly what he did in code and just build tree traversers, so
> you get the
> main
> > object from the hashtable, then start testing to see if it is a shape3D.
> If it
> > isn't cast it to it's object type, then get all of it's children and go
> > recursively through them until you find a shape3d. Once you find the
> shape3d you
> > can get the geometry.
> >
> > Hope that helps
> > Scott
> >
> >
> > Scott Decker
> > Research Scientist
> > Pacific Northwest National Labs
> > [EMAIL PROTECTED]
> > please feed the squirrels
> >
> >
> ==================================================================
> =========
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> > of the message "signoff JAVA3D-INTEREST".  For general help,
> send email to
> > [EMAIL PROTECTED] and include in the body of the message "help".
> >
>
> ==================================================================
> =========
> To unsubscribe, send email to [EMAIL PROTECTED] and include
> in the body
> of the message "signoff JAVA3D-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>

SimpleVrml97Viewer.java

Reply via email to