public void setOrientation (Vector3D angles) { if (Math.abs(angles.y) == 90) System.err.println("Gimbal lock when the y-angle is vertical!"); Transform3D t = getTransform(); Vector3D radians = angles.times(Math.PI / 180.); Transform3D t1 = new Transform3D(); t1.setEuler(createVector3d(radians)); Vector3d r = new Vector3d(); t.get(r); t1.setTranslation(r); t1.setScale(t.getScale()); setTransform(t1); }
public void setOrientation (Vector3D angles) { if (Math.abs(angles.y) == 90) System.err.println("Gimbal lock when the y-angle is vertical!"); Transform3D t = getTransform(); Vector3D radians = angles.times(Math.PI / 180.); Transform3D t1 = new Transform3D(); t1.setEuler(createVector3d(radians)); Vector3d r = new Vector3d(); t.get(r); t1.setTranslation(r); t1.setScale(t.getScale()); setTransform(t1); }
/** * Draws a 3D text object at (x, y, z) with Euler rotation angles (xA, yA, zA). * Uses the pen font, color, and transparency. */ public static Shape text3D (double x, double y, double z, String text, double xA, double yA, double zA) { Line2D.Double line = new Line2D.Double(0, 0, TEXT3D_DEPTH, 0); FontExtrusion extrudePath = new FontExtrusion(line); Font3D font3D = new Font3D(font, extrudePath); Point3d pos = new Point3d(x, y, z); javax.media.j3d.Text3D t = new javax.media.j3d.Text3D(font3D, text, createPoint3f(x, y, z)); // FIX THIS TO NOT HAVE SCALE INCLUDED Transform3D shrinker = new Transform3D(); shrinker.setEuler(new Vector3d(xA, yA, zA)); shrinker.setTranslation(new Vector3d(x, y, z)); shrinker.setScale(TEXT3D_SHRINK_FACTOR); Shape3D shape = createShape3D((Geometry)t); return shape(shape, true, shrinker, false); }
/** * Draws a 3D text object at (x, y, z) with Euler rotation angles (xA, yA, zA). * Uses the pen font, color, and transparency. */ public static Shape text3D (double x, double y, double z, String text, double xA, double yA, double zA) { Line2D.Double line = new Line2D.Double(0, 0, TEXT3D_DEPTH, 0); FontExtrusion extrudePath = new FontExtrusion(line); Font3D font3D = new Font3D(font, extrudePath); Point3d pos = new Point3d(x, y, z); javax.media.j3d.Text3D t = new javax.media.j3d.Text3D(font3D, text, createPoint3f(x, y, z)); // FIX THIS TO NOT HAVE SCALE INCLUDED Transform3D shrinker = new Transform3D(); shrinker.setEuler(new Vector3d(xA, yA, zA)); shrinker.setTranslation(new Vector3d(x, y, z)); shrinker.setScale(TEXT3D_SHRINK_FACTOR); Shape3D shape = createShape3D((Geometry)t); return shape(shape, true, shrinker, false); }
/** * Draws a Java 3D Primitive object at (x, y, z) with axial rotations (xA, yA, zA). */ private static Shape primitive (Primitive shape, double x, double y, double z, Vector3d angles, Vector3d scales) { shape.setCapability(Primitive.ENABLE_APPEARANCE_MODIFY); shape.setPickable(false); shape.setCollidable(false); TransformGroup tgScale = createTransformGroup(); Transform3D scaleTransform = new Transform3D(); if (scales != null) scaleTransform.setScale(scales); tgScale.setTransform(scaleTransform); tgScale.addChild(shape); TransformGroup tgShape = createTransformGroup(); Transform3D transform = new Transform3D(); if (angles != null) { angles.scale(Math.PI / 180); transform.setEuler( angles); } Vector3f vector = createVector3f(x, y, z); transform.setTranslation(vector); tgShape.setTransform(transform); tgShape.addChild(tgScale); BranchGroup bg = createBranchGroup(); bg.addChild(tgShape); offscreenGroup.addChild(bg); return new Shape(bg, tgShape); }
/** * Draws a Java 3D Primitive object at (x, y, z) with axial rotations (xA, yA, zA). */ private static Shape primitive (Primitive shape, double x, double y, double z, Vector3d angles, Vector3d scales) { shape.setCapability(Primitive.ENABLE_APPEARANCE_MODIFY); shape.setPickable(false); shape.setCollidable(false); TransformGroup tgScale = createTransformGroup(); Transform3D scaleTransform = new Transform3D(); if (scales != null) scaleTransform.setScale(scales); tgScale.setTransform(scaleTransform); tgScale.addChild(shape); TransformGroup tgShape = createTransformGroup(); Transform3D transform = new Transform3D(); if (angles != null) { angles.scale(Math.PI / 180); transform.setEuler( angles); } Vector3f vector = createVector3f(x, y, z); transform.setTranslation(vector); tgShape.setTransform(transform); tgShape.addChild(tgScale); BranchGroup bg = createBranchGroup(); bg.addChild(tgShape); offscreenGroup.addChild(bg); return new Shape(bg, tgShape); }