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");

//now you must start doing some testing
//usually the rootObj will be a branchgroup, test it first

if (rootObj instanceof BranchGroup)
{
        BranchGroup bgRoot = (BranchGroup)objRoot;

        //next, the next child is usually a transform group, but again, it could
also be the shape right         //underneath it

        Object childObject = bgRoot.getChild(0);
        if (childObject instanceof TransformGroup)
        {
                TransformGroup tgRoot = (TransformGroup)childObject;
                //now, again, the next item should be the child
                Object tmpObject = tgRoot.getChild(0);

                if (shapeObject instanceof Shape3D)
                {
                        Shape3D shapeObject = (Shape3D)tmpObject;

                        //now get the geometry
                        Geometry geomShape = shapeObject.getGeometry();
                        //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".

Reply via email to