Example usage for javax.media.j3d Link getSharedGroup

List of usage examples for javax.media.j3d Link getSharedGroup

Introduction

In this page you can find the example usage for javax.media.j3d Link getSharedGroup.

Prototype

public SharedGroup getSharedGroup() 

Source Link

Document

Retrieves the node's SharedGroup reference.

Usage

From source file:TreePrinter.java

private void printNode(Object o, int indent, Set sharedGroups) {
    for (int i = 0; i < indent; i++)
        printStream.print(">");
    printStream.print(nodeString(o) + ": ");
    if (o instanceof SceneGraphObject) {
        SceneGraphObject sgo = (SceneGraphObject) o;
        int capBits = 0;
        // TODO: how to make sure we always check all the valid bits?
        for (int i = 0; i < 64; i++) {
            if (sgo.getCapability(i)) {
                capBits |= 1 << i;
            }/* w w w.j av  a  2s. c  o  m*/
        }
        printStream.print("capBits:Ox" + Integer.toHexString(capBits));
        if (o instanceof javax.media.j3d.Group) {
            javax.media.j3d.Group g = (javax.media.j3d.Group) o;
            int numChildren = 0;
            try {
                numChildren = g.numChildren();
            } catch (CapabilityNotSetException e) {
                //anyone who is using treePrinter, is debugging, so it is
                //alright to blindly allow read. you should first detach
                //browser.curScene, print the tree, then add it back to
                //browser.locale when finished.
                g.setCapability(javax.media.j3d.Group.ALLOW_CHILDREN_READ);
                numChildren = g.numChildren();
                //System.out.println("Can't read children on group");
                //return;
            }
            printStream.print(" children:" + numChildren);
            if (o instanceof TransformGroup) {
                Transform3D transform = new Transform3D();
                Transform3D identity = new Transform3D();
                TransformGroup t = (TransformGroup) o;
                t.getTransform(transform);
                // TODO: use getBestType() when implemented
                if (transform.equals(identity)) {
                    printStream.print(" xform:IDENTITY ");
                } else {
                    printStream.print(" xform:NON-IDENTITY ");
                }
            }
        } else if (o instanceof Link) {
            Link l = (Link) o;
            SharedGroup sg = l.getSharedGroup();
            printStream.print(" sg:" + nodeString(sg));
            sharedGroups.add(sg);
        } else {
            printStream.print(": leaf");
        }
    }
    printStream.println();
}

From source file:ffx.potential.MolecularAssembly.java

private void recurseVRML(Node node) {
    if (node instanceof Shape3D) {
        Shape3D s3d = (Shape3D) node;
        PickTool.setCapabilities(s3d, PickTool.INTERSECT_COORD);
        return;/* w w w .j a  v  a 2s.  c  o  m*/

    } else if (node instanceof SharedGroup) {
        SharedGroup sg = (SharedGroup) node;
        for (Enumeration e = sg.getAllChildren(); e.hasMoreElements();) {
            recurseVRML((Node) e.nextElement());
        }

        return;
    } else if (node instanceof BranchGroup) {
        BranchGroup bg = (BranchGroup) node;
        for (Enumeration e = bg.getAllChildren(); e.hasMoreElements();) {
            recurseVRML((Node) e.nextElement());
        }

        return;
    } else if (node instanceof TransformGroup) {
        TransformGroup vrmlTG1 = (TransformGroup) node;
        for (Enumeration e = vrmlTG1.getAllChildren(); e.hasMoreElements();) {
            node = (Node) e.nextElement();
            recurseVRML(node);
        }

        return;
    } else if (node instanceof Link) {
        Link link = (Link) node;
        recurseVRML(link.getSharedGroup());
        return;

    } else if (node instanceof Group) {
        Group group = (Group) node;
        for (Enumeration e = group.getAllChildren(); e.hasMoreElements();) {
            Node n = (Node) e.nextElement();
            recurseVRML(n);
        }

    } else {
        return;
    }

}