List of usage examples for javax.media.j3d Transform3D rotY
public void rotY(double angle)
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
private void formKeyPressed(KeyEvent evt) { if (lockView) { return;//ww w . ja v a 2s . c om } 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 ww w . ja v a2 s .co 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); } }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
public void animate(double[] params) { if (lockView) { return;/*w ww. j a v a2 s . c o m*/ } objRotate.getTransform(tempTransform); Transform3D rot = new Transform3D(); Transform3D tmp = new Transform3D(); tmp.rotX(params[0]); rot.mul(tmp); tmp.rotY(params[1]); rot.mul(tmp); tmp.rotZ(params[2]); rot.mul(tmp); rot.mul(tempTransform); objRotate.setTransform(rot); objTranslate.getTransform(rot); Vector3d trans = new Vector3d(params[3], params[4], params[5]); tmp = new Transform3D(); tmp.setTranslation(trans); rot.mul(tmp); objTranslate.setTransform(rot); mouseScale *= params[6]; 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); }