Search in sources :

Example 31 with XYZPoint

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

the class SVGWFFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    List<Point> points = getPoints();
    if (points.size() > 1) {
        Point point = points.get(pContext.random(points.size()));
        double rawX = point.x;
        double rawY = point.y;
        if (antialias_radius > 0.01) {
            double dr = (exp(antialias_radius * sqrt(-log(pContext.random()))) - 1.0) * 0.001;
            double da = pContext.random() * 2.0 * M_PI;
            rawX += dr * cos(da);
            rawY += dr * sin(da);
        }
        pVarTP.x += (rawX * scale_x + offset_x);
        pVarTP.y += (rawY * scale_y + offset_y);
        if (true_color == 1) {
            pVarTP.rgbColor = true;
            pVarTP.redColor = point.r;
            pVarTP.greenColor = point.g;
            pVarTP.blueColor = point.b;
        }
        pVarTP.color = getColorIdx(point.r, point.g, point.b);
    } else {
        pVarTP.x += pContext.random();
        pVarTP.y += pContext.random();
        pVarTP.rgbColor = true;
        pVarTP.redColor = 0;
        pVarTP.greenColor = 0;
        pVarTP.blueColor = 0;
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 32 with XYZPoint

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

the class PrimitivesWFFunc method createPyramid.

private void createPyramid(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    double size = pAmount;
    double dx = 0.0, dy = 0.0, dz = 0.0;
    int side = pContext.random(5);
    switch(side) {
        case 0:
            dx = size * (pContext.random() - 0.5);
            dy = size * 0.5;
            dz = size * (pContext.random() - 0.5);
            break;
        default:
            double tx = 0.0, ty = 0.0;
            while (true) {
                tx = pContext.random();
                ty = pContext.random();
                if (insideUnitTriangle(tx, ty)) {
                    break;
                }
            }
            tx *= size;
            ty *= size;
            switch(side) {
                case 1:
                    dx = -size * 0.5 + P_COSA * ty;
                    dy = size * 0.5 - P_SINA * ty;
                    dz = (pContext.random() < 0.5 ? tx : -tx) * 0.5;
                    break;
                case 2:
                    dx = size * 0.5 - P_COSA * ty;
                    dy = 0.5 * size - P_SINA * ty;
                    dz = (pContext.random() < 0.5 ? tx : -tx) * 0.5;
                    break;
                case 3:
                    dx = (pContext.random() < 0.5 ? tx : -tx) * 0.5;
                    dy = 0.5 * size - P_SINA * ty;
                    dz = -size * 0.5 + P_COSA * ty;
                    break;
                case 4:
                    dx = (pContext.random() < 0.5 ? tx : -tx) * 0.5;
                    dy = 0.5 * size - P_SINA * ty;
                    dz = size * 0.5 - P_COSA * ty;
                    break;
                default:
                    // nothing to do
                    break;
            }
    }
    pVarTP.x += dx;
    pVarTP.y += dy;
    pVarTP.z += dz;
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 33 with XYZPoint

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

the class YPlot3DWFFunc method transform.

@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    if (evaluator == null) {
        return;
    }
    double randU = pContext.random();
    double randV = pContext.random();
    double x = _xmin + randU * _dx;
    double z = _zmin + randV * _dz;
    double y = evaluator.evaluate(x, z);
    if (displacementMapHolder.isActive()) {
        double epsx = _dx / 100.0;
        double x1 = x + epsx;
        double y1 = evaluator.evaluate(x1, z);
        double epsz = _dz / 100.0;
        double z1 = z + epsz;
        double y2 = evaluator.evaluate(x, z1);
        VectorD av = new VectorD(epsx, y1 - y, 0);
        VectorD bv = new VectorD(0.0, y2 - y, epsz);
        VectorD n = VectorD.cross(av, bv);
        n.normalize();
        double iu = GfxMathLib.clamp(randU * (displacementMapHolder.getDisplacementMapWidth() - 1.0), 0.0, displacementMapHolder.getDisplacementMapWidth() - 1.0);
        double iv = GfxMathLib.clamp(displacementMapHolder.getDisplacementMapHeight() - 1.0 - randV * (displacementMapHolder.getDisplacementMapHeight() - 1.0), 0, displacementMapHolder.getDisplacementMapHeight() - 1.0);
        int ix = (int) MathLib.trunc(iu);
        int iy = (int) MathLib.trunc(iv);
        double d = displacementMapHolder.calculateImageDisplacement(ix, iy, iu, iv) * _displ_amount;
        pVarTP.x += pAmount * n.x * d;
        pVarTP.y += pAmount * n.y * d;
        pVarTP.z += pAmount * n.z * d;
    }
    if (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_COLORMAP:
                if (colorMapHolder.isActive()) {
                    double iu = GfxMathLib.clamp(randU * (colorMapHolder.getColorMapWidth() - 1.0), 0.0, colorMapHolder.getColorMapWidth() - 1.0);
                    double iv = GfxMathLib.clamp(colorMapHolder.getColorMapHeight() - 1.0 - randV * (colorMapHolder.getColorMapHeight() - 1.0), 0, colorMapHolder.getColorMapHeight() - 1.0);
                    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_XZ:
                pVarTP.color = (x - _xmin) / _dx * (z - _zmin) / _dz;
                break;
            default:
            case CM_Z:
                pVarTP.color = (z - _zmin) / _dz;
                break;
        }
        if (pVarTP.color < 0.0)
            pVarTP.color = 0.0;
        else if (pVarTP.color > 1.0)
            pVarTP.color = 1.0;
    }
    pVarTP.x += pAmount * x;
    pVarTP.y += pAmount * y;
    pVarTP.z += pAmount * z;
}
Also used : VectorD(org.jwildfire.base.mathlib.VecMathLib.VectorD) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 34 with XYZPoint

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

the class FlamePanel method drawXForms.

private void drawXForms(Graphics2D g) {
    if (selectedXForm != null && selectedXForm.getVariationCount() > 0) {
        try {
            selectedXForm.initTransform();
            for (Variation var : selectedXForm.getVariations()) {
                var.getFunc().init(getFlameTransformationContext(), layerHolder != null ? layerHolder.getLayer() : null, selectedXForm, var.getAmount());
            }
            double xMin = -1.0;
            double xMax = 1.0;
            int xSteps = 32;
            double yMin = -1.0;
            double yMax = 1.0;
            int ySteps = 32;
            // 
            double xs = (xMax - xMin) / (double) (xSteps - 1.0);
            double ys = (yMax - yMin) / (double) (ySteps - 1.0);
            int[][] xx = new int[ySteps][xSteps];
            int[][] yy = new int[ySteps][xSteps];
            {
                double y = yMin;
                // affine part of the transformation
                XYZPoint affineT = new XYZPoint();
                // complete transformation
                XYZPoint varT = new XYZPoint();
                XYZPoint p = new XYZPoint();
                for (int i = 0; i < ySteps; i++) {
                    double x = xMin;
                    for (int j = 0; j < xSteps; j++) {
                        p.x = x;
                        p.y = y;
                        p.z = 0.0;
                        selectedXForm.transformPoint(getFlameTransformationContext(), affineT, varT, p, p);
                        xx[i][j] = triangleXToView(p.x);
                        yy[i][j] = triangleYToView(-p.y);
                        x += xs;
                    }
                    y += ys;
                }
            }
            g.setColor(VARIATION_COLOR);
            g.setStroke(GRID_LINE);
            for (int y = 0; y < ySteps - 1; y++) {
                for (int x = 0; x < xSteps - 1; x++) {
                    g.drawLine(xx[y][x], yy[y][x], xx[y][x + 1], yy[y][x + 1]);
                    g.drawLine(xx[y][x], yy[y][x], xx[y + 1][x], yy[y + 1][x]);
                    if (x == xSteps - 2) {
                        g.drawLine(xx[y][x + 1], yy[y][x + 1], xx[y + 1][x + 1], yy[y + 1][x + 1]);
                    }
                    if (y == ySteps - 2) {
                        g.drawLine(xx[y + 1][x], yy[y + 1][x], xx[y + 1][x + 1], yy[y + 1][x + 1]);
                    }
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
Also used : XYZPoint(org.jwildfire.create.tina.base.XYZPoint) Variation(org.jwildfire.create.tina.variation.Variation) XYZPoint(org.jwildfire.create.tina.base.XYZPoint)

Example 35 with XYZPoint

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

the class AbstractFractWFFunc method transformIterate.

public void transformIterate(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
    pVarTP.doHide = false;
    Iterator iterator = getIterator();
    double x0 = 0.0, y0 = 0.0;
    int iterCount = 0;
    for (int i = 0; i < max_clip_iter; i++) {
        x0 = (xmax - xmin) * pContext.random() + xmin;
        y0 = (ymax - ymin) * pContext.random() + ymin;
        iterCount = iterator.iterate(x0, y0, max_iter);
        if ((clip_iter_max < 0 && iterCount >= (max_iter + clip_iter_max)) || (clip_iter_min > 0 && iterCount <= clip_iter_min)) {
            if (i == max_clip_iter - 1) {
                // pVarTP.x = pVarTP.y = pVarTP.z = -120000.0 * (pContext.random() + 0.5);
                // pVarTP.rgbColor = true;
                // pVarTP.redColor = pVarTP.greenColor = pVarTP.blueColor = 0;
                pVarTP.doHide = true;
                return;
            }
        } else {
            break;
        }
    }
    pVarTP.x += scale * pAmount * (x0 + offsetx);
    pVarTP.y += scale * pAmount * (y0 + offsety);
    double z;
    if (z_logscale == 1) {
        z = scale * pAmount * (scalez / 10 * MathLib.log10(1.0 + (double) iterCount / (double) max_iter) + offsetz);
        if (z_fill > MathLib.EPSILON && pContext.random() < z_fill) {
            double prevZ = scale * pAmount * (scalez / 10 * MathLib.log10(1.0 + (double) (iterCount - 1) / (double) max_iter) + offsetz);
            z = (prevZ - z) * pContext.random() + z;
        }
    } else {
        z = scale * pAmount * (scalez / 10 * ((double) iterCount / (double) max_iter) + offsetz);
        if (z_fill > MathLib.EPSILON && pContext.random() < z_fill) {
            double prevZ = scale * pAmount * (scalez / 10 * ((double) (iterCount - 1) / (double) max_iter) + offsetz);
            z = (prevZ - z) * pContext.random() + z;
        }
    }
    pVarTP.z += z;
    if (direct_color != 0) {
        pVarTP.color += (double) iterCount / (double) max_iter;
        if (pVarTP.color > 1.0)
            pVarTP.color -= 1.0;
        if (pVarTP.color < 0)
            pVarTP.color = 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