Example usage for javax.media.j3d Transform3D Transform3D

List of usage examples for javax.media.j3d Transform3D Transform3D

Introduction

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

Prototype

public Transform3D() 

Source Link

Document

Constructs and initializes a transform to the identity matrix.

Usage

From source file:AppearanceTest.java

public void onX_30_degrees() {
    Transform3D t3d = new Transform3D();
    t3d.rotX(Math.toRadians(30));
    getTextureAttributes().setTextureTransform(t3d);
}

From source file:AppearanceTest.java

public void onY_30_degrees() {
    Transform3D t3d = new Transform3D();
    t3d.rotY(Math.toRadians(30));
    getTextureAttributes().setTextureTransform(t3d);
}

From source file:AppearanceTest.java

public void onZ_30_degrees() {
    Transform3D t3d = new Transform3D();
    t3d.rotZ(Math.toRadians(30));
    getTextureAttributes().setTextureTransform(t3d);
}

From source file:KeyNavigateTest.java

public Group createObject(Appearance app, Vector3d position, Vector3d scale, String szTextureFile,
        String szSoundFile, String szCollisionSound) {
    m_TransformGroup = new TransformGroup();
    Transform3D t3d = new Transform3D();

    t3d.setScale(scale);/* w w  w .ja  va2  s  .  c  om*/
    t3d.setTranslation(position);

    m_TransformGroup.setTransform(t3d);

    m_BehaviorTransformGroup = new TransformGroup();

    if ((m_nFlags & GEOMETRY) == GEOMETRY)
        m_BehaviorTransformGroup
                .addChild(createGeometryGroup(app, position, scale, szTextureFile, szSoundFile));

    if ((m_nFlags & SOUND) == SOUND) {
        MediaContainer media = loadSoundFile(szSoundFile);
        PointSound pointSound = new PointSound(media, getSoundInitialGain(false), 0, 0, 0);
        setSoundAttributes(pointSound, false);
        m_BehaviorTransformGroup.addChild(pointSound);
    }

    if ((m_nFlags & COLLISION) == COLLISION) {
        m_BehaviorTransformGroup.setCapability(Node.ENABLE_COLLISION_REPORTING);
        m_BehaviorTransformGroup.setCollidable(true);
        m_BehaviorTransformGroup.setCollisionBounds(getGeometryBounds());

        if ((m_nFlags & COLLISION_SOUND) == COLLISION_SOUND) {
            MediaContainer collideMedia = loadSoundFile(szCollisionSound);

            m_CollideSound = new BackgroundSound(collideMedia, 1);
            setSoundAttributes(m_CollideSound, true);
            m_TransformGroup.addChild(m_CollideSound);
        }

        CollisionBehavior collision = new CollisionBehavior(m_BehaviorTransformGroup, this);
        collision.setSchedulingBounds(getGeometryBounds());

        m_BehaviorTransformGroup.addChild(collision);
    }

    m_TransformGroup.addChild(m_BehaviorTransformGroup);
    m_ParentGroup.addChild(m_TransformGroup);

    return m_BehaviorTransformGroup;
}

From source file:KeyNavigateTest.java

public KeyBehavior(TransformGroup tg) {
    super();

    transformGroup = tg;
    transform3D = new Transform3D();
}

From source file:ffx.ui.MainPanel.java

/**
 * Merge two or more selected FSystem Nodes into one FSystem node. There are
 * a few gotchas that need to be fixed//from  ww  w . j a v  a  2  s . c o m
 *
 * @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();
}

From source file:SplineInterpolatorTest.java

protected Group createGeometryGroup(Appearance app, Vector3d position, Vector3d scale, String szTextureFile,
        String szSoundFile) {/* w w  w  .j  ava  2 s  .c  o m*/
    TransformGroup tg = new TransformGroup();

    // we need to flip the helicopter model
    // 90 degrees about the X axis
    Transform3D t3d = new Transform3D();
    t3d.rotX(Math.toRadians(-90));
    tg.setTransform(t3d);

    try {
        tg.addChild(loadGeometryGroup("heli.obj", app));

        // create an Alpha object for the Interpolator
        Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE,
                (long) Utils.getRandomNumber(0, 500), (long) Utils.getRandomNumber(0, 500),
                (long) Utils.getRandomNumber(20000, 5000), 4000, 100, (long) Utils.getRandomNumber(20000, 5000),
                5000, 50);

        attachSplinePathInterpolator(alpha, new Transform3D(),
                new URL(((Java3dApplet) m_Component).getWorkingDirectory(), "heli_spline.xls"));
    } catch (Exception e) {
        System.err.println(e.toString());
    }

    return tg;
}

From source file:KeyNavigateTest.java

protected void doRotateY(double radians) {
    transformGroup.getTransform(transform3D);
    Transform3D toMove = new Transform3D();
    toMove.rotY(radians);//w w w . ja  va2  s. c  o  m
    transform3D.mul(toMove);
    updateTransform();
}

From source file:KeyNavigateTest.java

protected void doRotateX(double radians) {
    transformGroup.getTransform(transform3D);
    Transform3D toMove = new Transform3D();
    toMove.rotX(radians);/*  ww  w. j ava  2s  .co m*/
    transform3D.mul(toMove);
    updateTransform();
}

From source file:KeyNavigateTest.java

protected void doRotateZ(double radians) {
    transformGroup.getTransform(transform3D);
    Transform3D toMove = new Transform3D();
    toMove.rotZ(radians);//  w ww .  j a  v  a  2 s  .c  o m
    transform3D.mul(toMove);
    updateTransform();
}