Search in sources :

Example 1 with LightDiffFuncPreset

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

the class AbstractFlameWriter method createFlameAttributes.

protected List<SimpleXMLBuilder.Attribute<?>> createFlameAttributes(Flame pFlame, SimpleXMLBuilder xb) throws Exception {
    List<SimpleXMLBuilder.Attribute<?>> attrList = new ArrayList<SimpleXMLBuilder.Attribute<?>>();
    String fName = pFlame.getName().replaceAll("\"", "");
    if (!fName.equals("")) {
        attrList.add(xb.createAttr("name", fName));
    }
    String bgImagefilename = pFlame.getBGImageFilename().replaceAll("\"", "");
    if (!bgImagefilename.equals("")) {
        attrList.add(xb.createAttr(ATTR_BACKGROUND_IMAGE, bgImagefilename));
    }
    if (pFlame.getLayers().size() == 1) {
        String name = pFlame.getFirstLayer().getName().replaceAll("\"", "");
        if (!name.equals("")) {
            attrList.add(xb.createAttr(ATTR_LAYER_NAME, name));
        }
        String gradientMapFilename = pFlame.getFirstLayer().getGradientMapFilename().replaceAll("\"", "");
        if (!gradientMapFilename.equals("")) {
            attrList.add(xb.createAttr(ATTR_GRADIENT_MAP, gradientMapFilename));
            attrList.add(xb.createAttr(ATTR_GRADIENT_MAP_HOFFSET, pFlame.getFirstLayer().getGradientMapHorizOffset()));
            attrList.add(xb.createAttr(ATTR_GRADIENT_MAP_HSCALE, pFlame.getFirstLayer().getGradientMapHorizScale()));
            attrList.add(xb.createAttr(ATTR_GRADIENT_MAP_VOFFSET, pFlame.getFirstLayer().getGradientMapVertOffset()));
            attrList.add(xb.createAttr(ATTR_GRADIENT_MAP_VSCALE, pFlame.getFirstLayer().getGradientMapVertScale()));
            attrList.add(xb.createAttr(ATTR_GRADIENT_MAP_LCOLOR_ADD, pFlame.getFirstLayer().getGradientMapLocalColorAdd()));
            attrList.add(xb.createAttr(ATTR_GRADIENT_MAP_LCOLOR_SCALE, pFlame.getFirstLayer().getGradientMapLocalColorScale()));
        }
        attrList.add(xb.createAttr(ATTR_SMOOTH_GRADIENT, pFlame.getFirstLayer().isSmoothGradient() ? "1" : "0"));
    }
    attrList.add(xb.createAttr("version", Tools.APP_TITLE + " " + Tools.APP_VERSION));
    attrList.add(xb.createAttr("size", pFlame.getWidth() + " " + pFlame.getHeight()));
    attrList.add(xb.createAttr("center", pFlame.getCentreX() + " " + pFlame.getCentreY()));
    attrList.add(xb.createAttr("scale", pFlame.getPixelsPerUnit()));
    attrList.add(xb.createAttr("rotate", pFlame.getCamRoll()));
    attrList.add(xb.createAttr("filter", pFlame.getSpatialFilterRadius()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_FILTER_TYPE, pFlame.getSpatialFilteringType().toString()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_FILTER_KERNEL, pFlame.getSpatialFilterKernel().toString()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_FILTER_INDICATOR, pFlame.isSpatialFilterIndicator() ? 1 : 0));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_FILTER_SHARPNESS, pFlame.getSpatialFilterSharpness()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_FILTER_LOW_DENSITY, pFlame.getSpatialFilterLowDensity()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SPATIAL_OVERSAMPLE, pFlame.getSpatialOversampling()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_NOISE_FILTER, pFlame.isPostNoiseFilter() ? 1 : 0));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_NOISE_FILTER_THRESHOLD, pFlame.getPostNoiseFilterThreshold()));
    attrList.add(xb.createAttr("quality", pFlame.getSampleDensity()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BACKGROUND_TYPE, pFlame.getBgColorType().toString()));
    if (BGColorType.GRADIENT_2X2.equals(pFlame.getBgColorType()) || BGColorType.GRADIENT_2X2_C.equals(pFlame.getBgColorType())) {
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BACKGROUND_UL, (double) pFlame.getBgColorULRed() / 255.0 + " " + (double) pFlame.getBgColorULGreen() / 255.0 + " " + (double) pFlame.getBgColorULBlue() / 255.0));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BACKGROUND_UR, (double) pFlame.getBgColorURRed() / 255.0 + " " + (double) pFlame.getBgColorURGreen() / 255.0 + " " + (double) pFlame.getBgColorURBlue() / 255.0));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BACKGROUND_LL, (double) pFlame.getBgColorLLRed() / 255.0 + " " + (double) pFlame.getBgColorLLGreen() / 255.0 + " " + (double) pFlame.getBgColorLLBlue() / 255.0));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BACKGROUND_LR, (double) pFlame.getBgColorLRRed() / 255.0 + " " + (double) pFlame.getBgColorLRGreen() / 255.0 + " " + (double) pFlame.getBgColorLRBlue() / 255.0));
    }
    if (BGColorType.GRADIENT_2X2_C.equals(pFlame.getBgColorType())) {
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BACKGROUND_CC, (double) pFlame.getBgColorCCRed() / 255.0 + " " + (double) pFlame.getBgColorCCGreen() / 255.0 + " " + (double) pFlame.getBgColorCCBlue() / 255.0));
    }
    if (BGColorType.SINGLE_COLOR.equals(pFlame.getBgColorType())) {
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BACKGROUND, (double) pFlame.getBgColorRed() / 255.0 + " " + (double) pFlame.getBgColorGreen() / 255.0 + " " + (double) pFlame.getBgColorBlue() / 255.0));
    }
    attrList.add(xb.createAttr("bg_transparency", pFlame.isBGTransparency() ? "1" : "0"));
    attrList.add(xb.createAttr("brightness", pFlame.getBrightness()));
    attrList.add(xb.createAttr(ATTR_SATURATION, pFlame.getSaturation()));
    attrList.add(xb.createAttr("gamma", pFlame.getGamma()));
    attrList.add(xb.createAttr("gamma_threshold", pFlame.getGammaThreshold()));
    attrList.add(xb.createAttr("vibrancy", pFlame.getVibrancy()));
    attrList.add(xb.createAttr("contrast", pFlame.getContrast()));
    attrList.add(xb.createAttr(ATTR_WHITE_LEVEL, pFlame.getWhiteLevel()));
    attrList.add(xb.createAttr("temporal_samples", 1.0));
    attrList.add(xb.createAttr("cam_zoom", pFlame.getCamZoom()));
    attrList.add(xb.createAttr("cam_pitch", (pFlame.getCamPitch() * Math.PI) / 180.0));
    attrList.add(xb.createAttr("cam_yaw", (pFlame.getCamYaw() * Math.PI) / 180.0));
    attrList.add(xb.createAttr("cam_persp", pFlame.getCamPerspective()));
    attrList.add(xb.createAttr("cam_xfocus", pFlame.getFocusX()));
    attrList.add(xb.createAttr("cam_yfocus", pFlame.getFocusY()));
    attrList.add(xb.createAttr("cam_zfocus", pFlame.getFocusZ()));
    if (pFlame.getDimishZ() != 0.0) {
        attrList.add(xb.createAttr("cam_zdimish", pFlame.getDimishZ()));
    }
    attrList.add(xb.createAttr(ATTR_CAM_POS_X, pFlame.getCamPosX()));
    attrList.add(xb.createAttr(ATTR_CAM_POS_Y, pFlame.getCamPosY()));
    attrList.add(xb.createAttr(ATTR_CAM_POS_Z, pFlame.getCamPosZ()));
    attrList.add(xb.createAttr("cam_zpos", pFlame.getCamZ()));
    attrList.add(xb.createAttr("cam_dof", pFlame.getCamDOF()));
    attrList.add(xb.createAttr("cam_dof_area", pFlame.getCamDOFArea()));
    attrList.add(xb.createAttr("cam_dof_exponent", pFlame.getCamDOFExponent()));
    if (pFlame.isNewCamDOF()) {
        attrList.add(xb.createAttr("new_dof", "1"));
    }
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_LOW_DENSITY_BRIGHTNESS, pFlame.getLowDensityBrightness()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BALANCING_RED, pFlame.getBalanceRed()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BALANCING_GREEN, pFlame.getBalanceGreen()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_BALANCING_BLUE, pFlame.getBalanceBlue()));
    attrList.add(xb.createAttr(ATTR_CAM_DOF_SHAPE, pFlame.getCamDOFShape().toString()));
    attrList.add(xb.createAttr(ATTR_CAM_DOF_SCALE, pFlame.getCamDOFScale()));
    attrList.add(xb.createAttr(ATTR_CAM_DOF_ROTATE, pFlame.getCamDOFAngle()));
    attrList.add(xb.createAttr(ATTR_CAM_DOF_FADE, pFlame.getCamDOFFade()));
    DOFBlurShape shape = pFlame.getCamDOFShape().getDOFBlurShape();
    if (shape != null) {
        List<String> paramNames = shape.getParamNames();
        if (paramNames.size() > 0) {
            attrList.add(xb.createAttr(ATTR_CAM_DOF_PARAM1, pFlame.getCamDOFParam1()));
            if (paramNames.size() > 1) {
                attrList.add(xb.createAttr(ATTR_CAM_DOF_PARAM2, pFlame.getCamDOFParam2()));
                if (paramNames.size() > 2) {
                    attrList.add(xb.createAttr(ATTR_CAM_DOF_PARAM3, pFlame.getCamDOFParam3()));
                    if (paramNames.size() > 3) {
                        attrList.add(xb.createAttr(ATTR_CAM_DOF_PARAM4, pFlame.getCamDOFParam4()));
                        if (paramNames.size() > 4) {
                            attrList.add(xb.createAttr(ATTR_CAM_DOF_PARAM5, pFlame.getCamDOFParam5()));
                            if (paramNames.size() > 5) {
                                attrList.add(xb.createAttr(ATTR_CAM_DOF_PARAM6, pFlame.getCamDOFParam6()));
                            }
                        }
                    }
                }
            }
        }
    }
    if (pFlame.isPreserveZ()) {
        attrList.add(xb.createAttr("preserve_z", "1"));
    }
    if (pFlame.getResolutionProfile() != null && pFlame.getResolutionProfile().length() > 0)
        attrList.add(xb.createAttr("resolution_profile", pFlame.getResolutionProfile()));
    if (pFlame.getQualityProfile() != null && pFlame.getQualityProfile().length() > 0)
        attrList.add(xb.createAttr("quality_profile", pFlame.getQualityProfile()));
    attrList.add(xb.createAttr("antialias_amount", pFlame.getAntialiasAmount()));
    attrList.add(xb.createAttr("antialias_radius", pFlame.getAntialiasRadius()));
    if (pFlame.getMotionBlurLength() > 0) {
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_MOTIONBLUR_LENGTH, pFlame.getMotionBlurLength()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_MOTIONBLUR_TIMESTEP, pFlame.getMotionBlurTimeStep()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_MOTIONBLUR_DECAY, pFlame.getMotionBlurDecay()));
    }
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_SYMMETRY_TYPE, pFlame.getPostSymmetryType().toString()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_SYMMETRY_ORDER, pFlame.getPostSymmetryOrder()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_SYMMETRY_CENTREX, pFlame.getPostSymmetryCentreX()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_SYMMETRY_CENTREY, pFlame.getPostSymmetryCentreY()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_SYMMETRY_DISTANCE, pFlame.getPostSymmetryDistance()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_SYMMETRY_ROTATION, pFlame.getPostSymmetryRotation()));
    if (pFlame.getStereo3dMode() != Stereo3dMode.NONE) {
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_STEREO3D_MODE, pFlame.getStereo3dMode().toString()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_STEREO3D_ANGLE, pFlame.getStereo3dAngle()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_STEREO3D_EYE_DIST, pFlame.getStereo3dEyeDist()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_STEREO3D_FOCAL_OFFSET, pFlame.getStereo3dFocalOffset()));
        if (pFlame.getStereo3dMode() == Stereo3dMode.ANAGLYPH) {
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_STEREO3D_LEFT_EYE_COLOR, pFlame.getStereo3dLeftEyeColor().toString()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_STEREO3D_RIGHT_EYE_COLOR, pFlame.getStereo3dRightEyeColor().toString()));
        } else if (pFlame.getStereo3dMode() == Stereo3dMode.INTERPOLATED_IMAGES) {
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_STEREO3D_INTERPOLATED_IMAGE_COUNT, pFlame.getStereo3dInterpolatedImageCount()));
        }
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_STEREO3D_PREVIEW, pFlame.getStereo3dPreview().toString()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_STEREO3D_SWAP_SIDES, pFlame.isStereo3dSwapSides() ? "1" : "0"));
    }
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_FRAME, pFlame.getFrame()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_FRAME_COUNT, pFlame.getFrameCount()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_FPS, pFlame.getFps()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POSTBLUR_RADIUS, pFlame.getPostBlurRadius()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POSTBLUR_FADE, pFlame.getPostBlurFade()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POSTBLUR_FALLOFF, pFlame.getPostBlurFallOff()));
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_ZBUFFER_SCALE, pFlame.getZBufferScale()));
    if (pFlame.getSolidRenderSettings().isSolidRenderingEnabled()) {
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_ENABLED, pFlame.getSolidRenderSettings().isSolidRenderingEnabled()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_AO_ENABLED, pFlame.getSolidRenderSettings().isAoEnabled()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_AO_INTENSITY, pFlame.getSolidRenderSettings().getAoIntensity()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_AO_SEARCH_RADIUS, pFlame.getSolidRenderSettings().getAoSearchRadius()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_AO_BLUR_RADIUS, pFlame.getSolidRenderSettings().getAoBlurRadius()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_AO_RADIUS_SAMPLES, pFlame.getSolidRenderSettings().getAoRadiusSamples()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_AO_AZIMUTH_SAMPLES, pFlame.getSolidRenderSettings().getAoAzimuthSamples()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_AO_FALLOFF, pFlame.getSolidRenderSettings().getAoFalloff()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_AO_AFFECT_DIFFUSE, pFlame.getSolidRenderSettings().getAoAffectDiffuse()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_SHADOW_TYPE, pFlame.getSolidRenderSettings().getShadowType().toString()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_SHADOW_SMOOTH_RADIUS, pFlame.getSolidRenderSettings().getShadowSmoothRadius()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_SHADOWMAP_SIZE, pFlame.getSolidRenderSettings().getShadowmapSize()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_SHADOWMAP_BIAS, pFlame.getSolidRenderSettings().getShadowmapBias()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_BOKEH_FILTER_KERNEL, pFlame.getSolidRenderSettings().getPostBokehFilterKernel().toString()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_BOKEH_INTENSITY, pFlame.getSolidRenderSettings().getPostBokehIntensity()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_BOKEH_BRIGHTNESS, pFlame.getSolidRenderSettings().getPostBokehBrightness()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_BOKEH_SIZE, pFlame.getSolidRenderSettings().getPostBokehSize()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_POST_BOKEH_ACTIVATION, pFlame.getSolidRenderSettings().getPostBokehActivation()));
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_COUNT, pFlame.getSolidRenderSettings().getMaterials().size()));
        for (int i = 0; i < pFlame.getSolidRenderSettings().getMaterials().size(); i++) {
            MaterialSettings material = pFlame.getSolidRenderSettings().getMaterials().get(i);
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_DIFFUSE + i, material.getDiffuse()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_AMBIENT + i, material.getAmbient()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_PHONG + i, material.getPhong()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_PHONG_SIZE + i, material.getPhongSize()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_PHONG_RED + i, material.getPhongRed()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_PHONG_GREEN + i, material.getPhongGreen()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_PHONG_BLUE + i, material.getPhongBlue()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_REFL_MAP_INTENSITY + i, material.getReflMapIntensity()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_REFL_MAP_FILENAME + i, material.getReflMapFilename() != null ? material.getReflMapFilename() : ""));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_REFL_MAPPING + i, material.getReflectionMapping().toString()));
            if (material.getLightDiffFunc() instanceof LightDiffFuncPreset)
                attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_MATERIAL_LIGHT_DIFF_FUNC + i, ((LightDiffFuncPreset) material.getLightDiffFunc()).toString()));
        }
        attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_COUNT, pFlame.getSolidRenderSettings().getLights().size()));
        for (int i = 0; i < pFlame.getSolidRenderSettings().getLights().size(); i++) {
            DistantLight light = pFlame.getSolidRenderSettings().getLights().get(i);
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_ALTITUDE + i, light.getAltitude()));
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_ALTITUDE + i, light.getAltitudeCurve());
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_AZIMUTH + i, light.getAzimuth()));
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_AZIMUTH + i, light.getAzimuthCurve());
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_INTENSITY + i, light.getIntensity()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_RED + i, light.getRed()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_GREEN + i, light.getGreen()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_BLUE + i, light.getBlue()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_SHADOWS + i, light.isCastShadows()));
            attrList.add(xb.createAttr(AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_SHADOW_INTENSITY + i, light.getShadowIntensity()));
        }
    }
    writeMotionCurves(pFlame, xb, attrList, null, flameAttrMotionCurveBlackList);
    attrList.add(xb.createAttr(AbstractFlameReader.ATTR_CHANNEL_MIXER_MODE, pFlame.getChannelMixerMode().toString()));
    switch(pFlame.getChannelMixerMode()) {
        case BRIGHTNESS:
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_RR_CURVE, pFlame.getMixerRRCurve());
            break;
        case RGB:
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_RR_CURVE, pFlame.getMixerRRCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_GG_CURVE, pFlame.getMixerGGCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_BB_CURVE, pFlame.getMixerBBCurve());
            break;
        case FULL:
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_RR_CURVE, pFlame.getMixerRRCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_RG_CURVE, pFlame.getMixerRGCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_RB_CURVE, pFlame.getMixerRBCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_GR_CURVE, pFlame.getMixerGRCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_GG_CURVE, pFlame.getMixerGGCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_GB_CURVE, pFlame.getMixerGBCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_BR_CURVE, pFlame.getMixerBRCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_BG_CURVE, pFlame.getMixerBGCurve());
            writeMotionCurve(xb, attrList, AbstractFlameReader.ATTR_CHANNEL_MIXER_BB_CURVE, pFlame.getMixerBBCurve());
            break;
        default:
            break;
    }
    return attrList;
}
Also used : DOFBlurShape(org.jwildfire.create.tina.render.dof.DOFBlurShape) LightDiffFuncPreset(org.jwildfire.create.tina.base.solidrender.LightDiffFuncPreset) MotionCurveAttribute(org.jwildfire.create.tina.animate.AnimationService.MotionCurveAttribute) MaterialSettings(org.jwildfire.create.tina.base.solidrender.MaterialSettings) ArrayList(java.util.ArrayList) DistantLight(org.jwildfire.create.tina.base.solidrender.DistantLight)

Example 2 with LightDiffFuncPreset

use of org.jwildfire.create.tina.base.solidrender.LightDiffFuncPreset 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

DistantLight (org.jwildfire.create.tina.base.solidrender.DistantLight)2 LightDiffFuncPreset (org.jwildfire.create.tina.base.solidrender.LightDiffFuncPreset)2 MaterialSettings (org.jwildfire.create.tina.base.solidrender.MaterialSettings)2 ArrayList (java.util.ArrayList)1 MotionCurveAttribute (org.jwildfire.create.tina.animate.AnimationService.MotionCurveAttribute)1 Layer (org.jwildfire.create.tina.base.Layer)1 DOFBlurShape (org.jwildfire.create.tina.render.dof.DOFBlurShape)1