Search in sources :

Example 1 with Transform3D

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

the class GraphicsCanvas method resetGlobalView.

/**
 * This functions centers the scene.
 */
public void resetGlobalView() {
    double radius = mainPanel.getDataRoot().getExtent();
    Transform3D t3d = new Transform3D();
    t3d.setScale(1.0d / (1.2d * radius));
    baseTransformGroup.setTransform(t3d);
    graphicsEvents.centerView(true, true, true);
}
Also used : Transform3D(javax.media.j3d.Transform3D)

Example 2 with Transform3D

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

the class MouseBehavior method setTransformGroup.

/**
 * <p>
 * Setter for the field <code>transformGroup</code>.</p>
 *
 * @param t a {@link javax.media.j3d.TransformGroup} object.
 */
public void setTransformGroup(TransformGroup t) {
    transformGroup = t;
    currXform = new Transform3D();
    transformX = new Transform3D();
    transformY = new Transform3D();
    reset = true;
}
Also used : Transform3D(javax.media.j3d.Transform3D)

Example 3 with Transform3D

use of javax.media.j3d.Transform3D 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 4 with Transform3D

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

the class RendererCache method transform3DFactory.

/**
 * <p>
 * transform3DFactory</p>
 *
 * @return a {@link javax.media.j3d.Transform3D} object.
 */
public static final Transform3D transform3DFactory() {
    Transform3D transform3D;
    if (transform3DPool.size() > 0) {
        transform3D = transform3DPool.get(0);
        if (transform3D != null) {
            return transform3D;
        }
    }
    transform3D = new Transform3D();
    return transform3D;
}
Also used : Transform3D(javax.media.j3d.Transform3D)

Example 5 with Transform3D

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

the class MainPanel method merge.

/**
 * Merge two or more selected FSystem Nodes into one FSystem node. There are
 * a few gotchas that need to be fixed
 *
 * @param nodesToMerge a {@link java.util.ArrayList} object.
 */
public void merge(ArrayList<MSNode> nodesToMerge) {
    ArrayList<MSNode> activeNodes = new ArrayList<MSNode>();
    for (MSNode node : nodesToMerge) {
        if (node != null && !(node instanceof MSRoot)) {
            activeNodes.add(node);
        }
    }
    if (activeNodes.size() <= 1) {
        return;
    }
    // Set up a structure to hold the new system
    FFXSystem active = hierarchy.getActive();
    File file = SystemFilter.version(hierarchy.getActive().getFile());
    FFXSystem system = new FFXSystem(file, "Merge Result", active.getProperties());
    system.setKeyFile(active.getKeyFile());
    system.setKeywords(KeyFilter.open(active.getKeyFile()));
    // Fill arrays with the atoms and bonds from the systems to be combined
    ArrayList<Atom> mergedAtoms = new ArrayList<Atom>();
    ArrayList<Bond> mergedBonds = new ArrayList<Bond>();
    ArrayList<FFXSystem> systems = new ArrayList<FFXSystem>();
    TransformGroup parentTransformGroup = null;
    FFXSystem parentSystem;
    Transform3D parentTransform3D = new Transform3D();
    Vector3d parentPosition = new Vector3d();
    Vector3d atomPosition = new Vector3d();
    // TINKER Atom Numbers start at 1
    int atomNum = 1;
    Vector3d zero = new Vector3d(0.0, 0.0, 0.0);
    for (MSNode m : activeNodes) {
        parentSystem = (FFXSystem) m.getMSNode(FFXSystem.class);
        if (parentSystem == null) {
            return;
        }
        if (!systems.contains(parentSystem)) {
            graphicsCanvas.updateSceneWait(parentSystem, false, true, RendererCache.ViewModel.WIREFRAME, false, null);
            systems.add(parentSystem);
        }
        // Move each atom into the global frame by applying the System
        // Transform to
        // relative atomic position
        parentTransformGroup = parentSystem.getOriginToRot();
        parentTransformGroup.getTransform(parentTransform3D);
        parentTransform3D.get(parentPosition);
        parentTransform3D.setTranslation(zero);
        // parentTransform3D.setScale(1.0d);
        ArrayList<Atom> atoms = m.getAtomList();
        ArrayList<ROLS> bonds = m.getBondList();
        for (Atom atom : atoms) {
            atom.removeFromParent();
            atom.setXyzIndex(atomNum++);
            mergedAtoms.add(atom);
            atom.getV3D(atomPosition);
            parentTransform3D.transform(atomPosition);
            atomPosition.add(parentPosition);
            atom.moveTo(atomPosition);
        }
        for (ROLS msm : bonds) {
            Bond bond = (Bond) msm;
            bond.removeFromParent();
            mergedBonds.add((Bond) msm);
        }
    }
    for (FFXSystem sys : systems) {
        close(sys);
    }
    MergeFilter mergeFilter = new MergeFilter(system, mergedAtoms, mergedBonds);
    UIFileOpener fileOpener = new UIFileOpener(mergeFilter, this);
    if (fileOpenerThreads > 0) {
        fileOpener.setNThreads(fileOpenerThreads);
    }
    Thread thread = new Thread(fileOpener);
    thread.start();
}
Also used : ROLS(ffx.potential.bonded.ROLS) Transform3D(javax.media.j3d.Transform3D) ArrayList(java.util.ArrayList) MergeFilter(ffx.potential.parsers.MergeFilter) Atom(ffx.potential.bonded.Atom) TransformGroup(javax.media.j3d.TransformGroup) MSNode(ffx.potential.bonded.MSNode) MSRoot(ffx.potential.bonded.MSRoot) Vector3d(javax.vecmath.Vector3d) Bond(ffx.potential.bonded.Bond) File(java.io.File)

Aggregations

Transform3D (javax.media.j3d.Transform3D)12 TransformGroup (javax.media.j3d.TransformGroup)6 Vector3d (javax.vecmath.Vector3d)6 AWTEvent (java.awt.AWTEvent)2 MouseEvent (java.awt.event.MouseEvent)2 BranchGroup (javax.media.j3d.BranchGroup)2 WakeupCriterion (javax.media.j3d.WakeupCriterion)2 WakeupOnAWTEvent (javax.media.j3d.WakeupOnAWTEvent)2 Color3f (javax.vecmath.Color3f)2 Vector3f (javax.vecmath.Vector3f)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 MSNode (ffx.potential.bonded.MSNode)1 MSRoot (ffx.potential.bonded.MSRoot)1 ROLS (ffx.potential.bonded.ROLS)1 MergeFilter (ffx.potential.parsers.MergeFilter)1