List of usage examples for javax.media.j3d Transform3D rotX
public void rotX(double angle)
From source file:SplineInterpolatorTest.java
protected Group createGeometryGroup(Appearance app, Vector3d position, Vector3d scale, String szTextureFile, String szSoundFile) {/*from w w w . jav a 2 s.co 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:ExSound.java
private Group buildTumblingBox(float width, float height, float depth, Appearance app, int xDur, int yDur, int zDur) { BoundingSphere worldBounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), // Center 1000.0); // Extent // Build a box to tumble Shape3D box = buildBox(width, height, depth, app); // Build a set of nested transform groups. Attach // to each one a behavior that rotates around an X, // Y, or Z axis. Use different rotation speeds for // each axis to create a tumbling effect. TransformGroup outerGroup = new TransformGroup(); outerGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D yAxis = new Transform3D(); Alpha alpha = new Alpha(-1, // loop count: -1 = forever Alpha.INCREASING_ENABLE, // increasing 0, // trigger time: 0 = now 0, // delay: 0 = none xDur, // increasing duration 0, // increasing ramp duration 0, // at one (sustain) duration 0, // decreasing duration 0, // decreasing ramp duration 0); // at zero duration RotationInterpolator rot = new RotationInterpolator(alpha, // Alpha // control outerGroup, // Target transform group yAxis, // Y axis rotation 0.0f, // Minimum angle 2.0f * (float) Math.PI);// Maximum angle rot.setSchedulingBounds(worldBounds); outerGroup.addChild(rot);/*from w ww . j a v a 2 s. c o m*/ TransformGroup middleGroup = new TransformGroup(); middleGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D xAxis = new Transform3D(); xAxis.rotZ(-1.571f); alpha = new Alpha(-1, // loop count: -1 = forever Alpha.INCREASING_ENABLE, // increasing 0, // trigger time: 0 = now 0, // delay: 0 = none yDur, // increasing duration 0, // increasing ramp duration 0, // at one (sustain) duration 0, // decreasing duration 0, // decreasing ramp duration 0); // at zero duration rot = new RotationInterpolator(alpha, // Alpha control middleGroup, // Target transform group xAxis, // Y axis rotation 0.0f, // Minimum angle 2.0f * (float) Math.PI);// Maximum angle rot.setSchedulingBounds(worldBounds); middleGroup.addChild(rot); outerGroup.addChild(middleGroup); TransformGroup innerGroup = new TransformGroup(); innerGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Transform3D zAxis = new Transform3D(); zAxis.rotX(1.571f); alpha = new Alpha(-1, // loop count: -1 = forever Alpha.INCREASING_ENABLE, // increasing 0, // trigger time: 0 = now 0, // delay: 0 = none zDur, // increasing duration 0, // increasing ramp duration 0, // at one (sustain) duration 0, // decreasing duration 0, // decreasing ramp duration 0); // at zero duration rot = new RotationInterpolator(alpha, // Alpha control innerGroup, // Target transform group zAxis, // Y axis rotation 0.0f, // Minimum angle 2.0f * (float) Math.PI);// Maximum angle rot.setSchedulingBounds(worldBounds); innerGroup.addChild(rot); middleGroup.addChild(innerGroup); innerGroup.addChild(box); return outerGroup; }
From source file:pl.edu.icm.visnow.geometries.viewer3d.Display3DPanel.java
private void formKeyPressed(KeyEvent evt) { if (lockView) { return;// www . j a v a 2 s . 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;// www .j ava2s .c om 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 w w . j a v a2s. com*/ } 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); }