Examples of PMatrix3D


Examples of processing.core.PMatrix3D

  }
 
  protected void update(BvhBone bone )
  {

      PMatrix3D m = new PMatrix3D();

      m.translate(bone.getXposition(), bone.getYposition(), bone.getZposition());
      m.translate(bone.getOffsetX(), bone.getOffsetY(), bone.getOffsetZ());
     
      m.rotateY(PApplet.radians(bone.getYrotation()));
      m.rotateX(PApplet.radians(bone.getXrotation()));
      m.rotateZ(PApplet.radians(bone.getZrotation()));
     
      bone.global_matrix = m;

      if (bone.getParent() != null && bone.getParent().global_matrix != null)
        m.preApply(bone.getParent().global_matrix);
      m.mult(new PVector(), bone.getAbsPosition());
     
      if (bone.getChildren().size() > 0)
      {
        for (BvhBone child : bone.getChildren())
        {
          update(child);
        }
      }
      else
      {
        m.translate(bone.getEndOffsetX(), bone.getEndOffsetY(), bone.getEndOffsetZ());
        m.mult(new PVector(), bone.getAbsEndPosition());
      }
  }
View Full Code Here

Examples of processing.core.PMatrix3D

  }
 
  protected void update(BvhBone bone )
  {

      PMatrix3D m = new PMatrix3D();

      m.translate(bone.getXposition(), bone.getYposition(), bone.getZposition());
      m.translate(bone.getOffsetX(), bone.getOffsetY(), bone.getOffsetZ());
     
      m.rotateY(PApplet.radians(bone.getYrotation()));
      m.rotateX(PApplet.radians(bone.getXrotation()));
      m.rotateZ(PApplet.radians(bone.getZrotation()));
     
      bone.global_matrix = m;

      if (bone.getParent() != null && bone.getParent().global_matrix != null)
        m.preApply(bone.getParent().global_matrix);
      m.mult(new PVector(), bone.getAbsPosition());
     
      if (bone.getChildren().size() > 0)
      {
        for (BvhBone child : bone.getChildren())
        {
          update(child);
        }
      }
      else
      {
        m.translate(bone.getEndOffsetX(), bone.getEndOffsetY(), bone.getEndOffsetZ());
        m.mult(new PVector(), bone.getAbsEndPosition());
      }
  }
View Full Code Here

Examples of processing.core.PMatrix3D

    g.endShape();
  }

 
  public static void flatCylinder(float r1, float r2, float len, Transform myTransform, PGraphics g) {
    PMatrix3D worldMatrix = new PMatrix3D();
    float matrixWorldScale = (float) (GLOBAL.getZOOM()*70.0f);//Where does this come from?
    List points = new ArrayList();
    //g.beginShape();

   
    g.pushMatrix();
    g.translate(0, -len/2.0f, 0);
    float screenX1 = g.screenX(0,0,0);
    float screenY1 = g.screenY(0,0,0);
    float screenZ1 = g.screenZ(0,0,0);
   


   
    g.popMatrix();
   
    g.pushMatrix();
    g.translate(0, len/2.0f, 0);
    float screenX2 = g.screenX(0,0,0);
    float screenY2 = g.screenY(0,0,0);
    float screenZ2 = g.screenZ(0,0,0);

    g.popMatrix();
   
   
    float atan = (float)Math.atan((screenY1-screenY2)/(screenX1-screenX2));

     
   
    g.pushMatrix();
    g.translate(0, -len/2.0f-0.1f, 0);

     worldMatrix = new PMatrix3D();
    g.getMatrix(worldMatrix);
    worldMatrix.m00 = matrixWorldScale;worldMatrix.m01 = 0;worldMatrix.m02 = 0;
    worldMatrix.m10 = 0;worldMatrix.m11 = matrixWorldScale;worldMatrix.m12 = 0;
    g.setMatrix(worldMatrix);
    g.rotate(atan);
    float worldX1 = g.screenX(0,0,0);
    float worldY1 = g.screenY(0,0,0);
    float worldZ1 = g.screenZ(0,0,0);
   
    g.popMatrix();
   
   
    g.pushMatrix();
    g.translate(0, len/2.0f+0.1f, 0);

     worldMatrix = new PMatrix3D();
    g.getMatrix(worldMatrix);
    worldMatrix.m00 = matrixWorldScale;worldMatrix.m01 = 0;worldMatrix.m02 = 0;
    worldMatrix.m10 = 0;worldMatrix.m11 = matrixWorldScale;worldMatrix.m12 = 0;
    g.setMatrix(worldMatrix);
    g.rotate(atan);
    float worldX2 = g.screenX(0,0,0);
    float worldY2 = g.screenY(0,0,0);
    float worldZ2 = g.screenZ(0,0,0);
   
    g.popMatrix();
   

    float worldDist =(float) Math.sqrt(Math.pow(worldX2-worldX1,2) + Math.pow(worldY2-worldY1,2)+ Math.pow(worldZ2-worldZ1,2) )/matrixWorldScale;
 
if(screenX1 < screenX2)
  atan -= (float)(Math.PI/2);
else
  atan += (float)(Math.PI/2);


    //side curve
    g.pushMatrix();
    g.translate(0, -len/2.0f-0.1f, 0);

     worldMatrix = new PMatrix3D();
    g.getMatrix(worldMatrix);
    //billboard matrix
    worldMatrix.m00 = matrixWorldScale;worldMatrix.m01 = 0;worldMatrix.m02 = 0;
    worldMatrix.m10 = 0;worldMatrix.m11 = matrixWorldScale;worldMatrix.m12 = 0;
    g.setMatrix(worldMatrix);
    g.rotate(atan);

   
   
    g.noStroke();
    g.fill(228);
    g.beginShape();
    g.vertex(-r1/2, 0,-0.1f);
    g.vertex( -r2/2, worldDist,-0.1f);
    g.vertex(r2/2, worldDist,-0.1f);
    g.vertex(r1/2, 0,-0.1f);
    g.endShape(PApplet.CLOSE);
   
    g.noFill();
    g.stroke(0);
    g.strokeWeight(2);
   
    g.line(-r1/2, 0, -r2/2, worldDist);
    g.line(r1/2,0, r2/2, worldDist);
   
   
   

   
    g.popMatrix();

   
   
   
    //Top curve
    g.pushMatrix();
    g.translate(0, -len/2.0f, 0);
    worldMatrix = new PMatrix3D();
    g.getMatrix(worldMatrix);
    //billboard matrix
    worldMatrix.m00 = matrixWorldScale;worldMatrix.m01 = 0;worldMatrix.m02 = 0;
    worldMatrix.m10 = 0;worldMatrix.m11 = matrixWorldScale;worldMatrix.m12 = 0;
    //worldMatrix.m20 = 0;worldMatrix.m21 = 0;worldMatrix.m22 = worldMatrix.m22;
    g.setMatrix(worldMatrix);
    g.rotate(atan);
   
   
    g.noStroke();
    g.fill(228);
    g.beginShape();
      for(float a=(float)(float) (Math.PI+(Math.PI/2)) ; a >= (float) (Math.PI/2); a -=0.1f) {
          g.vertex((float)(Math.sin(a)*(r1/2))+0,(float)(Math.cos(a)*(r1/2))+0,-0.1f);
    }
    g.endShape();
   
   
    g.noFill();
    g.stroke(0);
    g.strokeWeight(2);//top curve weight
    g.beginShape();
      for(float a=(float)(float) (Math.PI+(Math.PI/2)) ; a >= (float) (Math.PI/2); a -=0.1f) {
          g.vertex((float)(Math.sin(a)*(r1/2))+0,(float)(Math.cos(a)*(r1/2))+0);
          points.add(new PVector(g.modelX((float)(Math.sin(a)*(r1/2))+0,(float)(Math.cos(a)*(r1/2))+0,0),
              g.modelY((float)(Math.sin(a)*(r1/2))+0,(float)(Math.cos(a)*(r1/2))+0,0),
              g.modelZ((float)(Math.sin(a)*(r1/2))+0,(float)(Math.cos(a)*(r1/2))+0,0)));
    }
    g.endShape();
   
   
    g.strokeWeight(1);
    g.stroke(255,0,0);
    //g.ellipse(0, 0, r1,r1);
    g.popMatrix();
   
   
   
   
    //bottom curve
    g.pushMatrix();
    g.translate(0, len/2.0f, 0);

     worldMatrix = new PMatrix3D();
    g.getMatrix(worldMatrix);
    //billboard matrix
    worldMatrix.m00 = matrixWorldScale;worldMatrix.m01 = 0;worldMatrix.m02 = 0;
    worldMatrix.m10 = 0;worldMatrix.m11 = matrixWorldScale;worldMatrix.m12 = 0;
    //worldMatrix.m20 = 0;worldMatrix.m21 = 0;worldMatrix.m22 = worldMatrix.m22;
View Full Code Here

Examples of processing.core.PMatrix3D

  private List<float[]> lines;
  private List<Instruction> instructions;
 

  public SVG2PlotterTransformer() {
    draw = new PMatrix3D();
    splineForward(bezierDetail, draw);
    draw.apply(bezierBasisMatrix);
    lines = new ArrayList<float[]>(100);
    instructions = new ArrayList<Instruction>();
    prev = new float[2];
View Full Code Here

Examples of processing.core.PMatrix3D

   * (As the matrix incorporates that position, it stores every transformation, even though the matrix is created
   * anew.)
   */
  public void calculateMatrix() {
    synchronized (this) {
      PMatrix3D invMatrix = new PMatrix3D();
      invMatrix.apply(matrix);
      invMatrix.invert();

      float originalCenterX = invMatrix.multX(transformationCenter.x, transformationCenter.y);
      float originalCenterY = invMatrix.multY(transformationCenter.x, transformationCenter.y);

      matrix = new PMatrix3D();
      matrix.translate(transformationCenter.x, transformationCenter.y);
      matrix.scale(scale);
      matrix.rotateZ(angle);
      matrix.translate(-originalCenterX, -originalCenterY);
    }
View Full Code Here

Examples of processing.core.PMatrix3D

  }

  public void calculateInnerMatrix() {
    // Synchronize on this to not interfere with tile loading (see getVisibleKeys)
    synchronized (this) {
      PMatrix3D invMatrix = new PMatrix3D();
      invMatrix.apply(innerMatrix);
      invMatrix.invert();

      float originalCenterX = invMatrix.multX(innerTransformationCenter.x, innerTransformationCenter.y);
      float originalCenterY = invMatrix.multY(innerTransformationCenter.x, innerTransformationCenter.y);

      innerMatrix = new PMatrix3D();
      innerMatrix.translate(innerTransformationCenter.x, innerTransformationCenter.y);
      innerMatrix.scale(innerScale);
      innerMatrix.rotateZ(innerAngle);
      innerMatrix.translate(-originalCenterX, -originalCenterY);
    }
View Full Code Here

Examples of processing.core.PMatrix3D

      x -= offsetX;
      y -= offsetY;
    }

    float[] xyz = new float[3];
    PMatrix3D m = new PMatrix3D();
    m.apply(matrix);
    if (inverse) {
      m.invert();
    }
    m.mult(new float[] { x, y, 0 }, xyz);

    if (!inverse) {
      xyz[0] += offsetX;
      xyz[1] += offsetY;
    }
View Full Code Here

Examples of processing.core.PMatrix3D

      x -= innerOffsetX;
      y -= innerOffsetY;
    }

    float[] xyz = new float[3];
    PMatrix3D m = new PMatrix3D();
    m.apply(innerMatrix);
    if (inverse) {
      m.invert();
    }
    m.mult(new float[] { x, y, 0 }, xyz);

    if (!inverse) {
      xyz[0] += innerOffsetX;
      xyz[1] += innerOffsetY;
    }
View Full Code Here

Examples of processing.core.PMatrix3D

    Coordinate coord = getCoordinateFromInnerPosition(x, y);
    return provider.coordinateLocation(coord);
  }

  private Coordinate getCoordinateFromInnerPosition(float x, float y) {
    PMatrix3D m = new PMatrix3D();
    float tl[] = new float[3];
    m.mult(new float[] { 0, 0, 0 }, tl);
    float br[] = new float[3];
    m.mult(new float[] { TILE_WIDTH, TILE_HEIGHT, 0 }, br);

    float col = (x - tl[0]) / (br[0] - tl[0]);
    float row = (y - tl[1]) / (br[1] - tl[1]);
    Coordinate coord = new Coordinate(row, col, 0);
    return coord;
View Full Code Here

Examples of processing.core.PMatrix3D

      x -= offsetX;
      y -= offsetY;
    }

    float[] xy = new float[3];
    PMatrix3D m = new PMatrix3D();
    m.apply(matrix);
    if (inverse) {
      m.invert();
    }
    m.mult(new float[] { x, y, 0 }, xy);

    if (!inverse) {
      xy[0] += offsetX;
      xy[1] += offsetY;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.