Search in sources :

Example 1 with TransformGroup

use of javax.media.j3d.TransformGroup in project ffx by mjschnie.

the class MouseOrbit method setTransformGroups.

/**
 * <p>
 * setTransformGroups</p>
 *
 * @param tg a {@link javax.media.j3d.TransformGroup} object.
 * @param VPTG a {@link javax.media.j3d.TransformGroup} object.
 */
public void setTransformGroups(TransformGroup tg, TransformGroup VPTG) {
    super.ViewerTG = VPTG;
    tg_ghost = new TransformGroup();
    Transform3D tgT3D = new Transform3D();
    tg.getTransform(tgT3D);
    // Make a ghost TG since no transform on
    tg_ghost.setTransform(tgT3D);
// object is to occur
}
Also used : Transform3D(javax.media.j3d.Transform3D) TransformGroup(javax.media.j3d.TransformGroup)

Example 2 with TransformGroup

use of javax.media.j3d.TransformGroup in project ffx by mjschnie.

the class PickSelectionBehavior method updateScene.

/*
     * Update the scene to manipulate any nodes.
     * @param xpos Current mouse X pos. @param ypos Current mouse Y pos.
     */
/**
 * {@inheritDoc}
 */
public void updateScene(int xpos, int ypos) {
    TransformGroup tg = null;
    if ((mevent.getModifiersEx() & MouseEvent.BUTTON1) == MouseEvent.BUTTON1) {
        pickCanvas.setShapeLocation(xpos, ypos);
        PickResult r = pickCanvas.pickClosest();
        if (r != null) {
            tg = (TransformGroup) r.getNode(PickResult.TRANSFORM_GROUP);
            if ((tg != null) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))) {
                drag.wakeup();
                currentTG = tg;
                if (callback != null) {
                    callback.transformClicked(PickingCallback.SELECTION, currentTG);
                }
            }
        } else if (callback != null) {
            callback.transformClicked(PickingCallback.NO_PICK, null);
        }
    }
}
Also used : PickResult(com.sun.j3d.utils.picking.PickResult) TransformGroup(javax.media.j3d.TransformGroup)

Example 3 with TransformGroup

use of javax.media.j3d.TransformGroup in project ffx by mjschnie.

the class PickZoomBehavior method updateScene.

/*
     * Update the scene to manipulate any nodes. This is not meant to be called
     * by users. Behavior automatically calls this. You can call this only if
     * you know what you are doing.
     * @param xpos Current mouse X pos. @param ypos Current mouse Y pos.
     */
/**
 * {@inheritDoc}
 */
public void updateScene(int xpos, int ypos) {
    TransformGroup tg = null;
    if ((mevent.getModifiersEx() & MouseEvent.BUTTON3) == MouseEvent.BUTTON3) {
        pickCanvas.setShapeLocation(xpos, ypos);
        PickResult r = pickCanvas.pickClosest();
        if (r != null) {
            tg = (TransformGroup) r.getNode(PickResult.TRANSFORM_GROUP);
            if ((tg != null) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))) {
                zoom.setTransformGroup(tg);
                zoom.wakeup();
                currentTG = tg;
                if (callback != null) {
                    callback.transformClicked(PickingCallback.ZOOM, currentTG);
                }
            } else if (callback != null) {
                callback.transformChanged(PickingCallback.NO_PICK, null);
            }
        }
    }
}
Also used : PickResult(com.sun.j3d.utils.picking.PickResult) TransformGroup(javax.media.j3d.TransformGroup)

Example 4 with TransformGroup

use of javax.media.j3d.TransformGroup in project ffx by mjschnie.

the class MolecularAssembly method recurseVRML.

private void recurseVRML(Node node) {
    if (node instanceof Shape3D) {
        Shape3D s3d = (Shape3D) node;
        PickTool.setCapabilities(s3d, PickTool.INTERSECT_COORD);
        return;
    } else if (node instanceof SharedGroup) {
        SharedGroup sg = (SharedGroup) node;
        for (Enumeration<Node> e = sg.getAllChildren(); e.hasMoreElements(); ) {
            recurseVRML(e.nextElement());
        }
        return;
    } else if (node instanceof BranchGroup) {
        BranchGroup bg = (BranchGroup) node;
        for (Enumeration<Node> e = bg.getAllChildren(); e.hasMoreElements(); ) {
            recurseVRML(e.nextElement());
        }
        return;
    } else if (node instanceof TransformGroup) {
        TransformGroup vrmlTG1 = (TransformGroup) node;
        for (Enumeration<Node> e = vrmlTG1.getAllChildren(); e.hasMoreElements(); ) {
            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<Node> e = group.getAllChildren(); e.hasMoreElements(); ) {
            Node n = e.nextElement();
            recurseVRML(n);
        }
    }
}
Also used : BranchGroup(javax.media.j3d.BranchGroup) Group(javax.media.j3d.Group) SharedGroup(javax.media.j3d.SharedGroup) MSGroup(ffx.potential.bonded.MSGroup) TransformGroup(javax.media.j3d.TransformGroup) Enumeration(java.util.Enumeration) BranchGroup(javax.media.j3d.BranchGroup) Node(javax.media.j3d.Node) MSNode(ffx.potential.bonded.MSNode) Shape3D(javax.media.j3d.Shape3D) SharedGroup(javax.media.j3d.SharedGroup) Link(javax.media.j3d.Link) TransformGroup(javax.media.j3d.TransformGroup)

Example 5 with TransformGroup

use of javax.media.j3d.TransformGroup in project ffx by mjschnie.

the class RendererCache method doubleCylinderFactory.

/**
 * <p>
 * doubleCylinderFactory</p>
 *
 * @param a1 a {@link ffx.potential.bonded.Atom} object.
 * @param a2 a {@link ffx.potential.bonded.Atom} object.
 * @param div a int.
 * @return a {@link javax.media.j3d.BranchGroup} object.
 */
public static final BranchGroup doubleCylinderFactory(Atom a1, Atom a2, int div) {
    BranchGroup branchGroup;
    if (doubleCylinderPool.size() > 0) {
        branchGroup = doubleCylinderPool.remove(0);
        if (branchGroup != null) {
            TransformGroup cy1tg = (TransformGroup) branchGroup.getChild(0);
            Shape3D cy1 = (Shape3D) cy1tg.getChild(0);
            cy1.setAppearance(a1.getAtomAppearance());
            cy1.setUserData(a1);
            TransformGroup cy2tg = (TransformGroup) branchGroup.getChild(1);
            Shape3D cy2 = (Shape3D) cy2tg.getChild(0);
            cy2.setUserData(a2);
            cy2.setAppearance(a2.getAtomAppearance());
            return branchGroup;
        }
    }
    branchGroup = new BranchGroup();
    branchGroup.setCapability(BranchGroup.ALLOW_DETACH);
    branchGroup.setCapability(BranchGroup.ALLOW_CHILDREN_READ);
    branchGroup.setCapability(BranchGroup.ENABLE_PICK_REPORTING);
    TransformGroup cy1tg = createTransformGroup(null);
    Shape3D cy1 = createCylinder(a1.getAtomAppearance(), div);
    cy1.setUserData(a1);
    cy1tg.addChild(cy1);
    branchGroup.addChild(cy1tg);
    TransformGroup cy2tg = createTransformGroup(null);
    Shape3D cy2 = createCylinder(a2.getAtomAppearance(), div);
    cy2.setUserData(a2);
    cy2tg.addChild(cy2);
    branchGroup.addChild(cy2tg);
    branchGroup.compile();
    return branchGroup;
}
Also used : BranchGroup(javax.media.j3d.BranchGroup) Shape3D(javax.media.j3d.Shape3D) TransformGroup(javax.media.j3d.TransformGroup)

Aggregations

TransformGroup (javax.media.j3d.TransformGroup)16 Transform3D (javax.media.j3d.Transform3D)6 BranchGroup (javax.media.j3d.BranchGroup)5 Vector3d (javax.vecmath.Vector3d)5 PickResult (com.sun.j3d.utils.picking.PickResult)4 Shape3D (javax.media.j3d.Shape3D)4 MSNode (ffx.potential.bonded.MSNode)2 Color3f (javax.vecmath.Color3f)2 Cone (com.sun.j3d.utils.geometry.Cone)1 Cylinder (com.sun.j3d.utils.geometry.Cylinder)1 Sphere (com.sun.j3d.utils.geometry.Sphere)1 SimpleUniverse (com.sun.j3d.utils.universe.SimpleUniverse)1 Atom (ffx.potential.bonded.Atom)1 Bond (ffx.potential.bonded.Bond)1 MSGroup (ffx.potential.bonded.MSGroup)1 MSRoot (ffx.potential.bonded.MSRoot)1 ROLS (ffx.potential.bonded.ROLS)1 MergeFilter (ffx.potential.parsers.MergeFilter)1 Font (java.awt.Font)1 File (java.io.File)1