Example usage for javax.media.j3d TransformGroup getTransform

List of usage examples for javax.media.j3d TransformGroup getTransform

Introduction

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

Prototype

public void getTransform(Transform3D t1) 

Source Link

Document

Copies the transform component of this TransformGroup into the passed transform object.

Usage

From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java

private void processCameraKeys(KeyEvent evt) {
    double dAngle = Math.PI / 144;
    double dScale = 129. / 128.;
    if (storingFrames) {
        dAngle = Math.PI / 360;// w  ww. j a  va2 s  . c  o  m
        dScale = 513. / 512.;
    }
    if ((evt.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
        dAngle = Math.PI / 2;
    }

    TransformGroup cam = universe.getViewingPlatform().getViewPlatformTransform();
    Transform3D camTr;
    Transform3D cRot;
    Transform3D tmpTr;
    Vector3d cMov;

    if (cameraUpKeyPressed) {
        camTr = new Transform3D();
        cam.getTransform(camTr);
        cRot = new Transform3D();
        cRot.rotX(-dAngle);
        camTr.mul(cRot);
        cam.setTransform(camTr);
    }

    if (cameraDownKeyPressed) {
        camTr = new Transform3D();
        cam.getTransform(camTr);
        cRot = new Transform3D();
        cRot.rotX(dAngle);
        camTr.mul(cRot);
        cam.setTransform(camTr);
    }

    if (cameraRightKeyPressed) {
        camTr = new Transform3D();
        cam.getTransform(camTr);
        cRot = new Transform3D();
        cRot.rotY(-dAngle);
        camTr.mul(cRot);
        cam.setTransform(camTr);
    }

    if (cameraLeftKeyPressed) {
        camTr = new Transform3D();
        cam.getTransform(camTr);
        cRot = new Transform3D();
        cRot.rotY(dAngle);
        camTr.mul(cRot);
        cam.setTransform(camTr);
    }

    if (cameraForwardKeyPressed) {
        camTr = new Transform3D();
        cam.getTransform(camTr);
        cMov = new Vector3d();
        cMov.x = 0;
        cMov.y = 0;
        cMov.z = -(dScale / 50);

        tmpTr = new Transform3D();
        cam.getTransform(tmpTr);
        tmpTr.set(new Vector3d());
        tmpTr.transform(cMov);

        tmpTr.set(cMov);
        camTr.mul(tmpTr);
        cam.setTransform(camTr);
    }

    if (cameraBackwardKeyPressed) {
        camTr = new Transform3D();
        cam.getTransform(camTr);
        cMov = new Vector3d();
        cMov.x = 0;
        cMov.y = 0;
        cMov.z = (dScale / 50);

        tmpTr = new Transform3D();
        cam.getTransform(tmpTr);
        tmpTr.set(new Vector3d());
        tmpTr.transform(cMov);

        tmpTr.set(cMov);
        camTr.mul(tmpTr);
        cam.setTransform(camTr);
    }

}