Search in sources :

Example 1 with RandomGradientMutation

use of org.jwildfire.create.tina.mutagen.RandomGradientMutation in project JWildfire by thargor6.

the class SolidLabyrinthRandomFlameGenerator method createSubFlame.

private Flame createSubFlame() {
    Flame flame = new Flame();
    flame.getLayers().clear();
    flame.setCamRoll(0);
    flame.setCamPitch(0);
    flame.setCamYaw(0);
    flame.setCamPerspective(0);
    flame.setWidth(711);
    flame.setHeight(400);
    flame.setPixelsPerUnit(38.88427164);
    flame.setCamZoom(1);
    // create layer 1
    {
        Layer layer = new Layer();
        flame.getLayers().add(layer);
        layer.setWeight(1);
        layer.setVisible(true);
        // create a random gradient
        new RandomGradientMutation().execute(layer);
        // create transform 1
        {
            XForm xForm = new XForm();
            layer.getXForms().add(xForm);
            xForm.setWeight(0.5);
            xForm.setColor(0);
            xForm.setColorSymmetry(0);
            xForm.setMaterial(0);
            xForm.setMaterialSpeed(0);
            // a
            xForm.setCoeff00(1);
            // b
            xForm.setCoeff10(0);
            // e
            xForm.setCoeff20(0);
            // c
            xForm.setCoeff01(0);
            // d
            xForm.setCoeff11(1);
            // f
            xForm.setCoeff21(0);
            xForm.setPostCoeff00(1);
            xForm.setPostCoeff10(0);
            xForm.setPostCoeff01(0);
            xForm.setPostCoeff11(1);
            xForm.setPostCoeff20(0);
            xForm.setPostCoeff21(0);
            if (Math.random() < 0.15) {
                if (Math.random() < 0.85) {
                    VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("dc_crackle_wf", true);
                    varFunc.setParameter("cellsize", 0.15 + Math.random() * 0.5);
                    varFunc.setParameter("power", 0.2 + Math.random() * 1.2);
                    varFunc.setParameter("distort", Math.random() > 0.2 ? Math.random() * 0.5 : 0.0);
                    varFunc.setParameter("scale", Math.random() > 0.667 ? 1.06 - Math.random() * 0.12 : 1.0);
                    varFunc.setParameter("z", Math.random() * 0.5);
                    varFunc.setParameter("color_scale", 0.5);
                    varFunc.setParameter("color_offset", 0);
                    xForm.addVariation(1.0 + Math.random() * 2.0, varFunc);
                } else {
                    {
                        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("truchet", true);
                        varFunc.setParameter("extended", Math.random() < 0.25 ? 1 : 0);
                        varFunc.setParameter("exponent", 0.2 + Math.random() * 1.3);
                        varFunc.setParameter("arc_width", 0.5 + Math.random() * 0.5);
                        varFunc.setParameter("rotation", 0);
                        varFunc.setParameter("size", 0.4 + Math.random() * 0.3);
                        varFunc.setParameter("seed", 50.0 + Math.random() * 50.0);
                        varFunc.setParameter("direct_color", 1);
                        xForm.addVariation(1, varFunc);
                    }
                    xForm.addVariation(2.0 + Math.random() * 2.0, VariationFuncList.getVariationFuncInstance("pre_blur", true));
                }
            } else {
                VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("dc_perlin", true);
                varFunc.setParameter("shape", (int) (Math.random() * 3.0));
                varFunc.setParameter("map", Math.random() < 0.15 ? (int) (Math.random() * 6.0) : 2);
                varFunc.setParameter("select_centre", 0);
                varFunc.setParameter("select_range", 1);
                varFunc.setParameter("centre", 0.25 + Math.random() * 0.5);
                varFunc.setParameter("range", 0.25 + Math.random() * 0.5);
                varFunc.setParameter("edge", 0);
                varFunc.setParameter("scale", 1.0 + Math.random() * 5.0);
                varFunc.setParameter("octaves", Math.random() < 0.33 ? Tools.FTOI(2 + Math.random() * 2.0) : 2);
                varFunc.setParameter("amps", Math.random() < 0.33 ? Tools.FTOI(2 + Math.random() * 2.0) : 2);
                varFunc.setParameter("freqs", Math.random() < 0.33 ? Tools.FTOI(2 + Math.random() * 2.0) : 2);
                varFunc.setParameter("z", 0);
                varFunc.setParameter("select_bailout", 10);
                xForm.addVariation(3.0 + Math.random() * 4.0, varFunc);
            }
            // set default edit plane
            flame.setEditPlane(EditPlane.XY);
        // 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) RandomGradientMutation(org.jwildfire.create.tina.mutagen.RandomGradientMutation) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Example 2 with RandomGradientMutation

use of org.jwildfire.create.tina.mutagen.RandomGradientMutation in project JWildfire by thargor6.

the class OrchidsRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = new Flame();
    flame.setCamRoll(-0);
    flame.setCamPitch(0);
    flame.setCamYaw(0);
    flame.setCamPerspective(0);
    flame.setWidth(638);
    flame.setHeight(359);
    flame.setPixelsPerUnit(315.33902046);
    flame.setCamZoom(2.2 + Math.random() * 0.6);
    // create layer 1
    {
        Layer layer = flame.getFirstLayer();
        // create a random gradient
        new RandomGradientMutation().execute(layer);
        // create transform 1
        {
            XForm xForm = new XForm();
            layer.getXForms().add(xForm);
            xForm.setWeight(4 + Math.random() * 2.0);
            xForm.setColor(0.6 * Math.random());
            xForm.setColorSymmetry(0);
            xForm.setMaterial(0);
            xForm.setMaterialSpeed(0);
            // a
            xForm.setCoeff00(1);
            // b
            xForm.setCoeff10(0);
            // e
            xForm.setCoeff20(0);
            // c
            xForm.setCoeff01(0);
            // d
            xForm.setCoeff11(1);
            // f
            xForm.setCoeff21(0);
            xForm.setPostCoeff00(1);
            xForm.setPostCoeff10(0);
            xForm.setPostCoeff01(0);
            xForm.setPostCoeff11(1);
            xForm.setPostCoeff20(0);
            xForm.setPostCoeff21(0);
            // variation 1
            xForm.addVariation(1.5 + Math.random(), VariationFuncList.getVariationFuncInstance("elliptic", true));
            // set default edit plane
            flame.setEditPlane(EditPlane.XY);
        // 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(1.5 + Math.random());
            xForm.setColor(0.5 + Math.random() * 0.2);
            xForm.setColorSymmetry(0);
            xForm.setMaterial(0);
            xForm.setMaterialSpeed(0);
            // a
            xForm.setCoeff00(-0.00283201);
            // b
            xForm.setCoeff10(0.99999599);
            // e
            xForm.setCoeff20(0);
            // c
            xForm.setCoeff01(-0.99999599);
            // d
            xForm.setCoeff11(-0.00283201);
            // f
            xForm.setCoeff21(0);
            xForm.setPostCoeff00(1);
            xForm.setPostCoeff10(0);
            xForm.setPostCoeff01(0);
            xForm.setPostCoeff11(1);
            xForm.setPostCoeff20(0);
            xForm.setPostCoeff21(0);
            // variation 1
            {
                VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("poincare3D", true);
                varFunc.setParameter("r", 0);
                varFunc.setParameter("a", 0);
                varFunc.setParameter("b", 0);
                xForm.addVariation(Math.random() + 1.0, varFunc);
            }
            // variation 2
            xForm.addVariation(10.0 * Math.random() - 5.0, VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
            // set default edit plane
            flame.setEditPlane(EditPlane.XY);
            // random affine transforms (uncomment to play around)
            XFormTransformService.scale(xForm, 0.5 + 2.0 * Math.random(), 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 3
        {
            XForm xForm = new XForm();
            layer.getXForms().add(xForm);
            xForm.setWeight(1.2 + Math.random());
            xForm.setColor(0.2 + Math.random() * 0.5);
            xForm.setColorSymmetry(0);
            xForm.setMaterial(0);
            xForm.setMaterialSpeed(0);
            // a
            xForm.setCoeff00(1);
            // b
            xForm.setCoeff10(0);
            // e
            xForm.setCoeff20(0);
            // c
            xForm.setCoeff01(0);
            // d
            xForm.setCoeff11(1);
            // f
            xForm.setCoeff21(0);
            xForm.setPostCoeff00(1);
            xForm.setPostCoeff10(0);
            xForm.setPostCoeff01(0);
            xForm.setPostCoeff11(1);
            xForm.setPostCoeff20(0);
            xForm.setPostCoeff21(0);
            // variation 1
            xForm.addVariation(0.75, VariationFuncList.getVariationFuncInstance("rays", true));
            // set default edit plane
            flame.setEditPlane(EditPlane.XY);
        // 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 final transform 1
        {
            XForm xForm = new XForm();
            layer.getFinalXForms().add(xForm);
            xForm.setWeight(0);
            xForm.setColor(0.96);
            xForm.setColorSymmetry(0);
            xForm.setMaterial(0);
            xForm.setMaterialSpeed(0);
            // a
            xForm.setCoeff00(1);
            // b
            xForm.setCoeff10(0);
            // e
            xForm.setCoeff20(0);
            // c
            xForm.setCoeff01(0);
            // d
            xForm.setCoeff11(1);
            // f
            xForm.setCoeff21(0);
            xForm.setPostCoeff00(1);
            xForm.setPostCoeff10(0);
            xForm.setPostCoeff01(0);
            xForm.setPostCoeff11(1);
            xForm.setPostCoeff20(0);
            xForm.setPostCoeff21(0);
            // variation 1
            {
                VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("hypertile1", true);
                varFunc.setParameter("p", 4);
                varFunc.setParameter("q", 6);
                xForm.addVariation(0.3 + Math.random() * 0.8, varFunc);
            }
            // set default edit plane
            flame.setEditPlane(EditPlane.XY);
        // 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 final transform 2
        {
            XForm xForm = new XForm();
            layer.getFinalXForms().add(xForm);
            xForm.setWeight(0);
            xForm.setColor(0);
            xForm.setColorSymmetry(0);
            xForm.setMaterial(0);
            xForm.setMaterialSpeed(0);
            // a
            xForm.setCoeff00(1);
            // b
            xForm.setCoeff10(0);
            // e
            xForm.setCoeff20(0);
            // c
            xForm.setCoeff01(0);
            // d
            xForm.setCoeff11(1);
            // f
            xForm.setCoeff21(0);
            xForm.setPostCoeff00(1);
            xForm.setPostCoeff10(0);
            xForm.setPostCoeff01(0);
            xForm.setPostCoeff11(1);
            xForm.setPostCoeff20(0);
            xForm.setPostCoeff21(0);
            // variation 1
            if (Math.random() > 0.25) {
                xForm.addVariation(1, VariationFuncList.getVariationFuncInstance(Math.random() < 0.5 ? "polar" : "polar2", true));
            } else {
                xForm.addVariation(1, VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
            }
        }
        if (Math.random() > 0.666) {
            layer.getXForms().get(0).getModifiedWeights()[0] = 1.0 + Math.random();
            layer.getXForms().get(0).getModifiedWeights()[2] = 0.2 * Math.random();
        }
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) RandomGradientMutation(org.jwildfire.create.tina.mutagen.RandomGradientMutation) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Example 3 with RandomGradientMutation

use of org.jwildfire.create.tina.mutagen.RandomGradientMutation in project JWildfire by thargor6.

the class IFlamesController method createNewFlame.

private Flame createNewFlame() {
    Flame flame = new Flame();
    flame.setBGTransparency(prefs.isTinaDefaultBGTransparency());
    flame.setCamRoll(0);
    flame.setCamPitch(0);
    flame.setCamYaw(0);
    flame.setCamPerspective(0);
    flame.setWidth(800);
    flame.setHeight(600);
    flame.setCamZoom(1);
    {
        Layer layer = flame.getFirstLayer();
        new RandomGradientMutation().execute(layer);
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5);
        IFlamesFunc iflames = (IFlamesFunc) VariationFuncList.getVariationFuncInstance("iflames_wf", true);
        if (imageLibrary.size() > 0) {
            String imgFilename = imageLibrary.get((int) (Math.random() * imageLibrary.size())).getFilename();
            iflames.getImageParams().setImageFilename(imgFilename);
        }
        if (flameLibrary.size() > 0) {
            for (int i = 0; i < IFlamesFunc.MAX_FLAME_COUNT; i++) {
                if (i > 1 && Math.random() < 0.33) {
                    iflames.getFlameParams(i).setFlameXML(null);
                } else if (Math.random() < 0.50) {
                    Flame libFlame = flameLibrary.get((int) (Math.random() * flameLibrary.size())).getFlame();
                    String libFlameXML;
                    try {
                        libFlameXML = new FlameWriter().getFlameXML(libFlame);
                    } catch (Exception e) {
                        libFlameXML = null;
                        e.printStackTrace();
                    }
                    iflames.getFlameParams(i).setFlameXML(libFlameXML);
                }
            }
        }
        if (Math.random() < 0.5) {
            iflames.getImageParams().setShape_distribution(ShapeDistribution.HUE);
        } else {
            iflames.getImageParams().setShape_distribution(ShapeDistribution.RANDOM);
        }
        for (int i = 0; i < IFlamesFunc.MAX_FLAME_COUNT; i++) {
            iflames.getFlameParams(i).setSize(2.0 + Math.random() * 4.0);
        }
        iflames.getMotionParams().setPreview(previewButton.isSelected() ? 1 : 0);
        xForm.addVariation(1.0, iflames);
    }
    return flame.makeCopy();
}
Also used : FlameWriter(org.jwildfire.create.tina.io.FlameWriter) XForm(org.jwildfire.create.tina.base.XForm) RandomGradientMutation(org.jwildfire.create.tina.mutagen.RandomGradientMutation) Layer(org.jwildfire.create.tina.base.Layer) IFlamesFunc(org.jwildfire.create.tina.variation.iflames.IFlamesFunc) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 4 with RandomGradientMutation

use of org.jwildfire.create.tina.mutagen.RandomGradientMutation 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)

Aggregations

Layer (org.jwildfire.create.tina.base.Layer)4 XForm (org.jwildfire.create.tina.base.XForm)4 RandomGradientMutation (org.jwildfire.create.tina.mutagen.RandomGradientMutation)4 Flame (org.jwildfire.create.tina.base.Flame)3 VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)3 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)1 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)1 Variation (org.jwildfire.create.tina.variation.Variation)1 IFlamesFunc (org.jwildfire.create.tina.variation.iflames.IFlamesFunc)1