Package javax.vecmath

Examples of javax.vecmath.Vector3d


  }
 
  public Object clone() throws CloneNotSupportedException{
    TransformDataJava3d res=(TransformDataJava3d)super.clone();
    res.trans=new Transform3D();
    res.v3=new Vector3d();
    res.m3=new Matrix3f();
    res.m4=new Matrix4f();
    res.q=new Quat4f();
    return res;
  }
View Full Code Here


     */
    private Icon createIcon(BranchGroup modelNode, 
                            float pieceWidth, float pieceDepth, float pieceHeight) {
      // Add piece model scene to a normalized transform group
      Transform3D scaleTransform = new Transform3D();
      scaleTransform.setScale(new Vector3d(2 / pieceWidth, 2 / pieceHeight, 2 / pieceDepth));
      TransformGroup modelTransformGroup = new TransformGroup();
      modelTransformGroup.setTransform(scaleTransform);
      modelTransformGroup.addChild(modelNode);
      // Replace model textures by clones because Java 3D doesn't accept all the time
      // to share textures between offscreen and onscreen environments
View Full Code Here

        rotation.setRotation(new AxisAngle4f(this.floats [0], this.floats [1], this.floats [2],
            (float)Math.toRadians(floats[3])));
        mulTransformGroup(rotation);
      } else if ("scale".equals(name)) {
        Transform3D scale = new Transform3D();
        scale.setScale(new Vector3d(this.floats [0], this.floats [1], this.floats [2]));
        mulTransformGroup(scale);
      } else if ("node".equals(parent) && "translate".equals(name)) {
        Transform3D translation = new Transform3D();
        translation.setTranslation(new Vector3f(this.floats [0], this.floats [1], this.floats [2]));
        mulTransformGroup(translation);
View Full Code Here

        if (lower.x != Double.POSITIVE_INFINITY) {
          Point3d upper = new Point3d();
          bounds.getUpper(upper);
          Transform3D translation = new Transform3D();
          translation.setTranslation(
              new Vector3d(-lower.x - (upper.x - lower.x) / 2,
                  -lower.y - (upper.y - lower.y) / 2,
                  -lower.z - (upper.z - lower.z) / 2));     
          rootTransform.mul(translation);
        }
       
View Full Code Here

          bounds.getUpper(upper);
         
          // Translate model to center
          Transform3D translation = new Transform3D ();
          translation.setTranslation(
              new Vector3d(-lower.x - (upper.x - lower.x) / 2,
                           -lower.y - (upper.y - lower.y) / 2,
                           -lower.z - (upper.z - lower.z) / 2));
          // Scale model to make it fit in a 1.8 unit wide box
          Transform3D modelTransform = new Transform3D();
          modelTransform.setScale (1.8 / Math.max (Math.max (upper.x -lower.x, upper.y - lower.y),
View Full Code Here

      bounds.getUpper(upper);
   
      // Translate model to center
      Transform3D translation = new Transform3D ();
      translation.setTranslation(
          new Vector3d(-lower.x - (upper.x - lower.x) / 2,
                       -lower.y - (upper.y - lower.y) / 2,
                       -lower.z - (upper.z - lower.z) / 2));
      // Apply model rotation
      Transform3D rotationTransform = new Transform3D();
      if (modelRotation != null) {
View Full Code Here

      bounds.getUpper(upper);
     
      // Translate model to center
      Transform3D translation = new Transform3D ();
      translation.setTranslation(
          new Vector3d(-lower.x - (upper.x - lower.x) / 2,
                       -lower.y - (upper.y - lower.y) / 2,
                       -lower.z - (upper.z - lower.z) / 2));
      // Scale model to make it fill a 1 unit wide box
      Transform3D scaleOneTransform = new Transform3D();
      scaleOneTransform.setScale (
          new Vector3d(1 / Math.max(0.0001, upper.x -lower.x),
              1 / Math.max(0.0001, upper.y - lower.y),
              1 / Math.max(0.0001, upper.z - lower.z)));
      scaleOneTransform.mul(translation);
      // Apply model rotation
      Transform3D rotationTransform = new Transform3D();
      if (modelRotation != null) {
        Matrix3f modelRotationMatrix = new Matrix3f(modelRotation [0][0], modelRotation [0][1], modelRotation [0][2],
            modelRotation [1][0], modelRotation [1][1], modelRotation [1][2],
            modelRotation [2][0], modelRotation [2][1], modelRotation [2][2]);
        rotationTransform.setRotation(modelRotationMatrix);
      }
      rotationTransform.mul(scaleOneTransform);
      // Scale model to its size
      Transform3D scaleTransform = new Transform3D();
      if (width != 0 && depth != 0 && height != 0) {
        scaleTransform.setScale(new Vector3d(width, height, depth));
      }
      scaleTransform.mul(rotationTransform);
      // Scale model to make it fit in a 1.8 unit wide box     
      Transform3D modelTransform = new Transform3D();
      if (width != 0 && depth != 0 && height != 0) {
View Full Code Here

    modelBounds.getUpper(upper);
   
    // Translate model to its center
    Transform3D translation = new Transform3D();
    translation.setTranslation(
        new Vector3d(-lower.x - (upper.x - lower.x) / 2,
            -lower.y - (upper.y - lower.y) / 2,
            -lower.z - (upper.z - lower.z) / 2));     
    // Scale model to make it fill a 1 unit wide box
    Transform3D scaleOneTransform = new Transform3D();
    scaleOneTransform.setScale (
        new Vector3d(width / Math.max(MINIMUM_SIZE, upper.x -lower.x),
            width / Math.max(MINIMUM_SIZE, upper.y - lower.y),
            width / Math.max(MINIMUM_SIZE, upper.z - lower.z)));
    scaleOneTransform.mul(translation);
    Transform3D modelTransform = new Transform3D();
    if (modelRotation != null) {
View Full Code Here

    float pieceWidth = piece.getWidth();
    // If piece model is mirrored, inverse its width
    if (piece.isModelMirrored()) {
      pieceWidth *= -1;
    }
    scale.setScale(new Vector3d(pieceWidth, piece.getHeight(), piece.getDepth()));
    // Change its angle around y axis
    Transform3D orientation = new Transform3D();
    orientation.rotY(-piece.getAngle());
    orientation.mul(scale);
    // Translate it to its location
View Full Code Here

//        this.translation.addLocal(rotation.mult(in.translation).multLocal(in.scale));
//        this.rotation.multLocal(in.rotation);

        // Correctly calculate the multiplication.
        Quat4d q = new Quat4d(rotation.x, rotation.y, rotation.z, rotation.w);
        Vector3d t = new Vector3d(translation.x, translation.y, translation.z);
        Matrix4d m = new Matrix4d(q,t,scale);

        Quat4d q1 = new Quat4d(in.rotation.x, in.rotation.y, in.rotation.z, in.rotation.w);
        Vector3d t1 = new Vector3d(in.translation.x, in.translation.y, in.translation.z);
        Matrix4d m1 = new Matrix4d(q1,t1,in.scale);

        m.mul(m1);

        m.get(q);
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector3d

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.