public void scale (double scale) { Transform3D t = super.getTransform(); t.setScale(t.getScale() * scale); super.setTransform(t); }
public void scale (double scale) { Transform3D t = super.getTransform(); t.setScale(t.getScale() * scale); super.setTransform(t); }
public void setNouvelleEchelleZ(final float _echelle) { final Transform3D t3d = new Transform3D(); tg_.getTransform(t3d); final Vector3d v = new Vector3d(1, 1, _echelle); t3d.setScale(v); tg_.setTransform(t3d); calculeBBox(); }
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); }
public void setEchelleZ(final float _echelle) { final Transform3D t3d = new Transform3D(); tg_.getTransform(t3d); final Transform3D t3d2 = new Transform3D(); final Vector3d v = new Vector3d(1, 1, _echelle); t3d2.setScale(v); t3d2.mul(t3d); tg_.setTransform(t3d2); calculeBBox(); }
private void translate(float x, float y, float z) { Set<Node> alreadyConverted = new HashSet<Node>(); Transform3D t3d = new Transform3D(); t3d.setScale(scale); t3d.setTranslation(new Vector3f(x, y, z)); for (Triangle t : getGeometry()) { if (!alreadyConverted.contains(t.getNodeOne())) { t3d.transform(t.getNodeOne().getLocation()); alreadyConverted.add(t.getNodeOne()); } if (!alreadyConverted.contains(t.getNodeTwo())) { t3d.transform(t.getNodeTwo().getLocation()); alreadyConverted.add(t.getNodeTwo()); } if (!alreadyConverted.contains(t.getNodeThree())) { t3d.transform(t.getNodeThree().getLocation()); alreadyConverted.add(t.getNodeThree()); } } } }
public void setEchelleX(final float _echelle) { final Transform3D t3d = new Transform3D(); tg_.getTransform(t3d); final Transform3D t3d2 = new Transform3D(); final Vector3d v = new Vector3d(_echelle, 1, 1); t3d2.setScale(v); t3d2.mul(t3d); tg_.setTransform(t3d2); calculeBBox(); }
public void setEchelleY(final float _echelle) { final Transform3D t3d = new Transform3D(); tg_.getTransform(t3d); final Transform3D t3d2 = new Transform3D(); final Vector3d v = new Vector3d(1, _echelle, 1); t3d2.setScale(v); t3d2.mul(t3d); tg_.setTransform(t3d2); calculeBBox(); }
public void lookAt (Vector3D center, Vector3D up) { Transform3D t = getTransform(); Transform3D t2 = new Transform3D(t); Vector3f translation = new Vector3f(); t2.get(translation); Vector3d scales = new Vector3d(); t2.getScale(scales); Point3d trans = new Point3d(translation); Point3d c = new Point3d(center.x, center.y, center.z); Vector3d u = createVector3d(up); t2.lookAt(trans, c, u); try { t2.invert(); t2.setScale(scales); setTransform(t2); } catch (SingularMatrixException sme) { System.out.println("Singular matrix, bad lookAt()!"); } }
public void lookAt (Vector3D center, Vector3D up) { Transform3D t = getTransform(); Transform3D t2 = new Transform3D(t); Vector3f translation = new Vector3f(); t2.get(translation); Vector3d scales = new Vector3d(); t2.getScale(scales); Point3d trans = new Point3d(translation); Point3d c = new Point3d(center.x, center.y, center.z); Vector3d u = createVector3d(up); t2.lookAt(trans, c, u); try { t2.invert(); t2.setScale(scales); setTransform(t2); } catch (SingularMatrixException sme) { System.out.println("Singular matrix, bad lookAt()!"); } }
/** * 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); }
tt.setScale(5); TransformGroup tg = new TransformGroup(tt);
scaletx.setScale(new Vector3d(1,length,1));
tt.setScale(.05); tt.setTranslation(new Vector3f(0, 0, -30.f)); objTrans = new TransformGroup(tt);