Search in sources :

Example 71 with Layer

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

the class MandelbrotRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCentreY(0.45);
    flame.setCamPitch(49.0);
    flame.setCamRoll(00.0);
    flame.setCamYaw(0.0);
    flame.setCamZoom(1.0);
    flame.setGamma(2.0);
    flame.setCamPerspective(0.05 + Math.random() * 0.12);
    flame.setPixelsPerUnit(200);
    flame.setPreserveZ(true);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    VariationFunc varFunc;
    // 1st xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5);
        int varId = Tools.randomInt(6);
        switch(varId) {
            case 0:
                varFunc = VariationFuncList.getVariationFuncInstance("fract_dragon_wf", true);
                varFunc.setParameter("scale", 2.0);
                varFunc.setParameter("xmin", -2.0);
                varFunc.setParameter("xmax", 2.0);
                varFunc.setParameter("ymin", -2.0);
                varFunc.setParameter("ymax", 2.0);
                varFunc.setParameter("xseed", -1.0 + 2.0 * Math.random());
                varFunc.setParameter("yseed", -1.0 + 2.0 * Math.random());
                break;
            case 1:
                varFunc = VariationFuncList.getVariationFuncInstance("fract_julia_wf", true);
                varFunc.setParameter("scale", 2.0);
                varFunc.setParameter("xmin", -2.0);
                varFunc.setParameter("xmax", 2.0);
                varFunc.setParameter("ymin", -2.0);
                varFunc.setParameter("ymax", 2.0);
                varFunc.setParameter("xseed", -1.0 + 2.0 * Math.random());
                varFunc.setParameter("yseed", -1.0 + 2.0 * Math.random());
                break;
            case 2:
                varFunc = VariationFuncList.getVariationFuncInstance("fract_pearls_wf", true);
                varFunc.setParameter("scale", 2.0);
                varFunc.setParameter("xmin", -2.0);
                varFunc.setParameter("xmax", 2.0);
                varFunc.setParameter("ymin", -2.0);
                varFunc.setParameter("ymax", 2.0);
                varFunc.setParameter("xseed", -1.0 + 2.0 * Math.random());
                varFunc.setParameter("yseed", -1.0 + 2.0 * Math.random());
                break;
            case 3:
                varFunc = VariationFuncList.getVariationFuncInstance("fract_salamander_wf", true);
                varFunc.setParameter("scale", 2.0);
                varFunc.setParameter("xmin", -2.0);
                varFunc.setParameter("xmax", 2.0);
                varFunc.setParameter("ymin", -2.0);
                varFunc.setParameter("ymax", 2.0);
                varFunc.setParameter("xseed", -1.0 + 2.0 * Math.random());
                varFunc.setParameter("yseed", -1.0 + 2.0 * Math.random());
                break;
            case 4:
                varFunc = VariationFuncList.getVariationFuncInstance("fract_mandelbrot_wf", true);
                break;
            default:
                varFunc = VariationFuncList.getVariationFuncInstance("fract_meteors_wf", true);
                break;
        }
        if (Math.random() < 0.8) {
            double scale = 3 + Math.random() * 3;
            double xmin = -1.0 + 2.0 * Math.random();
            double ymin = -1.0 + 2.0 * Math.random();
            double xmax = xmin + 4.0 / scale;
            double ymax = ymin + 4.0 / scale;
            varFunc.setParameter("xmin", xmin);
            varFunc.setParameter("xmax", xmax);
            varFunc.setParameter("ymin", ymin);
            varFunc.setParameter("ymax", ymax);
            varFunc.setParameter("offsetx", -(xmax - xmin) * 0.5);
            varFunc.setParameter("offsety", -(ymax - ymin) * 0.5);
            varFunc.setParameter("scale", 2.0 * scale);
        }
        varFunc.setParameter("scalez", 1.0 + Math.random() * 10.0);
        xForm.addVariation(1.0, varFunc);
    }
    // final
    if (Math.random() < 0.75) {
        XForm xForm = new XForm();
        layer.getFinalXForms().add(xForm);
        varFunc = VariationFuncList.getVariationFuncInstance(FNCLST_FINAL[(int) (Math.random() * FNCLST_FINAL.length)], true);
        xForm.addVariation(1.0, varFunc);
    }
    flame.getFirstLayer().randomizeColors();
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Example 72 with Layer

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

the class SimpleRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    int maxXForms = (int) (2.0 + Math.random() * 5.0);
    double scl = 1.0;
    for (int i = 0; i < maxXForms; i++) {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        if (Math.random() < 0.5) {
            XFormTransformService.rotate(xForm, 360.0 * Math.random());
        } else {
            XFormTransformService.rotate(xForm, -360.0 * Math.random());
        }
        XFormTransformService.localTranslate(xForm, Math.random() - 1.0, Math.random() - 1.0);
        scl *= 0.75 + Math.random() / 4;
        XFormTransformService.scale(xForm, scl, true, true);
        xForm.setColor(Math.random());
        xForm.addVariation(Math.random() * 0.8 + 0.2, new Linear3DFunc());
        if (Math.random() > 0.33) {
            String[] fnc = FNCLST_ORIGINAL;
            int fncIdx = (int) (Math.random() * fnc.length);
            xForm.addVariation(Math.random() * 0.5, VariationFuncList.getVariationFuncInstance(fnc[fncIdx], true));
        }
        xForm.setWeight(Math.random() * 0.9 + 0.1);
    }
    return flame;
}
Also used : Linear3DFunc(org.jwildfire.create.tina.variation.Linear3DFunc) XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) Flame(org.jwildfire.create.tina.base.Flame)

Example 73 with Layer

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

the class SolidShadowsRandomFlameGenerator method postProcessFlameAfterRendering.

@Override
protected Flame postProcessFlameAfterRendering(RandomFlameGeneratorState pState, Flame pFlame) {
    pFlame.setCamZoom(0.5 + Math.random() * 0.25);
    pFlame.setCamPerspective(0.05 + Math.random() * 0.15);
    pFlame.setCamPitch(-5.0 - Math.random() * 30.0);
    pFlame.setCamYaw(-25.0 + Math.random() * 50.0);
    pFlame.setCamRoll(0.0);
    XForm xform0 = pFlame.getFirstLayer().getXForms().get(0);
    Variation var0 = xform0.getVariation(0);
    var0.setAmount(var0.getAmount() * (0.25 + Math.random() * 0.25));
    Layer layer = new Layer();
    layer.setWeight(0.25 + Math.random() * 0.5);
    pFlame.getLayers().add(layer);
    new RandomGradientMutation().execute(layer);
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5);
        if (Math.random() < 0.5) {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("plane_wf", true);
            varFunc.setParameter("axis", 2);
            varFunc.setParameter("position", Math.random() * 2.0 - 0.25);
            varFunc.setParameter("color_mode", Tools.FTOI(4 * Math.random()));
            xForm.addVariation(1.0 + Math.random(), varFunc);
        } else {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("checkerboard_wf", true);
            varFunc.setParameter("axis", 2);
            varFunc.setParameter("position", Math.random() * 2.0 - 0.25);
            varFunc.setParameter("checker_size", 0.05 + Math.random() * 0.1);
            varFunc.setParameter("displ_amount", 0.005 + Math.random() * 0.03);
            varFunc.setParameter("with_sides", Math.random() > 0.25 ? 1 : 0);
            xForm.addVariation(1.0 + Math.random(), varFunc);
        }
    }
    pFlame.getSolidRenderSettings().setShadowType(Math.random() < 0.5 ? ShadowType.SMOOTH : ShadowType.FAST);
    return pFlame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) RandomGradientMutation(org.jwildfire.create.tina.mutagen.RandomGradientMutation) Variation(org.jwildfire.create.tina.variation.Variation) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc)

Example 74 with Layer

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

the class XenomorphRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    Layer layer = flame.getFirstLayer();
    flame.setCentreX(0.0);
    flame.setCentreY(0.0);
    flame.setPixelsPerUnit(200);
    layer.getFinalXForms().clear();
    layer.getXForms().clear();
    // create transform 1
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.1 + Math.random() * 0.4);
        xForm.setColor(0.74488914);
        xForm.setColorSymmetry(0);
        // a
        xForm.setCoeff00(0.75610133);
        // b
        xForm.setCoeff10(-0.74186252);
        // e
        xForm.setCoeff20(5.25778565);
        // c
        xForm.setCoeff01(0.74186252);
        // d
        xForm.setCoeff11(0.75610133);
        // f
        xForm.setCoeff21(-0.34949139);
        xForm.setPostCoeff00(-0.42606416);
        xForm.setPostCoeff10(0.44290131);
        xForm.setPostCoeff01(-0.10610689);
        xForm.setPostCoeff11(-0.40885976);
        xForm.setPostCoeff20(-2.81712);
        xForm.setPostCoeff21(7.390367);
        // variation 1
        xForm.addVariation(1.43, VariationFuncList.getVariationFuncInstance("bubble", true));
        // variation 2
        xForm.addVariation(0.012, VariationFuncList.getVariationFuncInstance("linear", true));
        // variation 3
        if (Math.random() > 0.6) {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("radial_blur", true);
            varFunc.setParameter("angle", 0.609835);
            xForm.addVariation(-0.249, varFunc);
        } else {
            xForm.addVariation(Math.random() < 0.5 ? -0.249 : 0.5 - Math.random(), VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
        }
        // variation 4
        xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("power", true));
        // random affine transforms (uncomment to play around)
        // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
        // XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
        XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
    // random affine post transforms (uncomment to play around)
    // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
    // XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
    // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
    }
    // create transform 2
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(10.0 + Math.random() * 8.0);
        xForm.setColor(0.90312262);
        xForm.setColorSymmetry(0.95);
        // a
        xForm.setCoeff00(-0.85421287);
        // b
        xForm.setCoeff10(-0.63343313);
        // e
        xForm.setCoeff20(1.09379129);
        // c
        xForm.setCoeff01(-0.63343313);
        // d
        xForm.setCoeff11(0.85421287);
        // f
        xForm.setCoeff21(-0.20406326);
        xForm.setPostCoeff00(0.84389756);
        xForm.setPostCoeff10(-0.35800434);
        xForm.setPostCoeff01(0.43174917);
        xForm.setPostCoeff11(0.89637273);
        xForm.setPostCoeff20(-0.945758);
        xForm.setPostCoeff21(-0.4502584);
        // change relative weights
        xForm.getModifiedWeights()[0] = 2.05;
        xForm.getModifiedWeights()[1] = 1.25;
        xForm.getModifiedWeights()[2] = 0.9;
        // variation 1
        xForm.addVariation(0.008, VariationFuncList.getVariationFuncInstance("linear", true));
        // variation 2
        xForm.addVariation(10.72, VariationFuncList.getVariationFuncInstance("spherical", true));
        // random affine transforms (uncomment to play around)
        XFormTransformService.scale(xForm, 1.25 - Math.random() * 0.5, true, true, false);
        XFormTransformService.rotate(xForm, 36.0 * Math.random(), false);
        XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
    // random affine post transforms (uncomment to play around)
    // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
    // XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
    // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
    }
    // create transform 3
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.7);
        xForm.setColor(0.47272985);
        xForm.setColorSymmetry(0);
        // a
        xForm.setCoeff00(0.68724662);
        // b
        xForm.setCoeff10(-0.72642418);
        // e
        xForm.setCoeff20(-2.14812602);
        // c
        xForm.setCoeff01(0.72642418);
        // d
        xForm.setCoeff11(0.68724662);
        // f
        xForm.setCoeff21(2.39994214);
        xForm.setPostCoeff00(0.60646395);
        xForm.setPostCoeff10(0.79511098);
        xForm.setPostCoeff01(-0.79511098);
        xForm.setPostCoeff11(0.60646395);
        xForm.setPostCoeff20(-1.06135064);
        xForm.setPostCoeff21(-0.6369509);
        // variation 1
        {
            VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("bipolar", true);
            varFunc.setParameter("shift", 0);
            xForm.addVariation(1, varFunc);
        }
    // random affine transforms (uncomment to play around)
    // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, false);
    // XFormTransformService.rotate(xForm, 360.0*Math.random(), false);
    // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), false);
    // random affine post transforms (uncomment to play around)
    // XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
    // XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
    // XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Example 75 with Layer

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

the class DefaultRenderThread method restoreState.

@Override
protected void restoreState(RenderThreadPersistentState pState) {
    iterationState.clear();
    DefaultRenderThreadPersistentState state = (DefaultRenderThreadPersistentState) pState;
    currSample = state.currSample;
    startIter = state.startIter;
    for (DefaultRenderThreadPersistentState.IterationState persist : state.getLayerState()) {
        RenderPacket packet = renderPackets.get(persist.packetIdx);
        Layer layer = packet.getFlame().getLayers().get(persist.layerIdx);
        DefaultRenderIterationState restored = createState(packet, layer);
        restored.xf = (persist.xfIndex >= 0) ? restored.layer.getXForms().get(persist.xfIndex) : null;
        restored.affineT = persist.affineT != null ? persist.affineT.makeCopy() : null;
        restored.varT = persist.varT != null ? persist.varT.makeCopy() : null;
        restored.p = persist.p != null ? persist.p.makeCopy() : null;
        restored.q = persist.q != null ? persist.q.makeCopy() : null;
        iterationState.add(restored);
    }
}
Also used : Layer(org.jwildfire.create.tina.base.Layer)

Aggregations

Layer (org.jwildfire.create.tina.base.Layer)105 XForm (org.jwildfire.create.tina.base.XForm)73 Flame (org.jwildfire.create.tina.base.Flame)63 VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)31 XYZPoint (org.jwildfire.create.tina.base.XYZPoint)16 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)13 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)9 ArrayList (java.util.ArrayList)8 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)5 RandomGradientMutation (org.jwildfire.create.tina.mutagen.RandomGradientMutation)4 Linear3DFunc (org.jwildfire.create.tina.variation.Linear3DFunc)4 DefaultTableModel (javax.swing.table.DefaultTableModel)2 Test (org.junit.Test)2 QualityProfile (org.jwildfire.base.QualityProfile)2 ResolutionProfile (org.jwildfire.base.ResolutionProfile)2 XMLAttributes (org.jwildfire.base.Tools.XMLAttributes)2 HeadlessBatchRendererController (org.jwildfire.create.tina.batch.HeadlessBatchRendererController)2 Job (org.jwildfire.create.tina.batch.Job)2 JobRenderThread (org.jwildfire.create.tina.batch.JobRenderThread)2 JobRenderThreadController (org.jwildfire.create.tina.batch.JobRenderThreadController)2