Search in sources :

Example 1 with IFlamesFunc

use of org.jwildfire.create.tina.variation.iflames.IFlamesFunc 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 2 with IFlamesFunc

use of org.jwildfire.create.tina.variation.iflames.IFlamesFunc in project JWildfire by thargor6.

the class IFlamesController method getBaseFlame.

private Flame getBaseFlame() {
    IFlamesFunc iflame = getIFlamesFunc();
    String flameXML = iflame != null ? iflame.getFlameParams(getCurrFlameIndex()).getFlameXML() : null;
    return flameXML != null && flameXML.length() > 0 ? new FlameReader(prefs).readFlamesfromXML(flameXML).get(0) : null;
}
Also used : FlameReader(org.jwildfire.create.tina.io.FlameReader) IFlamesFunc(org.jwildfire.create.tina.variation.iflames.IFlamesFunc)

Example 3 with IFlamesFunc

use of org.jwildfire.create.tina.variation.iflames.IFlamesFunc in project JWildfire by thargor6.

the class IFlamesController method refreshImageFields.

private void refreshImageFields() {
    // TODO Auto-generated method stub
    IFlamesFunc iflame = getIFlamesFunc();
    if (iflame == null) {
        edgesNorthButton.setSelected(false);
        edgesWestButton.setSelected(false);
        edgesEastButton.setSelected(false);
        edgesSouthButton.setSelected(false);
        erodeButton.setSelected(false);
        erodeSizeField.setValue(0.0);
        maxImageWidthField.setValue(0.0);
        structureThresholdField.setValue(0.0);
        structureDensityField.setValue(0.0);
        globalScaleXField.setValue(0.0);
        globalScaleYField.setValue(0.0);
        globalScaleZField.setValue(0.0);
        globalOffsetXField.setValue(0.0);
        globalOffsetYField.setValue(0.0);
        globalOffsetZField.setValue(0.0);
        shapeDistributionCmb.setSelectedIndex(-1);
        iflameBrightnessField.setValue(0.0);
        imageBrightnessField.setValue(0.0);
        iflameDensityField.setValue(0.0);
        previewButton.setSelected(false);
        statisticsTextArea.setText("");
        imageRedChangeField.setValue(0.0);
        imageGreenChangeField.setValue(0.0);
        imageBlueChangeField.setValue(0.0);
        imageHueChangeField.setValue(0.0);
        imageSaturationChangeField.setValue(0.0);
        imageLightnessChangeField.setValue(0.0);
    } else {
        edgesNorthButton.setSelected(iflame.getImageParams().getConv_north() == 1);
        edgesWestButton.setSelected(iflame.getImageParams().getConv_west() == 1);
        edgesEastButton.setSelected(iflame.getImageParams().getConv_east() == 1);
        edgesSouthButton.setSelected(iflame.getImageParams().getConv_south() == 1);
        erodeButton.setSelected(iflame.getImageParams().getErode() == 1);
        erodeSizeField.setValue(iflame.getImageParams().getErodeSize());
        maxImageWidthField.setValue(iflame.getImageParams().getMaxImgWidth());
        structureThresholdField.setValue(iflame.getImageParams().getStructure_threshold());
        structureDensityField.setValue(iflame.getImageParams().getStructure_density());
        globalScaleXField.setValue(iflame.getImageParams().getScaleX());
        globalScaleYField.setValue(iflame.getImageParams().getScaleY());
        globalScaleZField.setValue(iflame.getImageParams().getScaleZ());
        globalOffsetXField.setValue(iflame.getImageParams().getOffsetX());
        globalOffsetYField.setValue(iflame.getImageParams().getOffsetY());
        globalOffsetZField.setValue(iflame.getImageParams().getOffsetZ());
        shapeDistributionCmb.setSelectedItem(iflame.getImageParams().getShape_distribution());
        iflameBrightnessField.setValue(iflame.getImageParams().getIFlame_brightness());
        imageBrightnessField.setValue(iflame.getImageParams().getImage_brightness());
        iflameDensityField.setValue(iflame.getImageParams().getIFlame_density());
        previewButton.setSelected(iflame.getMotionParams().getPreview() == 1);
        imageRedChangeField.setValue(iflame.getImageParams().getColorChangeRed());
        imageGreenChangeField.setValue(iflame.getImageParams().getColorChangeGreen());
        imageBlueChangeField.setValue(iflame.getImageParams().getColorChangeBlue());
        imageHueChangeField.setValue(iflame.getImageParams().getColorChangeHue());
        imageSaturationChangeField.setValue(iflame.getImageParams().getColorChangeSaturation());
        imageLightnessChangeField.setValue(iflame.getImageParams().getColorChangeLightness());
    }
}
Also used : IFlamesFunc(org.jwildfire.create.tina.variation.iflames.IFlamesFunc)

Example 4 with IFlamesFunc

use of org.jwildfire.create.tina.variation.iflames.IFlamesFunc in project JWildfire by thargor6.

the class IFlamesController method enableControls.

public void enableControls() {
    // TODO
    enableUndoControls();
    boolean hasFlame = getFlame() != null;
    IFlamesFunc iflames = getIFlamesFunc();
    boolean hasIFlame = iflames != null;
    String baseFlameXML = hasIFlame ? iflames.getFlameParams(getCurrFlameIndex()).getFlameXML() : null;
    boolean hasBaseFlame = baseFlameXML != null && baseFlameXML.length() > 0;
    loadIFlameButton.setEnabled(true);
    loadIFlameFromClipboardButton.setEnabled(true);
    saveIFlameToClipboardButton.setEnabled(hasFlame);
    saveIFlameButton.setEnabled(hasFlame);
    edgesNorthButton.setEnabled(hasIFlame);
    edgesWestButton.setEnabled(hasIFlame);
    edgesEastButton.setEnabled(hasIFlame);
    edgesSouthButton.setEnabled(hasIFlame);
    erodeButton.setEnabled(hasIFlame);
    displayPreprocessedImageButton.setEnabled(hasIFlame);
    autoRefreshButton.setEnabled(hasIFlame);
    refreshIFlameButton.setEnabled(hasIFlame);
    erodeSizeField.setEnabled(erodeButton.isEnabled() && erodeButton.isSelected());
    maxImageWidthField.setEnabled(hasIFlame);
    baseFlameCmb.setEnabled(hasIFlame);
    structureThresholdField.setEnabled(hasIFlame);
    structureDensityField.setEnabled(hasIFlame);
    globalScaleXField.setEnabled(hasIFlame);
    globalScaleYField.setEnabled(hasIFlame);
    globalScaleZField.setEnabled(hasIFlame);
    globalOffsetXField.setEnabled(hasIFlame);
    globalOffsetYField.setEnabled(hasIFlame);
    globalOffsetZField.setEnabled(hasIFlame);
    shapeDistributionCmb.setEnabled(hasIFlame);
    iflameBrightnessField.setEnabled(hasIFlame);
    imageBrightnessField.setEnabled(hasIFlame);
    iflameDensityField.setEnabled(hasIFlame);
    baseFlameSizeField.setEnabled(hasIFlame);
    baseFlameSizeVariationField.setEnabled(hasIFlame);
    baseFlameRotateAlphaField.setEnabled(hasIFlame);
    baseFlameRotateAlphaVariationField.setEnabled(hasIFlame);
    baseFlameRotateBetaField.setEnabled(hasIFlame);
    baseFlameRotateBetaVariationField.setEnabled(hasIFlame);
    baseFlameRotateGammaField.setEnabled(hasIFlame);
    baseFlameRotateGammaVariationField.setEnabled(hasIFlame);
    baseFlameCentreXField.setEnabled(hasIFlame);
    baseFlameCentreYField.setEnabled(hasIFlame);
    baseFlameCentreZField.setEnabled(hasIFlame);
    baseFlameFromClipboardButton.setEnabled(hasIFlame);
    baseFlameToClipboardButton.setEnabled(hasBaseFlame);
    baseFlameClearButton.setEnabled(hasBaseFlame);
    baseFlameClearAllButton.setEnabled(hasIFlame);
    previewButton.setEnabled(true);
    renderFlameButton.setEnabled(hasFlame);
    selectedMutationCmb.setEnabled(hasBaseFlame);
    paramMinValueField.setEnabled(hasBaseFlame);
    paramMaxValueField.setEnabled(hasBaseFlame);
    paramPropertyPathTree.setEnabled(hasBaseFlame);
    iflameToEditorButton.setEnabled(hasFlame);
    motionTimeField.setEnabled(hasIFlame);
    motionLifeTimeField.setEnabled(hasIFlame);
    motionLifeTimeVariationField.setEnabled(hasIFlame);
    motionForceXField.setEnabled(hasIFlame);
    motionForceYField.setEnabled(hasIFlame);
    motionForceZField.setEnabled(hasIFlame);
    speedXField.setEnabled(hasBaseFlame);
    speedYField.setEnabled(hasBaseFlame);
    speedZField.setEnabled(hasBaseFlame);
    speedXVarField.setEnabled(hasBaseFlame);
    speedYVarField.setEnabled(hasBaseFlame);
    speedZVarField.setEnabled(hasBaseFlame);
    speedAlphaField.setEnabled(hasBaseFlame);
    speedBetaField.setEnabled(hasBaseFlame);
    speedGammaField.setEnabled(hasBaseFlame);
    speedAlphaVarField.setEnabled(hasBaseFlame);
    speedBetaVarField.setEnabled(hasBaseFlame);
    speedGammaVarField.setEnabled(hasBaseFlame);
    radialAccelField.setEnabled(hasBaseFlame);
    radialAccelVarField.setEnabled(hasBaseFlame);
    tangentialAccelField.setEnabled(hasBaseFlame);
    tangentialAccelVarField.setEnabled(hasBaseFlame);
    forceCentreXField.setEnabled(hasIFlame);
    forceCentreYField.setEnabled(hasIFlame);
    forceCentreZField.setEnabled(hasIFlame);
    baseFlameClearOthersButton.setEnabled(hasIFlame);
    copyDynamicsParamsToOthersButton.setEnabled(hasBaseFlame);
    baseFlameBrightnessMinField.setEnabled(hasBaseFlame);
    baseFlameBrightnessMaxField.setEnabled(hasBaseFlame);
    baseFlameBrightnessChangeField.setEnabled(hasBaseFlame);
    imageRedChangeField.setEnabled(hasIFlame);
    imageGreenChangeField.setEnabled(hasIFlame);
    imageBlueChangeField.setEnabled(hasIFlame);
    imageHueChangeField.setEnabled(hasIFlame);
    imageSaturationChangeField.setEnabled(hasIFlame);
    imageLightnessChangeField.setEnabled(hasIFlame);
    baseFlameInstancingCBx.setEnabled(hasIFlame);
    boolean minMaxFields = hasIFlame && (ShapeDistribution.HUE.equals(iflames.getImageParams().getShape_distribution()) || ShapeDistribution.BRIGHTNESS.equals(iflames.getImageParams().getShape_distribution()) || ShapeDistribution.LUMINOSITY.equals(iflames.getImageParams().getShape_distribution()));
    baseFlameMinValueField.setEnabled(minMaxFields);
    baseFlameMaxValueField.setEnabled(minMaxFields);
    boolean weightFields = hasIFlame && ShapeDistribution.RANDOM.equals(iflames.getImageParams().getShape_distribution());
    baseFlameWeightField.setEnabled(weightFields);
    boolean gridFields = hasIFlame && ShapeDistribution.GRID.equals(iflames.getImageParams().getShape_distribution());
    baseFlameGridXOffsetField.setEnabled(gridFields);
    baseFlameGridYOffsetField.setEnabled(gridFields);
    baseFlameGridXSizeField.setEnabled(gridFields);
    baseFlameGridYSizeField.setEnabled(gridFields);
}
Also used : IFlamesFunc(org.jwildfire.create.tina.variation.iflames.IFlamesFunc)

Example 5 with IFlamesFunc

use of org.jwildfire.create.tina.variation.iflames.IFlamesFunc in project JWildfire by thargor6.

the class IFlamesController method refreshMutationFields.

private void refreshMutationFields() {
    IFlamesFunc iflame = getIFlamesFunc();
    if (iflame == null) {
        paramMinValueField.setValue(0.0);
        paramMaxValueField.setValue(0.0);
        paramPropertyPathTree.clearSelection();
    } else {
        FlameParams flameParams = iflame.getFlameParams(getCurrFlameIndex());
        switch(getCurrMutationIndex()) {
            case 0:
                fillMutationFields(getBaseFlame(), flameParams.getFlameParam1Min(), flameParams.getFlameParam1Max(), flameParams.getFlameParam1());
                break;
            case 1:
                fillMutationFields(getBaseFlame(), flameParams.getFlameParam2Min(), flameParams.getFlameParam2Max(), flameParams.getFlameParam2());
                break;
            case 2:
                fillMutationFields(getBaseFlame(), flameParams.getFlameParam3Min(), flameParams.getFlameParam3Max(), flameParams.getFlameParam3());
                break;
            default:
                // nothing to do
                break;
        }
    }
}
Also used : FlameParams(org.jwildfire.create.tina.variation.iflames.FlameParams) IFlamesFunc(org.jwildfire.create.tina.variation.iflames.IFlamesFunc)

Aggregations

IFlamesFunc (org.jwildfire.create.tina.variation.iflames.IFlamesFunc)7 Flame (org.jwildfire.create.tina.base.Flame)1 Layer (org.jwildfire.create.tina.base.Layer)1 XForm (org.jwildfire.create.tina.base.XForm)1 FlameReader (org.jwildfire.create.tina.io.FlameReader)1 FlameWriter (org.jwildfire.create.tina.io.FlameWriter)1 RandomGradientMutation (org.jwildfire.create.tina.mutagen.RandomGradientMutation)1 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)1 FlameParams (org.jwildfire.create.tina.variation.iflames.FlameParams)1