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:KeyNavigateTest.java

protected void doMove(Vector3d theMove) {
    transformGroup.getTransform(transform3D);
    Transform3D toMove = new Transform3D();
    toMove.setTranslation(theMove);/*from  www.j  a v  a 2 s . co  m*/
    transform3D.mul(toMove);
    updateTransform();
}

From source file:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_/*www  .  j  a  v a  2 s  . c om*/
 *
 * @param pt1 _more_
 * @param xyz1 _more_
 * @param xyz2 _more_
 * @param actualPoint _more_
 * @param animateMove _more_
 */
protected void goTo(FlythroughPoint pt1, double[] xyz1, double[] xyz2, double[] actualPoint,
        boolean animateMove) {

    currentHeading = 180;
    if (actualPoint == null) {
        actualPoint = xyz2;
    }
    NavigatedDisplay navDisplay = viewManager.getNavigatedDisplay();
    MouseBehavior mouseBehavior = navDisplay.getMouseBehavior();
    double[] currentMatrix = navDisplay.getProjectionMatrix();
    double[] aspect = navDisplay.getDisplayAspect();
    try {

        if (pt1.getDescription() != null) {
            getHtmlView().setText(pt1.getDescription());
        } else {
            getHtmlView().setText("");
        }

        processReadout(pt1);

        float x1 = (float) xyz1[0];
        float y1 = (float) xyz1[1];
        float z1 = (float) xyz1[2];

        float x2 = (float) xyz2[0];
        float y2 = (float) xyz2[1];
        float z2 = (float) xyz2[2];

        double zoom = (pt1.hasZoom() ? pt1.getZoom() : getZoom());
        if (zoom == 0) {
            zoom = 0.1;
        }

        double tiltx = (pt1.hasTiltX() ? pt1.getTiltX() : tilt[0]);
        double tilty = (pt1.hasTiltY() ? pt1.getTiltY() : tilt[1]);
        double tiltz = (pt1.hasTiltZ() ? pt1.getTiltZ() : tilt[2]);

        //Check for nans
        if ((x2 != x2) || (y2 != y2) || (z2 != z2)) {
            return;
        }

        if ((x1 != x1) || (y1 != y1) || (z1 != z1)) {
            return;
        }

        double[] m = pt1.getMatrix();
        if (m == null) {
            m = new double[16];

            Transform3D t = new Transform3D();
            if (orientation.equals(ORIENT_UP)) {
                y2 = y1 + 100;
                x2 = x1;
            } else if (orientation.equals(ORIENT_DOWN)) {
                y2 = y1 - 100;
                x2 = x1;
            } else if (orientation.equals(ORIENT_LEFT)) {
                x2 = x1 - 100;
                y2 = y1;
            } else if (orientation.equals(ORIENT_RIGHT)) {
                x2 = x1 + 100;
                y2 = y1;
            }

            if ((x1 == x2) && (y1 == y2) && (z1 == z2)) {
                return;
            }

            Vector3d upVector;
            if (doGlobe()) {
                upVector = new Vector3d(x1, y1, z1);
            } else {
                upVector = new Vector3d(0, 0, 1);
            }

            //Keep flat in z for non globe
            Point3d p1 = new Point3d(x1, y1, z1);
            Point3d p2 = new Point3d(x2, y2, ((!getUseFixedZ() || doGlobe()) ? z2 : z1));
            t.lookAt(p1, p2, upVector);

            t.get(m);

            EarthLocation el1 = navDisplay.getEarthLocation(p1.x, p1.y, p1.z, false);
            EarthLocation el2 = navDisplay.getEarthLocation(p2.x, p2.y, p2.z, false);
            Bearing bearing = Bearing.calculateBearing(new LatLonPointImpl(getLat(el1), getLon(el1)),
                    new LatLonPointImpl(getLat(el2), getLon(el2)), null);
            currentHeading = bearing.getAngle();

            double[] tiltMatrix = mouseBehavior.make_matrix(tiltx, tilty, tiltz, 1.0, 1.0, 1.0, 0.0, 0.0, 0.0);
            m = mouseBehavior.multiply_matrix(tiltMatrix, m);
            if (aspect != null) {
                double[] aspectMatrix = mouseBehavior.make_matrix(0.0, 0.0, 0.0, aspect[0], aspect[1],
                        aspect[2], 0.0, 0.0, 0.0);
                //                    m = mouseBehavior.multiply_matrix(aspectMatrix, m);
            }

            double[] scaleMatrix = mouseBehavior.make_matrix(0.0, 0.0, 0.0, zoom, 0.0, 0.0, 0.0);

            m = mouseBehavior.multiply_matrix(scaleMatrix, m);
        }

        currentPoint = pt1;
        location = currentPoint.getEarthLocation();

        if (doGlobe()) {
            setPts(locationLine, 0, x1 * 2, 0, y1 * 2, 0, z1 * 2);
            //                setPts(locationLine2, 0, x2 * 2, 0, y2 * 2, 0, z2 * 2);
        } else {
            setPts(locationLine, x1, x1, y1, y1, 1, -1);
        }

        RealTuple markerLocation = new RealTuple(RealTupleType.SpatialCartesian3DTuple,
                new double[] { x1, y1, z1 });

        if (xyz1[0] != xyz2[0]) {
            Transform3D rotTransform;
            VisADGeometryArray marker = (VisADGeometryArray) getMarker().clone();
            double rotx = 0;
            double roty = 0;
            double rotz = 0;
            rotz = -Math.toDegrees(Math.atan2(actualPoint[1] - xyz1[1], actualPoint[0] - xyz1[0])) + 90;

            if (doGlobe()) {
                Vector3d upVector = new Vector3d(x1, y1, z1);
                rotTransform = new Transform3D();
                rotTransform.lookAt(new Point3d(x1, y1, z1), new Point3d(x2, y2, z2), upVector);
                Matrix3d m3d = new Matrix3d();
                rotTransform.get(m3d);
                rotTransform = new Transform3D(m3d, new Vector3d(0, 0, 0), 1);
                rotTransform.invert();
                //                    ShapeUtility.rotate(marker, rotTransform,(float)x1,(float)y1,(float)z1);
                ShapeUtility.rotate(marker, rotTransform);

            } else {
                double[] markerM = navDisplay.getMouseBehavior().make_matrix(rotx, roty, rotz, 1.0, 0.0, 0.0,
                        0.0);
                rotTransform = new Transform3D(markerM);
                ShapeUtility.rotate(marker, rotTransform);
            }

            locationMarker.setPoint(markerLocation, marker);
        } else {
            locationMarker.setPoint(markerLocation);
        }

        locationLine.setVisible(showLine);
        //            locationLine2.setVisible(showLine);
        locationMarker.setVisible(showMarker);

        if (hasTimes && getShowTimes()) {
            DateTime dttm = pt1.getDateTime();
            if (dttm != null) {
                viewManager.getAnimationWidget().setTimeFromUser(dttm);
            }

        }

        if (changeViewpointCbx.isSelected()) {
            if (animateMove) {
                navDisplay.animateMatrix(m, animationSpeed);
            } else {
                navDisplay.setProjectionMatrix(m);
            }
        }

        if (!Misc.equals(lastLocation, pt1.getEarthLocation())) {
            lastLocation = pt1.getEarthLocation();
            EarthLocationTuple tuplePosition = new EarthLocationTuple(lastLocation.getLatitude(),
                    lastLocation.getLongitude(), lastLocation.getAltitude());
            doShare(ucar.unidata.idv.control.ProbeControl.SHARE_POSITION, tuplePosition);
        }

    } catch (NumberFormatException exc) {
        logException("Error parsing number:" + exc, exc);
    } catch (javax.media.j3d.BadTransformException bte) {
        try {
            navDisplay.setProjectionMatrix(currentMatrix);
        } catch (Exception ignore) {
        }
    } catch (Exception exc) {
        logException("Error", exc);
        if (animationWidget != null) {
            animationWidget.setRunning(false);
        }
        return;
    }

}

From source file:FourByFour.java

public Positions() {

    // Define colors for lighting
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f red = new Color3f(0.9f, 0.1f, 0.2f);
    Color3f blue = new Color3f(0.3f, 0.3f, 0.8f);
    Color3f yellow = new Color3f(1.0f, 1.0f, 0.0f);
    Color3f ambRed = new Color3f(0.3f, 0.03f, 0.03f);
    Color3f ambBlue = new Color3f(0.03f, 0.03f, 0.3f);
    Color3f ambYellow = new Color3f(0.3f, 0.3f, 0.03f);
    Color3f ambWhite = new Color3f(0.3f, 0.3f, 0.3f);
    Color3f specular = new Color3f(1.0f, 1.0f, 1.0f);

    // Create the red appearance node
    redMat = new Material(ambRed, black, red, specular, 100.f);
    redMat.setLightingEnable(true);/*from  www. ja v  a2 s.c o  m*/
    redApp = new Appearance();
    redApp.setMaterial(redMat);

    // Create the blue appearance node
    blueMat = new Material(ambBlue, black, blue, specular, 100.f);
    blueMat.setLightingEnable(true);
    blueApp = new Appearance();
    blueApp.setMaterial(blueMat);

    // Create the yellow appearance node
    yellowMat = new Material(ambYellow, black, yellow, specular, 100.f);
    yellowMat.setLightingEnable(true);
    yellowApp = new Appearance();
    yellowApp.setMaterial(yellowMat);

    // Create the white appearance node
    whiteMat = new Material(ambWhite, black, white, specular, 100.f);
    whiteMat.setLightingEnable(true);
    whiteApp = new Appearance();
    whiteApp.setMaterial(whiteMat);

    // Load the point array with the offset (coordinates) for each of
    // the 64 positions.
    point = new Vector3f[64];
    int count = 0;
    for (int i = -30; i < 40; i += 20) {
        for (int j = -30; j < 40; j += 20) {
            for (int k = -30; k < 40; k += 20) {
                point[count] = new Vector3f((float) k, (float) j, (float) i);
                count++;
            }
        }
    }

    // Create the switch nodes
    posSwitch = new Switch(Switch.CHILD_MASK);
    humanSwitch = new Switch(Switch.CHILD_MASK);
    machineSwitch = new Switch(Switch.CHILD_MASK);

    // Set the capability bits
    posSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    posSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);

    humanSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    humanSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);

    machineSwitch.setCapability(Switch.ALLOW_SWITCH_READ);
    machineSwitch.setCapability(Switch.ALLOW_SWITCH_WRITE);

    // Create the bit masks
    posMask = new BitSet();
    humanMask = new BitSet();
    machineMask = new BitSet();

    // Create the small white spheres that mark unoccupied
    // positions.
    posSphere = new Sphere[64];
    for (int i = 0; i < 64; i++) {
        Transform3D transform3D = new Transform3D();
        transform3D.set(point[i]);
        TransformGroup transformGroup = new TransformGroup(transform3D);
        posSphere[i] = new Sphere(2.0f, Sphere.GENERATE_NORMALS | Sphere.ENABLE_APPEARANCE_MODIFY, 12,
                whiteApp);
        Shape3D shape = posSphere[i].getShape();
        ID id = new ID(i);
        shape.setUserData(id);
        transformGroup.addChild(posSphere[i]);
        posSwitch.addChild(transformGroup);
        posMask.set(i);
    }

    // Create the red spheres that mark the user's positions.
    for (int i = 0; i < 64; i++) {
        Transform3D transform3D = new Transform3D();
        transform3D.set(point[i]);
        TransformGroup transformGroup = new TransformGroup(transform3D);
        transformGroup.addChild(new Sphere(7.0f, redApp));
        humanSwitch.addChild(transformGroup);
        humanMask.clear(i);
    }

    // Create the blue cubes that mark the computer's positions.
    for (int i = 0; i < 64; i++) {
        Transform3D transform3D = new Transform3D();
        transform3D.set(point[i]);
        TransformGroup transformGroup = new TransformGroup(transform3D);
        BigCube cube = new BigCube(blueApp);
        transformGroup.addChild(cube.getChild());
        machineSwitch.addChild(transformGroup);
        machineMask.clear(i);
    }

    // Set the positions mask
    posSwitch.setChildMask(posMask);
    humanSwitch.setChildMask(humanMask);
    machineSwitch.setChildMask(machineMask);

    // Throw everything into a single group
    group = new Group();
    group.addChild(posSwitch);
    group.addChild(humanSwitch);
    group.addChild(machineSwitch);
}

From source file:FourByFour.java

public void newGame() {

    // Clear the board
    for (int i = 0; i < 64; i++) {
        posMask.set(i);/*from w  w  w. j  a  v  a  2 s .  c  om*/
        humanMask.clear(i);
        machineMask.clear(i);
    }
    posSwitch.setChildMask(posMask);
    humanSwitch.setChildMask(humanMask);
    machineSwitch.setChildMask(machineMask);

    // The following three lines fix a bug in J3D
    Transform3D t = new Transform3D();
    tgroup.getTransform(t);
    tgroup.setTransform(t);

    // Reset the winner flag
    winnerFlag = false;
}

From source file:FourByFour.java

public void set(int pos, int player) {

    // Stop accepting selections when the game
    // is over.//  w  ww. j  a  va 2s .c  o m
    if (winnerFlag)
        return;

    // Make sure the position is not occupied.
    if (player == HUMAN)
        if (!board.unoccupied(pos))
            return;

    // Turn off the position marker for the given position
    posMask.clear(pos);
    posSwitch.setChildMask(posMask);

    // Turn on the player marker
    if (player == Positions.HUMAN) {
        humanMask.set(pos);
        humanSwitch.setChildMask(humanMask);
        board.selection(pos, Positions.HUMAN);
    } else {
        machineMask.set(pos);
        machineSwitch.setChildMask(machineMask);
    }

    // The following three lines fix a bug in J3D
    Transform3D t = new Transform3D();
    tgroup.getTransform(t);
    tgroup.setTransform(t);
}

From source file:FourByFour.java

public void clear(int pos) {

    // Turn on the position marker
    posMask.set(pos);//from ww w .  j a  va 2  s. c om
    posSwitch.setChildMask(posMask);

    // Turn off the player marker
    humanMask.clear(pos);
    humanSwitch.setChildMask(humanMask);
    machineMask.clear(pos);
    machineSwitch.setChildMask(machineMask);

    // The following three lines are a workaround for a bug
    // in dev09 in which the transform3D of certain items are
    // not updated properly. Scheduled to be fixed in dev10
    Transform3D t = new Transform3D();
    tgroup.getTransform(t);
    tgroup.setTransform(t);
}

From source file:FourByFour.java

PickDragBehavior(Canvas2D canvas2D, Canvas3D canvas3D, Positions positions, BranchGroup branchGroup,
        TransformGroup transformGroup) {

    this.canvas2D = canvas2D;
    this.canvas3D = canvas3D;
    this.positions = positions;
    this.branchGroup = branchGroup;
    this.transformGroup = transformGroup;

    modelTrans = new Transform3D();
    transformX = new Transform3D();
    transformY = new Transform3D();

    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f green = new Color3f(0.0f, 1.0f, 0.0f);

    highlight = new Appearance();
    highlight.setMaterial(new Material(green, black, green, white, 80.f));

    parallel = true;//from   w  w  w.  j a  v a2  s .  co m
}

From source file:FourByFour.java

public void processStimulus(Enumeration criteria) {
    WakeupCriterion wakeup;//from   ww  w  .j a  v  a  2 s  . c  om
    AWTEvent[] event;
    int id;
    int dx, dy;

    while (criteria.hasMoreElements()) {
        wakeup = (WakeupCriterion) criteria.nextElement();
        if (wakeup instanceof WakeupOnAWTEvent) {
            event = ((WakeupOnAWTEvent) wakeup).getAWTEvent();
            for (int i = 0; i < event.length; i++) {
                id = event[i].getID();
                if (id == MouseEvent.MOUSE_DRAGGED) {

                    x = ((MouseEvent) event[i]).getX();
                    y = ((MouseEvent) event[i]).getY();

                    dx = x - x_last;
                    dy = y - y_last;

                    x_angle = dy * y_factor;
                    y_angle = dx * x_factor;

                    transformX.rotX(x_angle);
                    transformY.rotY(y_angle);

                    modelTrans.mul(transformX, modelTrans);
                    modelTrans.mul(transformY, modelTrans);

                    transformGroup.setTransform(modelTrans);

                    x_last = x;
                    y_last = y;
                } else if (id == MouseEvent.MOUSE_PRESSED) {

                    x = x_last = ((MouseEvent) event[i]).getX();
                    y = y_last = ((MouseEvent) event[i]).getY();

                    Point3d eyePos = new Point3d();
                    canvas3D.getCenterEyeInImagePlate(eyePos);

                    Point3d mousePos = new Point3d();
                    canvas3D.getPixelLocationInImagePlate(x, y, mousePos);

                    Transform3D transform3D = new Transform3D();
                    canvas3D.getImagePlateToVworld(transform3D);

                    transform3D.transform(eyePos);
                    transform3D.transform(mousePos);

                    Vector3d mouseVec;
                    if (parallel) {
                        mouseVec = new Vector3d(0.f, 0.f, -1.f);
                    } else {
                        mouseVec = new Vector3d();
                        mouseVec.sub(mousePos, eyePos);
                        mouseVec.normalize();
                    }

                    pickRay.set(mousePos, mouseVec);
                    sceneGraphPath = branchGroup.pickAllSorted(pickRay);

                    if (sceneGraphPath != null) {
                        for (int j = 0; j < sceneGraphPath.length; j++) {
                            if (sceneGraphPath[j] != null) {
                                Node node = sceneGraphPath[j].getObject();
                                if (node instanceof Shape3D) {
                                    try {
                                        ID posID = (ID) node.getUserData();
                                        if (posID != null) {
                                            int pos = posID.get();
                                            positions.set(pos, Positions.HUMAN);
                                            canvas2D.repaint();
                                            break;
                                        }
                                    } catch (CapabilityNotSetException e) {
                                        // Catch all CapabilityNotSet
                                        // exceptions and
                                        // throw them away, prevents
                                        // renderer from
                                        // locking up when encountering
                                        // "non-selectable"
                                        // objects.
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    wakeupOn(mouseCriterion);
}

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

private void formKeyPressed(KeyEvent evt) {
    if (lockView) {
        return;//from  ww  w  .  j  a  v a 2s  .  c o  m
    }

    double dAngle = Math.PI / 144;
    double dScale = 129. / 128.;
    if (storingFrames) {
        dAngle = Math.PI / 360;
        dScale = 513. / 512.;
    }
    if ((evt.getModifiers() & KeyEvent.CTRL_MASK) != 0) {
        dAngle = Math.PI / 2;
    }
    if ((evt.getModifiers() & KeyEvent.SHIFT_MASK) != 0) {
        dAngle = Math.PI / 6;
    }
    objRotate.getTransform(tempTransform);
    Transform3D rot = new Transform3D();
    switch (evt.getKeyCode()) {
    case KeyEvent.VK_NUMPAD5:
        reset();
        break;
    case KeyEvent.VK_DOWN:
    case KeyEvent.VK_KP_DOWN:
    case KeyEvent.VK_NUMPAD2:
        rot.rotX(dAngle);
        break;
    case KeyEvent.VK_UP:
    case KeyEvent.VK_KP_UP:
    case KeyEvent.VK_NUMPAD8:
        rot.rotX(-dAngle);
        break;
    case KeyEvent.VK_LEFT:
    case KeyEvent.VK_KP_LEFT:
    case KeyEvent.VK_NUMPAD4:
        rot.rotY(-dAngle);
        break;
    case KeyEvent.VK_RIGHT:
    case KeyEvent.VK_KP_RIGHT:
    case KeyEvent.VK_NUMPAD6:
        rot.rotY(dAngle);
        break;
    case KeyEvent.VK_PAGE_UP:
    case KeyEvent.VK_NUMPAD9:
        rot.rotZ(dAngle);
        break;
    case KeyEvent.VK_PAGE_DOWN:
    case KeyEvent.VK_NUMPAD3:
        rot.rotZ(-dAngle);
        break;
    }
    rot.mul(tempTransform);
    objRotate.setTransform(rot);

    switch (evt.getKeyCode()) {
    case KeyEvent.VK_HOME:
    case KeyEvent.VK_NUMPAD7:
        mouseScale *= dScale;
        break;
    case KeyEvent.VK_END:
    case KeyEvent.VK_NUMPAD1:
        mouseScale /= dScale;
        break;
    }
    tempTransform = new Transform3D(new Matrix3d(1., 0., 0., 0., 1., 0., 0., 0., 1.),
            //sceneCenter,
            new Vector3d(0.0, 0.0, 0.0), externScale * mouseScale);
    objScale.setTransform(tempTransform);
    switch (evt.getKeyCode()) {

    case CAMERA_UP_KEY:
        cameraUpKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_DOWN_KEY:
        cameraDownKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_LEFT_KEY:
        cameraLeftKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_RIGHT_KEY:
        cameraRightKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_FORWARD_KEY:
        cameraForwardKeyPressed = true;
        processCameraKeys(evt);
        break;
    case CAMERA_BACKWARD_KEY:
        cameraBackwardKeyPressed = true;
        processCameraKeys(evt);
        break;

    // TODO milimetr: delete the code below after testing
    case '8':
        pickObject.setPickModuleMode(1);
        break;
    case '9':
        pickObject.setPickModuleMode(2);
        break;
    case '0':
        pickObject.setPickModuleMode(3);
        break;

    default:
        break;
    }
}

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;//from  www . j  a v  a2  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);
    }

}