Search in sources :

Example 1 with SolidRenderSettings

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

the class AnimationService method _evalMotionCurves.

private static void _evalMotionCurves(Object pObject, double pFrame) throws IllegalAccessException {
    Class<?> cls = pObject.getClass();
    for (Field field : cls.getDeclaredFields()) {
        field.setAccessible(true);
        if (field.getType() == MotionCurve.class && field.getName().endsWith(Tools.CURVE_POSTFIX)) {
            MotionCurve curve = (MotionCurve) field.get(pObject);
            if (curve.isEnabled()) {
                double value = evalCurve(pFrame, curve);
                String propName = field.getName().substring(0, field.getName().length() - Tools.CURVE_POSTFIX.length());
                curve.getChangeHandler().processValueChange(pObject, propName, value);
                if (pObject instanceof RGBPalette) {
                    curve.getChangeHandler().processValueChange(pObject, "modified", 1.0);
                }
            // setPropertyValue(pObject, propName, value);
            // System.out.println(propName + " " + value);
            }
        } else if (field.getType().isAssignableFrom(ArrayList.class)) {
            List<?> childs = (List<?>) field.get(pObject);
            for (Object child : childs) {
                _evalMotionCurves(child, pFrame);
            }
        } else if (field.getType().isAssignableFrom(RGBPalette.class)) {
            RGBPalette gradient = (RGBPalette) field.get(pObject);
            _evalMotionCurves(gradient, pFrame);
        } else if (field.getType().isAssignableFrom(SolidRenderSettings.class)) {
            SolidRenderSettings settings = (SolidRenderSettings) field.get(pObject);
            _evalMotionCurves(settings, pFrame);
        }
    }
    if (pObject instanceof Variation) {
        Variation var = (Variation) pObject;
        VariationFunc func = var.getFunc();
        for (String name : func.getParameterNames()) {
            MotionCurve curve = var.getMotionCurve(name);
            if (curve != null && curve.isEnabled()) {
                double value = evalCurve(pFrame, curve);
                try {
                    func.setParameter(name, value);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            }
        }
    }
}
Also used : RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) ArrayList(java.util.ArrayList) SolidRenderSettings(org.jwildfire.create.tina.base.solidrender.SolidRenderSettings) Field(java.lang.reflect.Field) MotionCurve(org.jwildfire.create.tina.base.motion.MotionCurve) ArrayList(java.util.ArrayList) List(java.util.List) Variation(org.jwildfire.create.tina.variation.Variation) VariationFunc(org.jwildfire.create.tina.variation.VariationFunc)

Example 2 with SolidRenderSettings

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

the class EnvelopeDialog method findProperty.

private String findProperty(Object pObject, Object pProperty, String pPath) {
    if (pObject == pProperty) {
        return pPath;
    }
    Class<?> cls = pObject.getClass();
    for (Field field : cls.getDeclaredFields()) {
        field.setAccessible(true);
        Object fieldValue;
        try {
            fieldValue = field.get(pObject);
        } catch (Exception ex) {
            fieldValue = null;
        }
        if (fieldValue != null) {
            if (fieldValue == pProperty) {
                String pathExt = field.getName();
                return pPath == null ? pathExt : pPath + PATH_SEPARATOR + pathExt;
            }
            if (fieldValue instanceof List) {
                List<?> list = (List<?>) fieldValue;
                for (int i = 0; i < list.size(); i++) {
                    String pathExt = field.getName() + "[" + i + "]";
                    String subPath = pPath == null ? pathExt : pPath + PATH_SEPARATOR + pathExt;
                    String subResult = findProperty(list.get(i), pProperty, subPath);
                    if (subResult != null) {
                        return subResult;
                    }
                }
            } else if (fieldValue instanceof Map) {
                Map<?, ?> map = (Map<?, ?>) fieldValue;
                Set<?> entrySet = map.entrySet();
                for (Object obj : entrySet) {
                    Entry<?, ?> entry = (Entry<?, ?>) obj;
                    String pathExt = field.getName() + "[" + entry.getKey().toString() + "]";
                    String subPath = pPath == null ? pathExt : pPath + PATH_SEPARATOR + pathExt;
                    String subResult = findProperty(entry.getValue(), pProperty, subPath);
                    if (subResult != null) {
                        return subResult;
                    }
                }
            } else if (fieldValue instanceof RGBPalette) {
                RGBPalette palette = (RGBPalette) fieldValue;
                String pathExt = field.getName();
                String subPath = pPath == null ? pathExt : pPath + PATH_SEPARATOR + pathExt;
                String subResult = findProperty(palette, pProperty, subPath);
                if (subResult != null) {
                    return subResult;
                }
            } else if (fieldValue instanceof SolidRenderSettings) {
                SolidRenderSettings settings = (SolidRenderSettings) fieldValue;
                String pathExt = field.getName();
                String subPath = pPath == null ? pathExt : pPath + PATH_SEPARATOR + pathExt;
                String subResult = findProperty(settings, pProperty, subPath);
                if (subResult != null) {
                    return subResult;
                }
            }
        }
    }
    return null;
}
Also used : Set(java.util.Set) RGBPalette(org.jwildfire.create.tina.palette.RGBPalette) SolidRenderSettings(org.jwildfire.create.tina.base.solidrender.SolidRenderSettings) Point(java.awt.Point) Field(java.lang.reflect.Field) Entry(java.util.Map.Entry) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 3 with SolidRenderSettings

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

the class FlameControlsDelegate method getSolidRenderingSelectedLight.

private DistantLight getSolidRenderingSelectedLight() {
    Flame flame = getCurrFlame();
    if (flame != null) {
        SolidRenderSettings settings = flame.getSolidRenderSettings();
        int idx = getSolidRenderingSelectedLightIndex();
        if (idx >= 0 && idx < settings.getLights().size()) {
            return settings.getLights().get(idx);
        }
    }
    return null;
}
Also used : SolidRenderSettings(org.jwildfire.create.tina.base.solidrender.SolidRenderSettings) Flame(org.jwildfire.create.tina.base.Flame)

Example 4 with SolidRenderSettings

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

the class FlameControlsDelegate method refreshSolidRenderingGlobals.

private void refreshSolidRenderingGlobals() {
    enableBokehPanels();
    SolidRenderSettings settings = getCurrFlame().getSolidRenderSettings();
    data.solidRenderingToggleBtn.setSelected(settings.isSolidRenderingEnabled());
    data.tinaSolidRenderingEnableAOCBx.setSelected(settings.isAoEnabled());
    data.tinaSolidRenderingAOIntensityREd.setText(Tools.doubleToString(settings.getAoIntensity()));
    data.tinaSolidRenderingAOIntensitySlider.setValue(Tools.FTOI(settings.getAoIntensity() * TinaController.SLIDER_SCALE_CENTRE));
    data.tinaSolidRenderingAOSearchRadiusREd.setText(Tools.doubleToString(settings.getAoSearchRadius()));
    data.tinaSolidRenderingAOSearchRadiusSlider.setValue(Tools.FTOI(settings.getAoSearchRadius() * TinaController.SLIDER_SCALE_CENTRE));
    data.tinaSolidRenderingAOBlurRadiusREd.setText(Tools.doubleToString(settings.getAoBlurRadius()));
    data.tinaSolidRenderingAOBlurRadiusSlider.setValue(Tools.FTOI(settings.getAoBlurRadius() * TinaController.SLIDER_SCALE_CENTRE));
    data.tinaSolidRenderingAOFalloffREd.setText(Tools.doubleToString(settings.getAoFalloff()));
    data.tinaSolidRenderingAOFalloffSlider.setValue(Tools.FTOI(settings.getAoFalloff() * TinaController.SLIDER_SCALE_CENTRE));
    data.tinaSolidRenderingAORadiusSamplesREd.setText(Tools.doubleToString(settings.getAoRadiusSamples()));
    data.tinaSolidRenderingAORadiusSamplesSlider.setValue(Tools.FTOI(settings.getAoRadiusSamples()));
    data.tinaSolidRenderingAOAzimuthSamplesREd.setText(Tools.doubleToString(settings.getAoAzimuthSamples()));
    data.tinaSolidRenderingAOAzimuthSamplesSlider.setValue(Tools.FTOI(settings.getAoAzimuthSamples()));
    data.tinaSolidRenderingAOAffectDiffuseREd.setText(Tools.doubleToString(settings.getAoAffectDiffuse()));
    data.tinaSolidRenderingAOAffectDiffuseSlider.setValue(Tools.FTOI(settings.getAoAffectDiffuse() * TinaController.SLIDER_SCALE_CENTRE));
    data.tinaSolidRenderingShadowTypeCmb.setSelectedItem(settings.getShadowType());
    data.tinaSolidRenderingShadowmapSizeCmb.setSelectedItem(String.valueOf(settings.getShadowmapSize()));
    if (data.tinaSolidRenderingShadowmapSizeCmb.getSelectedIndex() < 0) {
        data.tinaSolidRenderingShadowmapSizeCmb.setSelectedIndex(0);
    }
    data.tinaSolidRenderingShadowSmoothRadiusREd.setText(Tools.doubleToString(settings.getShadowSmoothRadius()));
    data.tinaSolidRenderingShadowSmoothRadiusSlider.setValue(Tools.FTOI(settings.getShadowSmoothRadius() * TinaController.SLIDER_SCALE_CENTRE));
    data.tinaSolidRenderingShadowmapBiasREd.setText(Tools.doubleToString(settings.getShadowmapBias()));
    data.tinaSolidRenderingShadowmapBiasSlider.setValue(Tools.FTOI(settings.getShadowmapBias() * TinaController.SLIDER_SCALE_CENTRE));
    data.postBokehIntensityREd.setText(Tools.doubleToString(settings.getPostBokehIntensity()));
    data.postBokehIntensitySlider.setValue(Tools.FTOI(settings.getPostBokehIntensity() * TinaController.SLIDER_SCALE_CENTRE));
    data.postBokehBrightnessREd.setText(Tools.doubleToString(settings.getPostBokehBrightness()));
    data.postBokehBrightnessSlider.setValue(Tools.FTOI(settings.getPostBokehBrightness() * TinaController.SLIDER_SCALE_CENTRE));
    data.postBokehSizeREd.setText(Tools.doubleToString(settings.getPostBokehSize()));
    data.postBokehSizeSlider.setValue(Tools.FTOI(settings.getPostBokehSize() * TinaController.SLIDER_SCALE_CENTRE));
    data.postBokehActivationREd.setText(Tools.doubleToString(settings.getPostBokehActivation()));
    data.postBokehActivationSlider.setValue(Tools.FTOI(settings.getPostBokehActivation() * TinaController.SLIDER_SCALE_CENTRE));
    data.postBokehFilterKernelCmb.setSelectedItem(settings.getPostBokehFilterKernel());
}
Also used : SolidRenderSettings(org.jwildfire.create.tina.base.solidrender.SolidRenderSettings)

Example 5 with SolidRenderSettings

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

the class FlameControlsDelegate method solidRenderingShadowTypeCmb_changed.

public void solidRenderingShadowTypeCmb_changed() {
    if (!isNoRefresh()) {
        Flame flame = getCurrFlame();
        if (flame != null) {
            SolidRenderSettings settings = flame.getSolidRenderSettings();
            owner.saveUndoPoint();
            settings.setShadowType((ShadowType) data.tinaSolidRenderingShadowTypeCmb.getSelectedItem());
            enableControls();
            owner.refreshFlameImage(true, false, 1, true, false);
        }
    }
}
Also used : SolidRenderSettings(org.jwildfire.create.tina.base.solidrender.SolidRenderSettings) Flame(org.jwildfire.create.tina.base.Flame)

Aggregations

SolidRenderSettings (org.jwildfire.create.tina.base.solidrender.SolidRenderSettings)9 Flame (org.jwildfire.create.tina.base.Flame)5 Field (java.lang.reflect.Field)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)2 Point (java.awt.Point)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 JTabbedPane (javax.swing.JTabbedPane)1 MotionCurve (org.jwildfire.create.tina.base.motion.MotionCurve)1 Variation (org.jwildfire.create.tina.variation.Variation)1 VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)1