Search in sources :

Example 1 with XYZPoint

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

the class VogelFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    // Vogel function by Victor Ganora
    final int i = pContext.random(n) + 1;
    final double a = i * M_2PI_PHI2;
    sinAndCos(a, sina, cosa);
    final double r = pAmount * (pAffineTP.getPrecalcSqrt() + sqrt(i));
    pVarTP.x += r * (cosa.value + (scale * pAffineTP.x));
    pVarTP.y += r * (sina.value + (scale * pAffineTP.y));
    if (pContext.isPreserveZCoordinate()) {
        pVarTP.z += pAmount * pAffineTP.z;
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 2 with XYZPoint

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

the class VoronFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    /* voronoi by eralex61, http://eralex61.deviantart.com/art/Voronoi-Diagram-plugin-153126702 */
    int i, j, l, K, M, M1, N, N1;
    double R, Rmin, OffsetX, OffsetY, X0 = 0, Y0 = 0, X, Y;
    Rmin = 20.0;
    M = (int) floor(pAffineTP.x / step);
    N = (int) floor(pAffineTP.y / step);
    for (i = -1; i < 2; i++) {
        M1 = M + i;
        for (j = -1; j < 2; j++) {
            N1 = N + j;
            K = (int) (1 + floor(num * DiscretNoise(19 * M1 + 257 * N1 + xseed)));
            for (l = 0; l < K; l++) {
                X = (DiscretNoise(l + 64 * M1 + 15 * N1 + xseed) + M1) * step;
                Y = (DiscretNoise(l + 21 * M1 + 33 * N1 + yseed) + N1) * step;
                OffsetX = pAffineTP.x - X;
                OffsetY = pAffineTP.y - Y;
                R = sqrt(OffsetX * OffsetX + OffsetY * OffsetY);
                if (R < Rmin) {
                    Rmin = R;
                    X0 = X;
                    Y0 = Y;
                }
            }
        }
    }
    pVarTP.x += pAmount * (k * (pAffineTP.x - X0) + X0);
    pVarTP.y += pAmount * (k * (pAffineTP.y - Y0) + Y0);
    if (pContext.isPreserveZCoordinate()) {
        pVarTP.z += pAmount * pAffineTP.z;
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 3 with XYZPoint

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

the class IFlamesFunc method addImage.

private void addImage(XYZPoint pVarTP, AbstractRandomGenerator randGen) {
    double xCoord = randGen.random(imageParams.getImgWidth()) + (0.5 - randGen.random());
    double yCoord = randGen.random(imageParams.getImgHeight()) + (0.5 - randGen.random());
    double dx = xCoord * imageParams.getScaleX() / (double) (imageParams.getImgWidth() - 1) + imageParams.getOffsetX();
    double dy = yCoord * imageParams.getScaleY() / (double) (imageParams.getImgHeight() - 1) + imageParams.getOffsetY();
    double dz = imageParams.getOffsetZ();
    pVarTP.x += dx;
    pVarTP.y += dy;
    pVarTP.z += dz;
    toolPixel.setARGBValue(((SimpleImage) imageParams.getColorMap()).getARGBValueIgnoreBounds((int) xCoord, (int) yCoord));
    int luR = toolPixel.r;
    int luG = toolPixel.g;
    int luB = toolPixel.b;
    pVarTP.doHide = false;
    if (luR == 0 && luG == 0 && luB == 0) {
        pVarTP.doHide = true;
        return;
    }
    toolPixel.setARGBValue(((SimpleImage) imageParams.getColorMap()).getARGBValueIgnoreBounds(((int) xCoord) + 1, (int) yCoord));
    int ruR = toolPixel.r;
    int ruG = toolPixel.g;
    int ruB = toolPixel.b;
    toolPixel.setARGBValue(((SimpleImage) imageParams.getColorMap()).getARGBValueIgnoreBounds((int) xCoord, ((int) yCoord) + 1));
    int lbR = toolPixel.r;
    int lbG = toolPixel.g;
    int lbB = toolPixel.b;
    toolPixel.setARGBValue(((SimpleImage) imageParams.getColorMap()).getARGBValueIgnoreBounds(((int) xCoord) + 1, ((int) yCoord) + 1));
    int rbR = toolPixel.r;
    int rbG = toolPixel.g;
    int rbB = toolPixel.b;
    double r = GfxMathLib.blerp(luR, ruR, lbR, rbR, MathLib.frac(xCoord), MathLib.frac(yCoord));
    double g = GfxMathLib.blerp(luG, ruG, lbG, rbG, MathLib.frac(xCoord), MathLib.frac(yCoord));
    double b = GfxMathLib.blerp(luB, ruB, lbB, rbB, MathLib.frac(xCoord), MathLib.frac(yCoord));
    pVarTP.rgbColor = true;
    pVarTP.redColor = r * imageParams.getImage_brightness();
    pVarTP.greenColor = g * imageParams.getImage_brightness();
    pVarTP.blueColor = b * imageParams.getImage_brightness();
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 4 with XYZPoint

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

the class IFlamesFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    if (imageParams.getImage_brightness() < MathLib.EPSILON || randGen.random() < imageParams.getIFlame_density()) {
        if (flameList.size() == 0) {
            return;
        }
        // int idx = randGen.random(flameList.size());
        int idx;
        if (randGen.random() < 0.5) {
            idx = randGen.random(flameList.size());
        } else {
            idx = flameIdx++;
            if (flameIdx >= flameList.size()) {
                flameIdx = 0;
            }
        }
        BaseFlame baseFlame = flameList.get(idx);
        Particle particle = particleLst.get(idx);
        if (baseFlame.getIterator() != null) {
            if (motionParams.getPreview() == 1) {
                XYZPoint dst = new XYZPoint();
                pVarTP.x += dst.x + particle.getPosition().getX();
                pVarTP.y += dst.y + particle.getPosition().getY();
                pVarTP.z += dst.z + particle.getPosition().getZ();
                pVarTP.rgbColor = true;
                pVarTP.redColor = baseFlame.getPreviewColorR() * imageParams.getIFlame_brightness() * baseFlame.getBrightness();
                pVarTP.greenColor = baseFlame.getPreviewColorG() * imageParams.getIFlame_brightness() * baseFlame.getBrightness();
                pVarTP.blueColor = baseFlame.getPreviewColorB() * imageParams.getIFlame_brightness() * baseFlame.getBrightness();
            } else {
                XYZPoint src = new XYZPoint();
                XYZPoint dst = new XYZPoint();
                baseFlame.getIterator().iterate(src, dst, baseFlame.getSize(), particle.getRotation().getX(), particle.getRotation().getY(), particle.getRotation().getZ());
                pVarTP.x += dst.x + particle.getPosition().getX();
                pVarTP.y += dst.y + particle.getPosition().getY();
                pVarTP.z += dst.z + particle.getPosition().getZ();
                pVarTP.color = dst.color;
                pVarTP.rgbColor = true;
                pVarTP.redColor = baseFlame.getR() * imageParams.getIFlame_brightness() * baseFlame.getBrightness();
                pVarTP.greenColor = baseFlame.getG() * imageParams.getIFlame_brightness() * baseFlame.getBrightness();
                pVarTP.blueColor = baseFlame.getB() * imageParams.getIFlame_brightness() * baseFlame.getBrightness();
            }
        } else {
            addImage(pVarTP, randGen);
        }
    } else {
        addImage(pVarTP, randGen);
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 5 with XYZPoint

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

the class IsoSFPlot3DWFFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    if (evaluator == null) {
        return;
    }
    pVarTP.doHide = true;
    double x = 0.0, y = 0.0, z = 0.0;
    for (int i = 0; i < max_iter; i++) {
        x = _xmin + pContext.random() * _dx;
        y = _ymin + pContext.random() * _dy;
        z = _zmin + pContext.random() * _dz;
        double e = evaluator.evaluate(x, y, z);
        if (fabs(e) <= thickness) {
            pVarTP.x += pAmount * x;
            pVarTP.y += pAmount * y;
            pVarTP.z += pAmount * z;
            pVarTP.doHide = false;
            break;
        }
    }
    if (!pVarTP.doHide && direct_color > 0) {
        switch(color_mode) {
            case CM_X:
                pVarTP.color = (x - _xmin) / _dx;
                break;
            case CM_Y:
                pVarTP.color = (y - _ymin) / _dy;
                break;
            case CM_Z:
                pVarTP.color = (z - _zmin) / _dz;
                break;
            case CM_COLORMAP_X:
            case CM_COLORMAP_Y:
            case CM_COLORMAP_Z:
                if (colorMapHolder.isActive()) {
                    double iu, iv;
                    switch(color_mode) {
                        case CM_COLORMAP_X:
                            iu = GfxMathLib.clamp(y * (colorMapHolder.getColorMapWidth() - 1.0), 0.0, colorMapHolder.getColorMapWidth() - 1.0);
                            iv = GfxMathLib.clamp(colorMapHolder.getColorMapHeight() - 1.0 - z * (colorMapHolder.getColorMapHeight() - 1.0), 0, colorMapHolder.getColorMapHeight() - 1.0);
                        case CM_COLORMAP_Y:
                            iu = GfxMathLib.clamp(z * (colorMapHolder.getColorMapWidth() - 1.0), 0.0, colorMapHolder.getColorMapWidth() - 1.0);
                            iv = GfxMathLib.clamp(colorMapHolder.getColorMapHeight() - 1.0 - x * (colorMapHolder.getColorMapHeight() - 1.0), 0, colorMapHolder.getColorMapHeight() - 1.0);
                        case CM_COLORMAP_Z:
                        default:
                            iu = GfxMathLib.clamp(x * (colorMapHolder.getColorMapWidth() - 1.0), 0.0, colorMapHolder.getColorMapWidth() - 1.0);
                            iv = GfxMathLib.clamp(colorMapHolder.getColorMapHeight() - 1.0 - y * (colorMapHolder.getColorMapHeight() - 1.0), 0, colorMapHolder.getColorMapHeight() - 1.0);
                            break;
                    }
                    int ix = (int) MathLib.trunc(iu);
                    int iy = (int) MathLib.trunc(iv);
                    colorMapHolder.applyImageColor(pVarTP, ix, iy, iu, iv);
                    pVarTP.color = getUVColorIdx(Tools.FTOI(pVarTP.redColor), Tools.FTOI(pVarTP.greenColor), Tools.FTOI(pVarTP.blueColor));
                }
                break;
            case CM_XY:
                pVarTP.color = (x - _xmin) / _dx * (y - _ymin) / _dy;
                break;
            case CM_YZ:
                pVarTP.color = (y - _ymin) / _dy * (z - _zmin) / _dz;
                break;
            case CM_ZX:
                pVarTP.color = (z - _zmin) / _dz * (x - _xmin) / _dx;
                break;
            default:
            case CM_XYZ:
                pVarTP.color = (x - _xmin) / _dx * (y - _ymin) / _dy * (z - _zmin) / _dz;
                break;
        }
        if (pVarTP.color < 0.0)
            pVarTP.color = 0.0;
        else if (pVarTP.color > 1.0)
            pVarTP.color = 1.0;
    }
}
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