transform.reset(); case TRANSLATE: if (ncoords == 3) { transform.translate(args[0], args[1], args[2]); } else { transform.translate(args[0], args[1]); transform.rotate(args[0], args[1], args[2], args[3]); } else { transform.rotate(args[0]); transform.scale(args[0], args[1], args[2]); } else { transform.scale(args[0], args[1]); transform.set(args[ 0], args[ 1], args[ 2], args[ 3], args[ 4], args[ 5], args[ 6], args[ 7], args[ 8], args[ 9], args[10], args[11], args[12], args[13], args[14], args[15]); } else { transform.set(args[0], args[1], args[2], args[3], args[4], args[5]); matrix.preApply(transform); pushTransform(); if (tessellated) applyMatrixImpl(transform);
transform.reset(); case TRANSLATE: if (ncoords == 3) { transform.translate(args[0], args[1], args[2]); } else { transform.translate(args[0], args[1]); transform.rotate(args[0], args[1], args[2], args[3]); } else { transform.rotate(args[0]); transform.scale(args[0], args[1], args[2]); } else { transform.scale(args[0], args[1]); transform.set(args[ 0], args[ 1], args[ 2], args[ 3], args[ 4], args[ 5], args[ 6], args[ 7], args[ 8], args[ 9], args[10], args[11], args[12], args[13], args[14], args[15]); } else { transform.set(args[0], args[1], args[2], args[3], args[4], args[5]); matrix.apply(transform); pushTransform(); if (tessellated) applyMatrixImpl(transform);
private PMatrix getMatrix(PShape shape) { boolean useParams = true; float[] params = null; try { params = shape.getParams(); } catch (NullPointerException npe) { useParams = false; } PMatrix matrix = ((PShapeSVGExtended) shape).getMatrix(); if (matrix == null) { matrix = new PMatrix2D(); } else { // use a copy matrix = matrix.get(); } if (useParams) { matrix.translate(params[0], params[1]); } // is root. if (shape.getParent() == null) { return matrix; } PMatrix2D parentMat = (PMatrix2D) getMatrix(shape.getParent()); matrix.preApply(parentMat); return matrix; }
/** * @param z forward/back translation */ public void translate(float x, float y, float z) { checkMatrix(3); matrix.translate(x, y, z); }
@Override public void resetMatrix() { if (shapeCreated && matrix != null && transformStack != null) { if (family == GROUP) { updateTessellation(); } if (tessellated) { PMatrix mat = popTransform(); while (mat != null) { boolean res = mat.invert(); if (res) { applyMatrixImpl(mat); } else { PGraphics.showWarning("Transformation applied on the shape cannot be inverted"); } mat = popTransform(); } } matrix.reset(); transformStack.clear(); } }
/** * @param x percentage to scale the object in the x-axis * @param y percentage to scale the object in the y-axis * @param z percentage to scale the object in the z-axis */ public void scale(float x, float y, float z) { checkMatrix(3); matrix.scale(x, y, z); }
public void applyMatrix(float n00, float n01, float n02, float n10, float n11, float n12) { checkMatrix(2); matrix.apply(n00, n01, n02, n10, n11, n12); }
matrix.rotate(angle);
protected void pushTransform() { if (transformStack == null) transformStack = new Stack<PMatrix>(); PMatrix mat; if (transform instanceof PMatrix2D) { mat = new PMatrix2D(); } else { mat = new PMatrix3D(); } mat.set(transform); transformStack.push(mat); }
/** * ( begin auto-generated from PShape_resetMatrix.xml ) * * Replaces the current matrix of a shape with the identity matrix. The * equivalent function in OpenGL is glLoadIdentity(). * * ( end auto-generated ) * @webref pshape:method * @brief Replaces the current matrix of a shape with the identity matrix * @usage web_application * @see PShape#rotate(float) * @see PShape#scale(float) * @see PShape#translate(float, float) */ public void resetMatrix() { checkMatrix(2); matrix.reset(); }
/** * @param tz forward/back translation */ public void translate(float x, float y, float z) { checkMatrix(3); matrix.translate(x, y, z); }
@Override public void resetMatrix() { if (shapeCreated && matrix != null && transformStack != null) { if (family == GROUP) { updateTessellation(); } if (tessellated) { PMatrix mat = popTransform(); while (mat != null) { boolean res = mat.invert(); if (res) { applyMatrixImpl(mat); } else { PGraphics.showWarning("Transformation applied on the shape cannot be inverted"); } mat = popTransform(); } } matrix.reset(); transformStack.clear(); } }
/** * @param x percentage to scale the object in the x-axis * @param y percentage to scale the object in the y-axis * @param z percentage to scale the object in the z-axis */ public void scale(float x, float y, float z) { checkMatrix(3); matrix.scale(x, y, z); }
public void applyMatrix(float n00, float n01, float n02, float n10, float n11, float n12) { checkMatrix(2); matrix.apply(n00, n01, n02, n10, n11, n12); }
/** * @nowebref */ public void rotate(float angle, float v0, float v1, float v2) { checkMatrix(3); float norm2 = v0 * v0 + v1 * v1 + v2 * v2; if (Math.abs(norm2 - 1) > EPSILON) { // The rotation vector is not normalized. float norm = PApplet.sqrt(norm2); v0 /= norm; v1 /= norm; v2 /= norm; } matrix.rotate(angle, v0, v1, v2); }
protected void pushTransform() { if (transformStack == null) transformStack = new Stack<PMatrix>(); PMatrix mat; if (transform instanceof PMatrix2D) { mat = new PMatrix2D(); } else { mat = new PMatrix3D(); } mat.set(transform); transformStack.push(mat); }
/** * ( begin auto-generated from PShape_resetMatrix.xml ) * * Replaces the current matrix of a shape with the identity matrix. The * equivalent function in OpenGL is glLoadIdentity(). * * ( end auto-generated ) * @webref pshape:method * @brief Replaces the current matrix of a shape with the identity matrix * @usage web_application * @see PShape#rotate(float) * @see PShape#scale(float) * @see PShape#translate(float, float) */ public void resetMatrix() { checkMatrix(2); matrix.reset(); }
/** * ( begin auto-generated from PShape_translate.xml ) * * Specifies an amount to displace the shape. The <b>x</b> parameter * specifies left/right translation, the <b>y</b> parameter specifies * up/down translation, and the <b>z</b> parameter specifies translations * toward/away from the screen. Subsequent calls to the method accumulates * the effect. For example, calling <b>translate(50, 0)</b> and then * <b>translate(20, 0)</b> is the same as <b>translate(70, 0)</b>. This * transformation is applied directly to the shape, it's not refreshed each * time <b>draw()</b> is run. * <br /><br /> * Using this method with the <b>z</b> parameter requires using the P3D * parameter in combination with size. * * ( end auto-generated ) * @webref pshape:method * @usage web_application * @brief Displaces the shape * @param tx left/right translation * @param ty up/down translation * @see PShape#rotate(float) * @see PShape#scale(float) * @see PShape#resetMatrix() */ public void translate(float x, float y) { checkMatrix(2); matrix.translate(x, y); }
public void scale(float x, float y) { checkMatrix(2); matrix.scale(x, y); }