Search in sources :

Example 81 with Layer

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

the class DuckiesRandomFlameGenerator 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();
    // 1st xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(0.5 + Math.random());
        xForm.addVariation(1.5 + Math.random(), VariationFuncList.getVariationFuncInstance(Math.random() < 0.12 ? VariationFuncList.getRandomVariationname() : "spherical", true));
        xForm.setColorSymmetry(-0.5);
        XFormTransformService.localTranslate(xForm, 0.75 - 5.50 * Math.random(), 0.75 - 1.50 * Math.random(), false);
        XFormTransformService.rotate(xForm, -60.0 + Math.random() * 30.0, false);
        XFormTransformService.scale(xForm, 0.1 + Math.random() * 0.4, true, true, false);
    }
    // 2nd xForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1.0 + Math.random() * 100.0);
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(Math.random() < 0.8 ? "juliascope" : "julian", true);
        varFunc.setParameter("power", Math.random() < 0.8 ? 2 : 2 + Math.random() * 10.0);
        varFunc.setParameter("dist", Math.random() < 0.8 ? 1.0 : -2.0 + 4.0 * Math.random());
        xForm.addVariation(0.5 + Math.random(), varFunc);
        xForm.setColorSymmetry(0.5);
        XFormTransformService.rotate(xForm, Math.random() * 360.0, false);
        XFormTransformService.localTranslate(xForm, 1.75 - 3.50 * Math.random(), 0.75 - 5.50 * Math.random(), false);
        XFormTransformService.scale(xForm, 1.1 + Math.random() * 2.0, true, true, false);
    }
    layer.getXForms().get(0).getModifiedWeights()[0] = 0.0;
    layer.getXForms().get(0).getModifiedWeights()[1] = 1.0;
    if (Math.random() > 0.667) {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(1.0 + Math.random() * 100.0);
        VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
        xForm.addVariation(0.25 + 1.25 * Math.random(), varFunc);
        XFormTransformService.rotate(xForm, -12.0 + Math.random() * 24.0, true);
        XFormTransformService.localTranslate(xForm, -0.125 + Math.random() * 0.25, -0.125 + Math.random() * 0.25, true);
        XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.2, true, true, true);
        layer.getXForms().get(0).getModifiedWeights()[1] = 0.0;
        layer.getXForms().get(1).getModifiedWeights()[2] = 0.0;
        layer.getXForms().get(2).getModifiedWeights()[2] = 0.0;
        if (Math.random() > 0.667) {
            xForm = new XForm();
            layer.getXForms().add(xForm);
            xForm.setWeight(0.50 + Math.random() * 50.0);
            varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
            xForm.addVariation(0.125 + 0.75 * Math.random(), varFunc);
            XFormTransformService.rotate(xForm, -24.0 + Math.random() * 48.0, true);
            XFormTransformService.localTranslate(xForm, -0.25 + Math.random() * 0.5, -0.25 + Math.random() * 0.5, true);
            XFormTransformService.scale(xForm, 0.5 + Math.random() * 0.25, true, true, true);
            layer.getXForms().get(0).getModifiedWeights()[2] = 0.0;
            layer.getXForms().get(2).getModifiedWeights()[2] = 0.0;
            layer.getXForms().get(1).getModifiedWeights()[3] = 0.0;
            layer.getXForms().get(2).getModifiedWeights()[3] = 0.0;
            layer.getXForms().get(3).getModifiedWeights()[3] = 0.0;
        }
    }
    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 82 with Layer

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

the class ExperimentalBubbles3DRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    Flame flame = super.prepareFlame(pState);
    Layer layer = flame.getFirstLayer();
    // modify last xForm
    {
        XForm xForm = layer.getXForms().get(layer.getXForms().size() - 1);
        XFormTransformService.scale(xForm, 0.5 + 5.0 * Math.random(), Math.random() < 0.75, Math.random() < 0.75, false);
        XFormTransformService.rotate(xForm, 180.0 - Math.random() * 360.0, false);
        XFormTransformService.localTranslate(xForm, 4.0 - 8.0 * Math.random(), 4.0 - 8.0 * Math.random(), false);
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer) Flame(org.jwildfire.create.tina.base.Flame)

Example 83 with Layer

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

the class ExperimentalGnarlRandomFlameGenerator method prepareFlame.

@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
    // Bases loosely on the W2R Batch Script by parrotdolphin.deviantart.com */
    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();
    // init
    double scaleX = Math.random() * 0.04 + 0.04;
    if (Math.random() > 0.75) {
        scaleX = 0 - scaleX;
    }
    double scaleY = Math.random() * 0.04 + 0.04;
    if (Math.random() > 0.75) {
        scaleY = 0 - scaleY;
    } else if (Math.random() < 0.25) {
        scaleY = scaleX;
    }
    double freqX = Math.random() * 2.0 + 7.0;
    double freqY;
    if (Math.random() < 0.25) {
        freqY = freqX;
    } else {
        freqY = Math.random() * 2.0 + 7.0;
    }
    double blurAmount = 0.0025 * Math.random();
    double nonBlurAmount = 0.25 * Math.random();
    double wavesWeight = Math.random() * 10 + 75;
    double _2ndWeight = 0.5;
    double _3rdWeight = 0.5;
    double symmetry = 0.6 + Math.random() * 0.4;
    int sides = (int) (Math.random() * 11.0 + 2.0);
    // 1st XForm
    {
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(wavesWeight);
        double varRnd = Math.random();
        VariationFunc w2;
        if (Math.random() > 0.5) {
            w2 = createExpWaves2Variation(scaleX, scaleY, freqX, freqY, varRnd);
        } else {
            if (Math.random() < 0.25) {
                w2 = GnarlRandomFlameGenerator.createWaves2Variation(scaleX, scaleY, freqX, freqY);
            } else {
                w2 = GnarlRandomFlameGenerator.createWaves2BVariation(scaleX, scaleY, freqX, freqY);
            }
        }
        xForm.addVariation(1, w2);
        switch(Tools.randomInt(36)) {
            case 0:
                xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance("blur", true));
                break;
            case 1:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("cos", true));
                break;
            case 2:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("exp", true));
                break;
            case 3:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("exponential", true));
                break;
            case 4:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("lazysusan", true));
                break;
            case 5:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("ngon", true));
                break;
            case 6:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("sech", true));
                break;
            case 7:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("sinh", true));
                break;
            case 8:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("epispiral_wf", true));
                break;
            case 9:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("tanh", true));
                break;
            case 10:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("twintrian", true));
                break;
            case 11:
                xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance("bubble", true));
                break;
            case 12:
                xForm.addVariation(nonBlurAmount, VariationFuncList.getVariationFuncInstance("epispiral", true));
                break;
            default:
                {
                    int l = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length;
                    String fName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[Tools.randomInt(l)];
                    xForm.addVariation(blurAmount, VariationFuncList.getVariationFuncInstance(fName, true));
                }
        }
        xForm.setColorSymmetry(symmetry);
        xForm.setColor(0.9);
        if (Math.random() > 0.5) {
            XFormTransformService.scale(xForm, 0.9 + Math.random() * 0.09, true, true);
        }
        double angle, tx, ty;
        switch(sides) {
            case 2:
                angle = -180;
                tx = Math.random() * 8 - 4;
                ty = Math.random() * 8 - 4;
                break;
            case 3:
                angle = -120;
                tx = Math.random() * 8 - 4;
                ty = Math.random() * 8 - 4;
                break;
            case 4:
                angle = -90;
                tx = Math.random() * 8 - 4;
                ty = Math.random() * 8 - 4;
                break;
            case 5:
                angle = -72;
                tx = Math.random() * 7 - 3.5;
                ty = Math.random() * 7 - 3.5;
                break;
            case 6:
                angle = -60;
                tx = Math.random() * 7 - 3.5;
                ty = Math.random() * 7 - 3.5;
                break;
            case 7:
                angle = -51.42857;
                tx = Math.random() * 6 - 3;
                ty = Math.random() * 6 - 3;
                break;
            case 8:
                angle = -135;
                tx = Math.random() * 6 - 3;
                ty = Math.random() * 6 - 3;
                break;
            case 9:
                angle = -40;
                tx = Math.random() * 5 - 2.5;
                ty = Math.random() * 5 - 2.5;
                break;
            case 10:
                angle = -36;
                tx = Math.random() * 4 - 2;
                ty = Math.random() * 4 - 2;
                break;
            case 11:
                angle = -32.73;
                tx = Math.random() * 4.2 - 3;
                ty = Math.random() * 4.2 - 3;
                break;
            case 12:
                angle = -30;
                tx = Math.random() * 4.2 - 3;
                ty = Math.random() * 4.2 - 3;
                break;
            default:
                throw new IllegalStateException();
        }
        XFormTransformService.rotate(xForm, angle);
        XFormTransformService.localTranslate(xForm, tx, ty);
    }
    // 2nd XForm
    XForm secondXForm;
    {
        XForm xForm = secondXForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(_2ndWeight);
        int f = Tools.randomInt(4);
        switch(f) {
            case 0:
                xForm.addVariation(Math.random() * 0.7 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
                break;
            case 1:
                xForm.addVariation(Math.random() * 0.7 + 0.3, VariationFuncList.getVariationFuncInstance("bubble", true));
                xForm.addVariation(Math.random() * 0.7 + 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
                break;
            case 2:
                xForm.addVariation(Math.random() * 0.1, VariationFuncList.getVariationFuncInstance("radial_blur", true));
                JuliaNFunc juliaN = (JuliaNFunc) VariationFuncList.getVariationFuncInstance("julian", true);
                juliaN.setParameter("power", 50 - Math.random() * 100);
                juliaN.setParameter("dist", Math.random() * 10 - 2);
                xForm.addVariation(Math.random() * 0.06 + 0.1, juliaN);
                break;
            case 3:
                xForm.addVariation(Math.random() * 0.7 + 0.3, VariationFuncList.getVariationFuncInstance("spherical3D", true));
                break;
            default:
                // nothing to do
                break;
        }
        XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0);
        if (Math.random() > 0.5) {
            XFormTransformService.scale(xForm, 0.5 + Math.random() * 1.0, true, true);
        }
        xForm.setColorSymmetry(-1);
    }
    // 3rd XForm
    if (Math.random() > 0.75) {
        if (Math.random() > 0.5) {
            secondXForm.setWeight(5 + Math.random() * 20.0);
        }
        XForm xForm = new XForm();
        layer.getXForms().add(xForm);
        xForm.setWeight(_3rdWeight);
        xForm.addVariation(1.0, VariationFuncList.getVariationFuncInstance("linear3D", true));
        XFormTransformService.rotate(xForm, 180 - Math.random() * 360.0);
        XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random());
        xForm.setColorSymmetry(-1);
    }
    return flame;
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) JuliaNFunc(org.jwildfire.create.tina.variation.JuliaNFunc) Layer(org.jwildfire.create.tina.base.Layer) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc) Flame(org.jwildfire.create.tina.base.Flame)

Example 84 with Layer

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

the class AbstractAffine3DRandomFlameGenerator method rotateXForm.

protected void rotateXForm(Flame pFlame, int idx, double amp0) {
    Layer layer = pFlame.getFirstLayer();
    if (layer.getXForms().size() > idx) {
        pFlame.setEditPlane(EditPlane.ZX);
        XForm xform = layer.getXForms().get(idx);
        XFormTransformService.rotate(xform, (0.5 - Math.random()) * amp0);
        pFlame.setEditPlane(EditPlane.XY);
    }
}
Also used : XForm(org.jwildfire.create.tina.base.XForm) Layer(org.jwildfire.create.tina.base.Layer)

Example 85 with Layer

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

the class JWFScriptController method convertFlameToScript.

private String convertFlameToScript(Flame pFlame) {
    StringBuilder sb = new StringBuilder();
    sb.append("import org.jwildfire.create.tina.base.Flame;\n");
    sb.append("import org.jwildfire.create.tina.base.XForm;\n");
    sb.append("import org.jwildfire.create.tina.palette.RGBPalette;\n");
    sb.append("import org.jwildfire.create.tina.script.ScriptRunnerEnvironment;\n");
    sb.append("import org.jwildfire.create.tina.transform.XFormTransformService;\n");
    sb.append("import org.jwildfire.create.tina.base.Layer;\n");
    sb.append("import org.jwildfire.create.tina.variation.Variation;\n");
    sb.append("import org.jwildfire.create.tina.variation.VariationFunc;\n");
    sb.append("import org.jwildfire.create.tina.variation.VariationFuncList;\n");
    sb.append("import org.jwildfire.create.tina.mutagen.RandomGradientMutation;\n");
    sb.append("import org.jwildfire.create.tina.transform.XFormTransformService;\n");
    sb.append("import org.jwildfire.create.tina.base.EditPlane;\n");
    sb.append("\n");
    sb.append("");
    sb.append("public void run(ScriptRunnerEnvironment pEnv) throws Exception {\n");
    sb.append("  // create a new flame\n");
    sb.append("  Flame flame=new Flame();\n");
    sb.append("  flame.getLayers().clear(); // get rid of the default layer because we create all layers by ourselves\n");
    sb.append("  // set the flame main attributes\n");
    sb.append("  flame.setCamRoll(" + Tools.doubleToString(pFlame.getCamRoll()) + ");\n");
    sb.append("  flame.setCamPitch(" + Tools.doubleToString(pFlame.getCamPitch()) + ");\n");
    sb.append("  flame.setCamYaw(" + Tools.doubleToString(pFlame.getCamYaw()) + ");\n");
    sb.append("  flame.setCamPerspective(" + Tools.doubleToString(pFlame.getCamPerspective()) + ");\n");
    sb.append("  flame.setWidth(" + pFlame.getWidth() + ");\n");
    sb.append("  flame.setHeight(" + pFlame.getHeight() + ");\n");
    sb.append("  flame.setPixelsPerUnit(" + Tools.doubleToString(pFlame.getPixelsPerUnit()) + ");\n");
    sb.append("  flame.setCamZoom(" + Tools.doubleToString(pFlame.getCamZoom()) + ");\n");
    sb.append("  flame.setBGTransparency(" + pFlame.isBGTransparency() + ");\n");
    switch(pFlame.getPostSymmetryType()) {
        case POINT:
            sb.append("  flame.setPostSymmetryType(org.jwildfire.create.tina.base.PostSymmetryType." + pFlame.getPostSymmetryType().toString() + ");\n");
            sb.append("  flame.setPostSymmetryOrder(" + pFlame.getPostSymmetryOrder() + ");\n");
            sb.append("  flame.setPostSymmetryCentreX(" + Tools.doubleToString(pFlame.getPostSymmetryCentreX()) + ");\n");
            sb.append("  flame.setPostSymmetryCentreY(" + Tools.doubleToString(pFlame.getPostSymmetryCentreY()) + ");\n");
            break;
        case X_AXIS:
        case Y_AXIS:
            sb.append("  flame.setPostSymmetryType(org.jwildfire.create.tina.base.PostSymmetryType." + pFlame.getPostSymmetryType().toString() + ");\n");
            sb.append("  flame.setPostSymmetryDistance(" + Tools.doubleToString(pFlame.getPostSymmetryDistance()) + ");\n");
            sb.append("  flame.setPostSymmetryRotation(" + Tools.doubleToString(pFlame.getPostSymmetryRotation()) + ");\n");
            sb.append("  flame.setPostSymmetryCentreX(" + Tools.doubleToString(pFlame.getPostSymmetryCentreX()) + ");\n");
            sb.append("  flame.setPostSymmetryCentreY(" + Tools.doubleToString(pFlame.getPostSymmetryCentreY()) + ");\n");
            break;
        default:
            // nothing to do
            break;
    }
    if (pFlame.getSolidRenderSettings().isSolidRenderingEnabled()) {
        sb.append(" //// Begin of solid-rendering-settings\n");
        sb.append(" flame.getSolidRenderSettings().setSolidRenderingEnabled(true);\n");
        sb.append(" // Ambient shadows\n");
        sb.append(" flame.getSolidRenderSettings().setAoEnabled(" + (pFlame.getSolidRenderSettings().isAoEnabled() ? "true" : "false") + ");\n");
        if (pFlame.getSolidRenderSettings().isAoEnabled()) {
            sb.append(" flame.getSolidRenderSettings().setAoIntensity(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getAoIntensity()) + ");\n");
            sb.append(" flame.getSolidRenderSettings().setAoSearchRadius(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getAoSearchRadius()) + ");\n");
            sb.append(" flame.getSolidRenderSettings().setAoBlurRadius(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getAoBlurRadius()) + ");\n");
            sb.append(" flame.getSolidRenderSettings().setAoRadiusSamples(" + pFlame.getSolidRenderSettings().getAoRadiusSamples() + ");\n");
            sb.append(" flame.getSolidRenderSettings().setAoAzimuthSamples(" + pFlame.getSolidRenderSettings().getAoAzimuthSamples() + ");\n");
            sb.append(" flame.getSolidRenderSettings().setAoFalloff(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getAoFalloff()) + ");\n");
            sb.append(" flame.getSolidRenderSettings().setAoAffectDiffuse(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getAoAffectDiffuse()) + ");\n");
        }
        sb.append(" // Hard shadows\n");
        sb.append(" flame.getSolidRenderSettings().setShadowType(" + pFlame.getSolidRenderSettings().getShadowType().getClass().getName() + "." + pFlame.getSolidRenderSettings().getShadowType().toString() + ");\n");
        if (!ShadowType.OFF.equals(pFlame.getSolidRenderSettings().getShadowType())) {
            sb.append(" flame.getSolidRenderSettings().setShadowmapBias(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getShadowmapBias()) + ");\n");
            sb.append(" flame.getSolidRenderSettings().setShadowmapSize(" + pFlame.getSolidRenderSettings().getShadowmapSize() + ");\n");
            if (ShadowType.SMOOTH.equals(pFlame.getSolidRenderSettings().getShadowType())) {
                sb.append(" flame.getSolidRenderSettings().setShadowSmoothRadius(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getShadowSmoothRadius()) + ");\n");
            }
        }
        sb.append(" // Post bokeh\n");
        sb.append(" flame.getSolidRenderSettings().setPostBokehFilterKernel(" + pFlame.getSolidRenderSettings().getPostBokehFilterKernel().getDeclaringClass().getName() + "." + pFlame.getSolidRenderSettings().getPostBokehFilterKernel().toString() + ");\n");
        sb.append(" flame.getSolidRenderSettings().setPostBokehIntensity(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getPostBokehIntensity()) + ");\n");
        sb.append(" flame.getSolidRenderSettings().setPostBokehBrightness(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getPostBokehBrightness()) + ");\n");
        sb.append(" flame.getSolidRenderSettings().setPostBokehSize(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getPostBokehSize()) + ");\n");
        sb.append(" flame.getSolidRenderSettings().setPostBokehActivation(" + Tools.doubleToString(pFlame.getSolidRenderSettings().getPostBokehActivation()) + ");\n");
        sb.append(" // Materials\n");
        sb.append(" flame.getSolidRenderSettings().getMaterials().clear();\n");
        for (MaterialSettings material : pFlame.getSolidRenderSettings().getMaterials()) {
            sb.append(" {\n");
            sb.append("   org.jwildfire.create.tina.base.solidrender.MaterialSettings material = new org.jwildfire.create.tina.base.solidrender.MaterialSettings();\n");
            sb.append("   flame.getSolidRenderSettings().getMaterials().add(material);\n");
            sb.append("   material.setDiffuse(" + Tools.doubleToString(material.getDiffuse()) + ");\n");
            sb.append("   material.setAmbient(" + Tools.doubleToString(material.getAmbient()) + ");\n");
            sb.append("   material.setPhong(" + Tools.doubleToString(material.getPhong()) + ");\n");
            sb.append("   material.setPhongSize(" + Tools.doubleToString(material.getPhongSize()) + ");\n");
            sb.append("   material.setPhongRed(" + Tools.doubleToString(material.getPhongRed()) + ");\n");
            sb.append("   material.setPhongGreen(" + Tools.doubleToString(material.getPhongGreen()) + ");\n");
            sb.append("   material.setPhongBlue(" + Tools.doubleToString(material.getPhongBlue()) + ");\n");
            sb.append("   material.setLightDiffFunc(" + ((LightDiffFuncPreset) material.getLightDiffFunc()).getDeclaringClass().getName() + "." + material.getLightDiffFunc().toString() + ");\n");
            if (material.getReflMapFilename() != null && material.getReflMapFilename().length() > 0) {
                sb.append("   material.setReflMapFilename(\"" + material.getReflMapFilename() + "\");\n");
                sb.append("   material.setReflMapIntensity(" + Tools.doubleToString(material.getReflMapIntensity()) + ");\n");
                sb.append("   material.setReflectionMapping(" + material.getReflectionMapping().getDeclaringClass().getName() + "." + material.getReflectionMapping().toString() + ");\n");
            }
            sb.append(" }\n");
        }
        sb.append(" // Lights\n");
        sb.append(" flame.getSolidRenderSettings().getLights().clear();\n");
        for (DistantLight light : pFlame.getSolidRenderSettings().getLights()) {
            sb.append(" {\n");
            sb.append("   org.jwildfire.create.tina.base.solidrender.DistantLight light = new org.jwildfire.create.tina.base.solidrender.DistantLight();\n");
            sb.append("   flame.getSolidRenderSettings().getLights().add(light);\n");
            sb.append("   light.setRed(" + Tools.doubleToString(light.getRed()) + ");\n");
            sb.append("   light.setGreen(" + Tools.doubleToString(light.getGreen()) + ");\n");
            sb.append("   light.setBlue(" + Tools.doubleToString(light.getBlue()) + ");\n");
            sb.append("   light.setIntensity(" + Tools.doubleToString(light.getIntensity()) + ");\n");
            sb.append("   light.setCastShadows(" + (light.isCastShadows() ? "true" : "false") + ");\n");
            sb.append("   light.setAltitude(" + Tools.doubleToString(light.getAltitude()) + ");\n");
            sb.append("   light.setAzimuth(" + Tools.doubleToString(light.getAzimuth()) + ");\n");
            sb.append("   light.setShadowIntensity(" + Tools.doubleToString(light.getShadowIntensity()) + ");\n");
            sb.append("   // randomize light positions (uncomment to play around)\n");
            sb.append("   // light.setAltitude(180.0 - 360.0 * Math.random());\n");
            sb.append("   // light.setAzimuth(360.0 - 720.0 * Math.random());\n");
            sb.append(" }\n");
        }
        sb.append(" //// End of solid-rendering-settings\n");
    }
    for (int i = 0; i < pFlame.getLayers().size(); i++) {
        Layer layer = pFlame.getLayers().get(i);
        addLayer(sb, layer, i);
    }
    sb.append("  // Either update the currently selected flame (to not need to create a new thumbnail\n");
    sb.append("  // in the thumbnail ribbon after each run of the script...\n");
    sb.append("  Flame selFlame = pEnv.getCurrFlame();\n");
    sb.append("  if(selFlame!=null) {\n");
    sb.append("    selFlame.assign(flame);\n");
    sb.append("    pEnv.refreshUI();\n");
    sb.append("  }\n");
    sb.append("  // ...or load the flame in the editor and refresh the UI\n");
    sb.append("  else {\n");
    sb.append("    pEnv.setCurrFlame(flame);\n");
    sb.append("  }\n");
    sb.append("}\n");
    return sb.toString();
}
Also used : LightDiffFuncPreset(org.jwildfire.create.tina.base.solidrender.LightDiffFuncPreset) MaterialSettings(org.jwildfire.create.tina.base.solidrender.MaterialSettings) DistantLight(org.jwildfire.create.tina.base.solidrender.DistantLight) 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