List of usage examples for javax.media.j3d Transform3D setEuler
public final void setEuler(Vector3d euler)
From source file:ScenegraphTest.java
private TransformGroup createArm(double rotX, double rotY, double rotZ) { TransformGroup tgShoulder = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setEuler(new Vector3d(rotX, rotY, rotZ)); tgShoulder.setTransform(t3d);/*from w w w. java 2 s. com*/ TransformGroup tgParent = null; tgParent = addLimb(tgShoulder, "Upper Arm", 0.05, 0.5, 0.0, 0.0); tgParent = addLimb(tgParent, "Lower Arm", 0.03, 0.4, Math.PI * -0.5, Math.PI * 0.8); TransformGroup tgWrist = addLimb(tgParent, "Wrist", 0.03, 0.07, 0.0, Math.PI * 0.5); addLimb(tgWrist, "Thumb", 0.01, 0.05, 0.0, Math.PI * 0.5); addLimb(tgWrist, "Finger 1", 0.01, 0.08, 0.0, Math.PI * 0.3); addLimb(tgWrist, "Finger 2", 0.01, 0.10, 0.0, Math.PI * 0.3); addLimb(tgWrist, "Finger 3", 0.01, 0.08, 0.0, Math.PI * 0.3); addLimb(tgWrist, "Finger 4", 0.01, 0.05, 0.0, Math.PI * 0.3); return tgShoulder; }
From source file:PlatformTest.java
ViewerAvatar createViewerAvatar(String szText, Color3f objColor) { ViewerAvatar viewerAvatar = new ViewerAvatar(); // rotate the Cone so that it is lying down and // points sharp-end towards the Viewer's field of view. TransformGroup tg = new TransformGroup(); Transform3D t3d = new Transform3D(); t3d.setEuler(new Vector3d(Math.PI / 2.0, Math.PI, 0)); tg.setTransform(t3d);/*w w w. j a v a 2 s . co m*/ // create appearance and material for the Cone Appearance app = new Appearance(); Color3f black = new Color3f(0.4f, 0.2f, 0.1f); app.setMaterial(new Material(objColor, black, objColor, black, 90.0f)); // create the Primitive and add to the parent BranchGroup tg.addChild(new Cone(1, 3, Primitive.GENERATE_NORMALS, app)); viewerAvatar.addChild(tg); return viewerAvatar; }
From source file:MouseNavigateTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); // note that we are creating a TG *above* the TG // the is being controlled by the mouse behaviors. // The SUN mouse translate behavior would fail in this // instance as all movement would be in the X-Y plane // irrespective of any TG above the object. // The TornadoMouseTranslate behavior always moves an object // parrallel to the image plane TransformGroup objTrans1 = new TransformGroup(); Transform3D t3d = new Transform3D(); objTrans1.getTransform(t3d);/* w w w.j ava 2s. c o m*/ t3d.setEuler(new Vector3d(0.9, 0.8, 0.3)); objTrans1.setTransform(t3d); TransformGroup objTrans = new TransformGroup(); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // create the mouse scale behavior and set limits TornadoMouseScale mouseScale = new TornadoMouseScale(5, 0.1f); mouseScale.setMinScale(new Point3d(0.5, 0.5, 0.5)); mouseScale.setMaxScale(new Point3d(2, 2, 2)); mouseScale.setObject(objTrans); mouseScale.setChangeListener(this); mouseScale.setSchedulingBounds(getApplicationBounds()); objTrans.addChild(mouseScale); // create the mouse rotate behavior TornadoMouseRotate mouseRotate = new TornadoMouseRotate(0.001, 0.001); mouseRotate.setInvert(true); mouseRotate.setObject(objTrans); mouseRotate.setChangeListener(this); mouseRotate.setSchedulingBounds(getApplicationBounds()); objTrans.addChild(mouseRotate); // create the mouse translate behavior and set limits TornadoMouseTranslate mouseTrans = new TornadoMouseTranslate(0.005f); mouseTrans.setObject(objTrans); mouseTrans.setChangeListener(this); mouseTrans.setMinTranslate(new Point3d(-4, -4, -4)); mouseTrans.setMaxTranslate(new Point3d(4, 4, 4)); mouseTrans.setSchedulingBounds(getApplicationBounds()); objTrans.addChild(mouseTrans); objTrans.addChild(new ColorCube(0.5)); // create some axis for the world to show it has been rotated ColorCube axis = new ColorCube(5.0); Appearance app = new Appearance(); app.setPolygonAttributes( new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0)); axis.setAppearance(app); objTrans1.addChild(axis); objTrans1.addChild(objTrans); objRoot.addChild(objTrans1); return objRoot; }
From source file:AppearanceTest.java
protected BranchGroup createSceneBranchGroup() { BranchGroup objRoot = super.createSceneBranchGroup(); TransformGroup zoomTg = new TransformGroup(); zoomTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); zoomTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // attach a navigation behavior to the position of the viewer KeyNavigatorBehavior key = new KeyNavigatorBehavior(zoomTg); key.setSchedulingBounds(createApplicationBounds()); key.setEnable(true);/*from w w w . j av a 2s . c o m*/ objRoot.addChild(key); // create a TransformGroup to flip the hand onto its end and enlarge it. TransformGroup objTrans1 = new TransformGroup(); Transform3D tr = new Transform3D(); objTrans1.getTransform(tr); tr.setEuler(new Vector3d(0.5 * Math.PI, 0.6, 0)); objTrans1.setTransform(tr); // Set up the global lights Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f); Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f); Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); AmbientLight aLgt = new AmbientLight(alColor); aLgt.setInfluencingBounds(getApplicationBounds()); DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1); lgt1.setInfluencingBounds(getApplicationBounds()); objRoot.addChild(aLgt); objRoot.addChild(lgt1); int nScale = 50; Box box = new Box(nScale, nScale, nScale, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS, m_Appearance); Shape3D frontFace = box.getShape(Box.LEFT); // create a new left face so we can // assign per-vertex colors GeometryArray geometry = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.NORMALS | GeometryArray.COLOR_4 | GeometryArray.TEXTURE_COORDINATE_2); nScale = 40; final float[] verts = { // left face -1.0f * nScale, -1.0f * nScale, 1.0f * nScale, -1.0f * nScale, 1.0f * nScale, 1.0f * nScale, -1.0f * nScale, 1.0f * nScale, -1.0f * nScale, -1.0f * nScale, -1.0f * nScale, -1.0f * nScale }; final float[] colors = { // left face 1, 0, 0, 0, 0, 1, 0, 0.2f, 0, 0, 1, 0.8f, 0, 0, 0, 1, }; float[] tcoords = { // left 1, 0, 1, 1, 0, 1, 0, 0 }; Vector3f normalVector = new Vector3f(-1.0f, 0.0f, 0.0f); geometry.setColors(0, colors, 0, 4); for (int n = 0; n < 4; n++) geometry.setNormal(n, normalVector); geometry.setTextureCoordinates(0, tcoords, 0, 4); geometry.setCoordinates(0, verts); frontFace.setGeometry(geometry); // connect the scenegraph objTrans1.addChild(box); zoomTg.addChild(objTrans1); objRoot.addChild(zoomTg); return objRoot; }