Search in sources :

Example 16 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.

the class DCCarpetFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    /* dc_carpet by Xyrus02, http://apophysis-7x.org/extensions */
    int x0 = (pContext.random() < 0.5) ? -1 : 1;
    int y0 = (pContext.random() > 0.5) ? -1 : 1;
    double x = pAffineTP.x + x0, y = pAffineTP.y + y0;
    double x0_xor_y0 = (double) (x0 ^ y0);
    double h = -H + (1 - x0_xor_y0) * H;
    pVarTP.x += pAmount * (pXForm.getXYCoeff00() * x + pXForm.getXYCoeff10() * y + pXForm.getXYCoeff20());
    pVarTP.y += pAmount * (pXForm.getXYCoeff01() * x + pXForm.getXYCoeff11() * y + pXForm.getXYCoeff21());
    pVarTP.color = fmod(fabs(pVarTP.color * 0.5 * (1 + h) + x0_xor_y0 * (1 - h) * 0.5), 1.0);
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 17 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.

the class IconAttractorFunc method transform.

public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    // Reference:
    // https://softologyblog.wordpress.com/2017/03/04/2d-strange-attractors/
    double x, y;
    double zzbar = sqr(pAffineTP.x) + sqr(pAffineTP.y);
    double p = a * zzbar + l;
    double zreal = pAffineTP.x;
    double zimag = pAffineTP.y;
    for (int i = 1; i <= degree - 2; i++) {
        double za = zreal * pAffineTP.x - zimag * pAffineTP.y;
        double zb = zimag * pAffineTP.x + zreal * pAffineTP.y;
        zreal = za;
        zimag = zb;
    }
    double zn = pAffineTP.x * zreal - pAffineTP.y * zimag;
    p = p + b * zn;
    x = p * pAffineTP.x + g * zreal - o * pAffineTP.y;
    y = p * pAffineTP.y - g * zimag + o * pAffineTP.x;
    pVarTP.x = x * pAmount;
    pVarTP.y = y * pAmount;
    pVarTP.color = fmod(fabs(bdcs * (sqr(pVarTP.x + centerx) + sqr(pVarTP.y + centery))), 1.0);
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 18 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.

the class InversionFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    double xin = pAffineTP.x;
    double yin = pAffineTP.y;
    double zin = pAffineTP.z;
    XYZPoint srcPoint, dstPoint;
    srcPoint = pAffineTP;
    dstPoint = pVarTP;
    double iscale;
    if (draw_guides && guides_enabled) {
        double rnd = pContext.random();
        double theta = rnd * shape.getPeriod();
        double split = pContext.random() * 1.1;
        if (split < 1) {
            if (ring_mode == IGNORE_RING) {
                shape.getCurvePoint(theta, curve_point);
                pVarTP.x += curve_point.x;
                pVarTP.y += curve_point.y;
            } else {
                if (split < 0.5) {
                    shape.getCurvePoint(theta, curve_point);
                    pVarTP.x += curve_point.x;
                    pVarTP.y += curve_point.y;
                } else if (split < 0.75) {
                    // draw ring_rmin
                    pVarTP.x += ring_rmin * cos(theta);
                    pVarTP.y += ring_rmin * sin(theta);
                } else {
                    pVarTP.x += ring_rmax * cos(theta);
                    pVarTP.y += ring_rmax * sin(theta);
                // draw ring_rmax
                }
            }
        } else {
        // no-op, leave 10% at shape origin
        }
        return;
    }
    if (draw_shape > 0) {
        double rnd = pContext.random();
        if (rnd < draw_shape) {
            double theta = pContext.random() * shape.getPeriod();
            shape.getCurvePoint(theta, curve_point);
            pVarTP.x += curve_point.x;
            pVarTP.y += curve_point.y;
            if (shape_thickness != 0) {
                pVarTP.x += 0.01 * (pContext.random() - 0.5) * shape_thickness;
                pVarTP.y += 0.01 * (pContext.random() - 0.5) * shape_thickness;
            }
            return;
        }
    }
    if (passthrough > 0) {
        double rnd = pContext.random();
        if (rnd < passthrough) {
            pVarTP.x += xin;
            pVarTP.y += yin;
            return;
        }
    }
    // to do generalized inversion of input point P,
    // need two other points:
    // O, the origin of inversion
    // S, the intersection of the line OP and the boundary of the shape
    // then output point P' = O + (d1(O,B)^2/d2(O,P)^2) * (P - O)
    // where d1 and d2 are distance metric functions
    double tin = atan2(yin, xin);
    double rin = sqrt(xin * xin + yin * yin);
    boolean do_inversion;
    shape.getMaxCurvePoint(tin, curve_point);
    double rcurve = curve_point.r;
    double xcurve = curve_point.x;
    double ycurve = curve_point.y;
    if (inversion_mode == EXTERNAL_INVERSION_ONLY) {
        // only do inversion if input point is outside of circle
        do_inversion = rin > rcurve;
    } else if (inversion_mode == INTERNAL_INVERSION_ONLY) {
        // only do inversion if input point is inside of circle
        do_inversion = rin < rcurve;
    } else {
        // default to STANDARD mode ==> always do inversion
        do_inversion = true;
    }
    // if outside of curve radius, make sure is < ring_max (based on inversion of ring_min)
    if (do_inversion && (ring_mode != IGNORE_RING) && (ring_scale != 1)) {
        if (ring_mode == INVERSION_INSIDE_RING_ONLY) {
            do_inversion = (rin >= ring_rmin) && (rin <= ring_rmax);
        } else if (ring_mode == INVERSION_OUTSIDE_RING_ONLY) {
            do_inversion = (rin <= ring_rmin) || (rin >= ring_rmax);
        }
    }
    if (do_inversion) {
        double num_scale = rcurve * rcurve;
        double denom_scale;
        if (pnorm_shape == 2 && pnorm_smod == 1) {
            num_scale = sqr(rcurve);
        } else {
            num_scale = pow((pow(abs(xcurve), pnorm_shape) + pow(abs(ycurve), pnorm_shape)), 2.0 / (pnorm_shape * pnorm_smod));
        }
        if (pnorm_point == 2 && pnorm_pmod == 1) {
            denom_scale = sqr(xin) + sqr(yin);
        } else {
            denom_scale = pow((pow(abs(xin), pnorm_point) + pow(abs(yin), pnorm_point)), 2.0 / (pnorm_point * pnorm_pmod));
        }
        iscale = num_scale / denom_scale;
        double xout = iscale * xin;
        double yout = iscale * yin;
        pVarTP.x += pAmount * xout;
        pVarTP.y += pAmount * yout;
        if (pContext.isPreserveZCoordinate()) {
            pVarTP.z += pAmount * zin;
        }
        pVarTP.doHide = false;
        setColor(srcPoint, dstPoint, curve_point, pAmount);
    } else {
        // if didn't do inversion, check to see if should hide
        pVarTP.x += xin;
        pVarTP.y += yin;
        if (pContext.isPreserveZCoordinate()) {
            pVarTP.z += zin;
        }
        pVarTP.doHide = hide_uninverted;
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 19 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.

the class Hexnix3DFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    /* hexnix3D by Larry Berlin, http://aporev.deviantart.com/art/3D-Plugins-Collection-One-138514007?q=gallery%3Aaporev%2F8229210&qo=15 */
    if (_fcycle > 5) {
        // Resets the cyclic counting
        _fcycle = 0;
        // Chooses new 6 or 3 nodes
        _rswtch = (int) trunc(pContext.random() * 3.0);
    }
    if (_bcycle > 2) {
        _bcycle = 0;
        // Chooses new 6 or 3 nodes
        _rswtch = (int) trunc(pContext.random() * 3.0);
    }
    // Sets hexagon length radius - major plane
    double lrmaj = pAmount;
    double smooth = 1.0;
    double smRotxTP = 0.0;
    double smRotyTP = 0.0;
    double smRotxFT = 0.0;
    double smRotyFT = 0.0;
    double gentleZ = 0.0;
    if (fabs(pAmount) <= 0.5) {
        smooth = pAmount * 2.0;
    } else {
        smooth = 1.0;
    }
    // Boost is the separation distance between the two planes
    double boost = 0.0;
    int posNeg = 1;
    int loc60;
    int loc120;
    double scale = this.scale;
    double scale3 = this._3side;
    if (pContext.random() < 0.5) {
        posNeg = -1;
    }
    // Determine whether one or two major planes
    int majplane = 0;
    double abmajp = fabs(this.majp);
    if (abmajp <= 1.0) {
        // 0= 1 plate active  1= transition to two plates active  2= defines two plates
        majplane = 0;
        boost = 0.0;
    } else if (abmajp > 1.0 && abmajp < 2.0) {
        majplane = 1;
        boost = 0.0;
    } else {
        majplane = 2;
        // distance above and below XY plane
        boost = (abmajp - 2.0) * 0.5;
    }
    // Creating Z factors relative to the planes
    if (majplane == 0) {
        // single plate instructions
        pVarTP.z += smooth * pAffineTP.z * scale * this.zlift;
    } else if (majplane == 1 && this.majp < 0.0) {
        // Transition for reversing plates  because  majp is negative value
        if (this.majp < -1.0 && this.majp >= -2.0) {
            // Set transition smoothing values  0.00001 to 1.0
            gentleZ = (abmajp - 1.0);
        } else {
            // full effect explicit default value
            gentleZ = 1.0;
        }
        // Begin reverse transition - starts with pVarTP.z==pVarTP.z proceeds by gradual negative
        if (posNeg < 0) {
            // gradually grows negative plate, in place, no boost,
            pVarTP.z += -2.0 * (pVarTP.z * gentleZ);
        }
    }
    if (majplane == 2 && this.majp < 0.0) {
        // Begin the splitting operation, animation transition is done
        if (posNeg > 0) {
            // The splitting operation positive side
            pVarTP.z += (smooth * (pAffineTP.z * scale * this.zlift + boost));
        } else {
            // The splitting operation negative side
            pVarTP.z = (pVarTP.z - (2.0 * smooth * pVarTP.z)) + (smooth * posNeg * (pAffineTP.z * scale * this.zlift + boost));
        }
    } else {
        // majp > 0.0       The splitting operation
        pVarTP.z += smooth * (pAffineTP.z * scale * this.zlift + (posNeg * boost));
    }
    if (this._rswtch <= 1) {
        // Occasion to build using 60 degree segments
        // random nodes selection
        loc60 = (int) trunc(pContext.random() * 6.0);
        // loc60 = this.fcycle;   // sequential nodes selection - seems to create artifacts that are progressively displaced
        smRotxTP = (smooth * scale * pVarTP.x * _seg60x[loc60]) - (smooth * scale * pVarTP.y * _seg60y[loc60]);
        smRotyTP = (smooth * scale * pVarTP.y * _seg60x[loc60]) + (smooth * scale * pVarTP.x * _seg60y[loc60]);
        smRotxFT = (pAffineTP.x * smooth * scale * _seg60x[loc60]) - (pAffineTP.y * smooth * scale * _seg60y[loc60]);
        smRotyFT = (pAffineTP.y * smooth * scale * _seg60x[loc60]) + (pAffineTP.x * smooth * scale * _seg60y[loc60]);
        pVarTP.x = pVarTP.x * (1.0 - smooth) + smRotxTP + smRotxFT + smooth * lrmaj * _seg60x[loc60];
        pVarTP.y = pVarTP.y * (1.0 - smooth) + smRotyTP + smRotyFT + smooth * lrmaj * _seg60y[loc60];
        this._fcycle += 1;
    } else {
        // Occasion to build on 120 degree segments
        // random nodes selection
        loc120 = (int) trunc(pContext.random() * 3.0);
        // loc120 = this.bcycle;  // sequential nodes selection - seems to create artifacts that are progressively displaced
        smRotxTP = (smooth * scale * pVarTP.x * _seg120x[loc120]) - (smooth * scale * pVarTP.y * _seg120y[loc120]);
        smRotyTP = (smooth * scale * pVarTP.y * _seg120x[loc120]) + (smooth * scale * pVarTP.x * _seg120y[loc120]);
        smRotxFT = (pAffineTP.x * smooth * scale * _seg120x[loc120]) - (pAffineTP.y * smooth * scale * _seg120y[loc120]);
        smRotyFT = (pAffineTP.y * smooth * scale * _seg120x[loc120]) + (pAffineTP.x * smooth * scale * _seg120y[loc120]);
        pVarTP.x = pVarTP.x * (1.0 - smooth) + smRotxTP + smRotxFT + smooth * lrmaj * scale3 * _seg120x[loc120];
        pVarTP.y = pVarTP.y * (1.0 - smooth) + smRotyTP + smRotyFT + smooth * lrmaj * scale3 * _seg120y[loc120];
        this._bcycle += 1;
    }
/*
    Rotations need to interchange smoothly between x and y values (pseudo code)
    new x = in_x*cos(r) - in_y*sin(r) + movedLoci_x;
    new y = in_y*cos(r) + in_x*sin(r) + movedLoci_y;
    */
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 20 with XYZPoint

use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.

the class Cubic_3DFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    /* cubic3D by Larry Berlin, http://aporev.deviantart.com/art/3D-Plugins-Collection-One-138514007?q=gallery%3Aaporev%2F8229210&qo=15 */
    double fill, exnze, wynze, znxy;
    double smooth = 1.0;
    double smoothStyle = 1.0;
    int useNode = 0;
    int rchoice = (int) trunc(pContext.random() * 8.0);
    double lattd = pAmount * 0.5;
    if (fabs(this.xpand) <= 1.0) {
        // values up to 0.5
        fill = this.xpand * 0.5;
    } else {
        // values above 0.5
        fill = sqrt(this.xpand) * 0.5;
    }
    if (fabs(pAmount) <= 0.5) {
        // Causes full effect above pAmount=0.5
        smooth = pAmount * 2.0;
    } else {
        smooth = 1.0;
    }
    if (fabs(this.style) <= 1.0) {
        smoothStyle = this.style;
    } else {
        if (this.style > 1.0) {
            smoothStyle = 1.0 + (this.style - 1.0) * 0.25;
        } else {
            smoothStyle = (this.style + 1.0) * 0.25 - 1.0;
        }
    }
    exnze = 1.0 - (smoothStyle * (1.0 - (cos(atan2(pAffineTP.x, pAffineTP.z)))));
    wynze = 1.0 - (smoothStyle * (1.0 - (sin(atan2(pAffineTP.y, pAffineTP.z)))));
    if (smoothStyle > 1.0) {
        znxy = 1.0 - (smoothStyle * (1.0 - ((exnze + wynze) / 2.0 * smoothStyle)));
    } else {
        znxy = 1.0 - (smoothStyle * (1.0 - ((exnze + wynze) / 2.0)));
    }
    useNode = rchoice;
    if (useNode == 0) {
        pVarTP.x = ((pVarTP.x - (smooth * (1.0 - fill) * pVarTP.x * exnze)) + (pAffineTP.x * smooth * fill * exnze)) + lattd;
        pVarTP.y = ((pVarTP.y - (smooth * (1.0 - fill) * pVarTP.y * wynze)) + (pAffineTP.y * smooth * fill * wynze)) + lattd;
        pVarTP.z = ((pVarTP.z - (smooth * (1.0 - fill) * pVarTP.z * znxy)) + (pAffineTP.z * smooth * fill * znxy)) + lattd;
    }
    if (useNode == 1) {
        pVarTP.x = ((pVarTP.x - (smooth * (1.0 - fill) * pVarTP.x * exnze)) + (pAffineTP.x * smooth * fill * exnze)) + lattd;
        pVarTP.y = ((pVarTP.y - (smooth * (1.0 - fill) * pVarTP.y * wynze)) + (pAffineTP.y * smooth * fill * wynze)) - lattd;
        pVarTP.z = ((pVarTP.z - (smooth * (1.0 - fill) * pVarTP.z * znxy)) + (pAffineTP.z * smooth * fill * znxy)) + lattd;
    }
    if (useNode == 2) {
        pVarTP.x = ((pVarTP.x - (smooth * (1.0 - fill) * pVarTP.x * exnze)) + (pAffineTP.x * smooth * fill * exnze)) + lattd;
        pVarTP.y = ((pVarTP.y - (smooth * (1.0 - fill) * pVarTP.y * wynze)) + (pAffineTP.y * smooth * fill * wynze)) + lattd;
        pVarTP.z = ((pVarTP.z - (smooth * (1.0 - fill) * pVarTP.z * znxy)) + (pAffineTP.z * smooth * fill * znxy)) - lattd;
    }
    if (useNode == 3) {
        pVarTP.x = ((pVarTP.x - (smooth * (1.0 - fill) * pVarTP.x * exnze)) + (pAffineTP.x * smooth * fill * exnze)) + lattd;
        pVarTP.y = ((pVarTP.y - (smooth * (1.0 - fill) * pVarTP.y * wynze)) + (pAffineTP.y * smooth * fill * wynze)) - lattd;
        pVarTP.z = ((pVarTP.z - (smooth * (1.0 - fill) * pVarTP.z * znxy)) + (pAffineTP.z * smooth * fill * znxy)) - lattd;
    }
    if (useNode == 4) {
        pVarTP.x = ((pVarTP.x - (smooth * (1.0 - fill) * pVarTP.x * exnze)) + (pAffineTP.x * smooth * fill * exnze)) - lattd;
        pVarTP.y = ((pVarTP.y - (smooth * (1.0 - fill) * pVarTP.y * wynze)) + (pAffineTP.y * smooth * fill * wynze)) + lattd;
        pVarTP.z = ((pVarTP.z - (smooth * (1.0 - fill) * pVarTP.z * znxy)) + (pAffineTP.z * smooth * fill * znxy)) + lattd;
    }
    if (useNode == 5) {
        pVarTP.x = ((pVarTP.x - (smooth * (1.0 - fill) * pVarTP.x * exnze)) + (pAffineTP.x * smooth * fill * exnze)) - lattd;
        pVarTP.y = ((pVarTP.y - (smooth * (1.0 - fill) * pVarTP.y * wynze)) + (pAffineTP.y * smooth * fill * wynze)) - lattd;
        pVarTP.z = ((pVarTP.z - (smooth * (1.0 - fill) * pVarTP.z * znxy)) + (pAffineTP.z * smooth * fill * znxy)) + lattd;
    }
    if (useNode == 6) {
        pVarTP.x = ((pVarTP.x - (smooth * (1.0 - fill) * pVarTP.x * exnze)) + (pAffineTP.x * smooth * fill * exnze)) - lattd;
        pVarTP.y = ((pVarTP.y - (smooth * (1.0 - fill) * pVarTP.y * wynze)) + (pAffineTP.y * smooth * fill * wynze)) + lattd;
        pVarTP.z = ((pVarTP.z - (smooth * (1.0 - fill) * pVarTP.z * znxy)) + (pAffineTP.z * smooth * fill * znxy)) - lattd;
    }
    if (useNode == 7) {
        pVarTP.x = ((pVarTP.x - (smooth * (1.0 - fill) * pVarTP.x * exnze)) + (pAffineTP.x * smooth * fill * exnze)) - lattd;
        pVarTP.y = ((pVarTP.y - (smooth * (1.0 - fill) * pVarTP.y * wynze)) + (pAffineTP.y * smooth * fill * wynze)) - lattd;
        pVarTP.z = ((pVarTP.z - (smooth * (1.0 - fill) * pVarTP.z * znxy)) + (pAffineTP.z * smooth * fill * znxy)) - lattd;
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Aggregations

XYZPoint (org.jwildfire.create.tina.base.XYZPoint)102 XForm (org.jwildfire.create.tina.base.XForm)16 Layer (org.jwildfire.create.tina.base.Layer)13 Test (org.junit.Test)4 VectorD (org.jwildfire.base.mathlib.VecMathLib.VectorD)4 Flame (org.jwildfire.create.tina.base.Flame)4 ZigguratRandomGenerator (org.jwildfire.create.tina.random.ZigguratRandomGenerator)4 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)4 SimpleHDRImage (org.jwildfire.image.SimpleHDRImage)4 SimpleImage (org.jwildfire.image.SimpleImage)4 Complex (org.jwildfire.base.mathlib.Complex)2 XYZProjectedPoint (org.jwildfire.create.tina.base.XYZProjectedPoint)2 Face (org.jwildfire.create.tina.variation.mesh.Face)2 Vertex (org.jwildfire.create.tina.variation.mesh.Vertex)2 VertexWithUV (org.jwildfire.create.tina.variation.mesh.VertexWithUV)2 RenderColor (org.jwildfire.create.tina.palette.RenderColor)1 CannabisCurveWFFunc (org.jwildfire.create.tina.variation.CannabisCurveWFFunc)1 CloverLeafWFFunc (org.jwildfire.create.tina.variation.CloverLeafWFFunc)1 DCPerlinFunc (org.jwildfire.create.tina.variation.DCPerlinFunc)1 FlowerFunc (org.jwildfire.create.tina.variation.FlowerFunc)1