Search in sources :

Example 6 with DistantLight

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

the class AbstractFlameReader method parseFlameAttributes.

protected XMLAttributes parseFlameAttributes(Flame pFlame, String pXML) {
    XMLAttributes atts = Tools.parseAttributes(pXML);
    String hs;
    if ((hs = atts.get(ATTR_NAME)) != null) {
        pFlame.setName(hs);
    }
    if ((hs = atts.get(ATTR_BACKGROUND_IMAGE)) != null) {
        pFlame.setBGImageFilename(hs);
    }
    if ((hs = atts.get(ATTR_LAYER_NAME)) != null && pFlame.getLayers().size() == 1) {
        pFlame.getFirstLayer().setName(hs);
    }
    if ((hs = atts.get(ATTR_GRADIENT_MAP)) != null && pFlame.getLayers().size() == 1) {
        pFlame.getFirstLayer().setGradientMapFilename(hs);
    }
    if ((hs = atts.get(ATTR_GRADIENT_MAP_HOFFSET)) != null && pFlame.getLayers().size() == 1) {
        pFlame.getFirstLayer().setGradientMapHorizOffset(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_GRADIENT_MAP_HSCALE)) != null && pFlame.getLayers().size() == 1) {
        pFlame.getFirstLayer().setGradientMapHorizScale(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_GRADIENT_MAP_VOFFSET)) != null && pFlame.getLayers().size() == 1) {
        pFlame.getFirstLayer().setGradientMapVertOffset(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_GRADIENT_MAP_VSCALE)) != null && pFlame.getLayers().size() == 1) {
        pFlame.getFirstLayer().setGradientMapVertScale(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_GRADIENT_MAP_LCOLOR_ADD)) != null && pFlame.getLayers().size() == 1) {
        pFlame.getFirstLayer().setGradientMapLocalColorAdd(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_GRADIENT_MAP_LCOLOR_SCALE)) != null && pFlame.getLayers().size() == 1) {
        pFlame.getFirstLayer().setGradientMapLocalColorScale(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SMOOTH_GRADIENT)) != null && pFlame.getLayers().size() == 1) {
        pFlame.getFirstLayer().setSmoothGradient("1".equals(hs));
    }
    if ((hs = atts.get(ATTR_SIZE)) != null) {
        String[] s = hs.split(" ");
        pFlame.setWidth(Integer.parseInt(s[0]));
        pFlame.setHeight(Integer.parseInt(s[1]));
    }
    if ((hs = atts.get(ATTR_CENTER)) != null) {
        String[] s = hs.split(" ");
        pFlame.setCentreX(Double.parseDouble(s[0]));
        pFlame.setCentreY(Double.parseDouble(s[1]));
    }
    if ((hs = atts.get(ATTR_SCALE)) != null) {
        pFlame.setPixelsPerUnit(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_ROTATE)) != null) {
        // pFlame.setCamRoll(-Double.parseDouble(hs) * 180.0 / Math.PI);
        pFlame.setCamRoll(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_FILTER)) != null) {
        pFlame.setSpatialFilterRadius(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_FILTER_SHARPNESS)) != null) {
        pFlame.setSpatialFilterSharpness(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_FILTER_LOW_DENSITY)) != null) {
        pFlame.setSpatialFilterLowDensity(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_FILTER_TYPE)) != null) {
        try {
            FilteringType filteringType = FilteringType.valueOf(hs);
            pFlame.setSpatialFilteringType(filteringType);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_FILTER_KERNEL)) != null) {
        try {
            FilterKernelType kernel = FilterKernelType.valueOf(hs);
            pFlame.setSpatialFilterKernel(kernel);
            if (atts.get(ATTR_FILTER_TYPE) == null) {
                if (FilterKernelType.getAdapativeFilters().contains(kernel)) {
                    pFlame.setSpatialFilteringType(FilteringType.ADAPTIVE);
                } else if (FilterKernelType.getSharpeningFilters().contains(kernel)) {
                    pFlame.setSpatialFilteringType(FilteringType.GLOBAL_SHARPENING);
                } else if (FilterKernelType.getSmoothingFilters().contains(kernel)) {
                    pFlame.setSpatialFilteringType(FilteringType.GLOBAL_SMOOTHING);
                } else {
                    pFlame.setSpatialFilteringType(FilteringType.GLOBAL_SMOOTHING);
                    pFlame.setSpatialFilterKernel(FilterKernelType.SINEPOW10);
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_FILTER_INDICATOR)) != null) {
        pFlame.setSpatialFilterIndicator(Integer.parseInt(hs) == 1);
    }
    if ((hs = atts.get(ATTR_SPATIAL_OVERSAMPLE)) != null) {
        pFlame.setSpatialOversampling(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_POST_NOISE_FILTER)) != null) {
        pFlame.setPostNoiseFilter(Integer.parseInt(hs) == 1);
    }
    if ((hs = atts.get(ATTR_POST_NOISE_FILTER_THRESHOLD)) != null) {
        pFlame.setPostNoiseFilterThreshold(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_QUALITY)) != null) {
        pFlame.setSampleDensity(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_BACKGROUND_TYPE)) != null) {
        try {
            pFlame.setBgColorType(BGColorType.valueOf(hs));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_BACKGROUND)) != null) {
        String[] s = hs.split(" ");
        pFlame.setBgColorRed(Tools.roundColor(255.0 * Double.parseDouble(s[0])));
        pFlame.setBgColorGreen(Tools.roundColor(255.0 * Double.parseDouble(s[1])));
        pFlame.setBgColorBlue(Tools.roundColor(255.0 * Double.parseDouble(s[2])));
        // old flames without a bg color type
        if (atts.get(ATTR_BACKGROUND_TYPE) == null) {
            pFlame.setBgColorType(BGColorType.SINGLE_COLOR);
        }
    }
    if ((hs = atts.get(ATTR_BACKGROUND_UL)) != null) {
        String[] s = hs.split(" ");
        pFlame.setBgColorULRed(Tools.roundColor(255.0 * Double.parseDouble(s[0])));
        pFlame.setBgColorULGreen(Tools.roundColor(255.0 * Double.parseDouble(s[1])));
        pFlame.setBgColorULBlue(Tools.roundColor(255.0 * Double.parseDouble(s[2])));
    }
    if ((hs = atts.get(ATTR_BACKGROUND_UR)) != null) {
        String[] s = hs.split(" ");
        pFlame.setBgColorURRed(Tools.roundColor(255.0 * Double.parseDouble(s[0])));
        pFlame.setBgColorURGreen(Tools.roundColor(255.0 * Double.parseDouble(s[1])));
        pFlame.setBgColorURBlue(Tools.roundColor(255.0 * Double.parseDouble(s[2])));
    }
    if ((hs = atts.get(ATTR_BACKGROUND_LL)) != null) {
        String[] s = hs.split(" ");
        pFlame.setBgColorLLRed(Tools.roundColor(255.0 * Double.parseDouble(s[0])));
        pFlame.setBgColorLLGreen(Tools.roundColor(255.0 * Double.parseDouble(s[1])));
        pFlame.setBgColorLLBlue(Tools.roundColor(255.0 * Double.parseDouble(s[2])));
    }
    if ((hs = atts.get(ATTR_BACKGROUND_LR)) != null) {
        String[] s = hs.split(" ");
        pFlame.setBgColorLRRed(Tools.roundColor(255.0 * Double.parseDouble(s[0])));
        pFlame.setBgColorLRGreen(Tools.roundColor(255.0 * Double.parseDouble(s[1])));
        pFlame.setBgColorLRBlue(Tools.roundColor(255.0 * Double.parseDouble(s[2])));
    }
    if ((hs = atts.get(ATTR_BACKGROUND_CC)) != null) {
        String[] s = hs.split(" ");
        pFlame.setBgColorCCRed(Tools.roundColor(255.0 * Double.parseDouble(s[0])));
        pFlame.setBgColorCCGreen(Tools.roundColor(255.0 * Double.parseDouble(s[1])));
        pFlame.setBgColorCCBlue(Tools.roundColor(255.0 * Double.parseDouble(s[2])));
    }
    if ((hs = atts.get(ATTR_BRIGHTNESS)) != null) {
        pFlame.setBrightness(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SATURATION)) != null) {
        pFlame.setSaturation(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_BG_TRANSPARENCY)) != null) {
        pFlame.setBGTransparency(Integer.parseInt(hs) == 1);
    } else {
        pFlame.setBGTransparency(prefs.isTinaDefaultBGTransparency());
    }
    if ((hs = atts.get(ATTR_GAMMA)) != null) {
        pFlame.setGamma(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_GAMMA_THRESHOLD)) != null) {
        pFlame.setGammaThreshold(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_VIBRANCY)) != null) {
        pFlame.setVibrancy(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_LOW_DENSITY_BRIGHTNESS)) != null) {
        pFlame.setLowDensityBrightness(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_BALANCING_RED)) != null) {
        pFlame.setBalanceRed(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_BALANCING_GREEN)) != null) {
        pFlame.setBalanceGreen(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_BALANCING_BLUE)) != null) {
        pFlame.setBalanceBlue(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CONTRAST)) != null) {
        pFlame.setContrast(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_WHITE_LEVEL)) != null) {
        pFlame.setWhiteLevel(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_PERSP)) != null) {
        pFlame.setCamPerspective(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_PERSPECTIVE)) != null) {
        pFlame.setCamPerspective(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_ZPOS)) != null) {
        pFlame.setCamZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_POS_X)) != null) {
        pFlame.setCamPosX(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_POS_Y)) != null) {
        pFlame.setCamPosY(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_POS_Z)) != null) {
        pFlame.setCamPosZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_XFOCUS)) != null) {
        pFlame.setFocusX(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_YFOCUS)) != null) {
        pFlame.setFocusY(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_ZFOCUS)) != null) {
        pFlame.setFocusZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_ZDIMISH)) != null) {
        pFlame.setDimishZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF)) != null) {
        pFlame.setCamDOF(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF_SHAPE)) != null) {
        try {
            pFlame.setCamDOFShape(DOFBlurShapeType.valueOf(hs));
        } catch (Exception ex) {
            pFlame.setCamDOFShape(DOFBlurShapeType.BUBBLE);
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_CAM_DOF_SCALE)) != null) {
        pFlame.setCamDOFScale(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF_ROTATE)) != null) {
        pFlame.setCamDOFAngle(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF_FADE)) != null) {
        pFlame.setCamDOFFade(Double.parseDouble(hs));
    }
    {
        DOFBlurShape shape = pFlame.getCamDOFShape().getDOFBlurShape();
        List<String> paramNames = shape.getParamNames();
        if (paramNames.size() > 0 && (hs = atts.get(ATTR_CAM_DOF_PARAM1)) != null) {
            pFlame.setCamDOFParam1(Double.parseDouble(hs));
        }
        if (paramNames.size() > 1 && (hs = atts.get(ATTR_CAM_DOF_PARAM2)) != null) {
            pFlame.setCamDOFParam2(Double.parseDouble(hs));
        }
        if (paramNames.size() > 2 && (hs = atts.get(ATTR_CAM_DOF_PARAM3)) != null) {
            pFlame.setCamDOFParam3(Double.parseDouble(hs));
        }
        if (paramNames.size() > 3 && (hs = atts.get(ATTR_CAM_DOF_PARAM4)) != null) {
            pFlame.setCamDOFParam4(Double.parseDouble(hs));
        }
        if (paramNames.size() > 4 && (hs = atts.get(ATTR_CAM_DOF_PARAM5)) != null) {
            pFlame.setCamDOFParam5(Double.parseDouble(hs));
        }
        if (paramNames.size() > 5 && (hs = atts.get(ATTR_CAM_DOF_PARAM6)) != null) {
            pFlame.setCamDOFParam6(Double.parseDouble(hs));
        }
    }
    if ((hs = atts.get(ATTR_CAM_DOF_AREA)) != null) {
        pFlame.setCamDOFArea(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF_EXPONENT)) != null) {
        pFlame.setCamDOFExponent(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_PITCH)) != null) {
        pFlame.setCamPitch(Double.parseDouble(hs) * 180.0 / Math.PI);
    }
    if ((hs = atts.get(ATTR_CAM_YAW)) != null) {
        pFlame.setCamYaw(Double.parseDouble(hs) * 180.0 / Math.PI);
    }
    if ((hs = atts.get(ATTR_CAM_ZOOM)) != null) {
        pFlame.setCamZoom(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_NEW_DOF)) != null) {
        pFlame.setNewCamDOF("1".equals(hs));
    }
    // preserve-z
    if ((hs = atts.get(ATTR_PRESERVE_Z)) != null) {
        pFlame.setPreserveZ("1".equals(hs));
    }
    // profiles
    if ((hs = atts.get(ATTR_RESOLUTION_PROFILE)) != null) {
        pFlame.setResolutionProfile(hs);
    }
    if ((hs = atts.get(ATTR_QUALITY_PROFILE)) != null) {
        pFlame.setQualityProfile(hs);
    }
    if ((hs = atts.get(ATTR_NEW_LINEAR)) != null) {
        pFlame.setPreserveZ(hs.length() > 0 && Integer.parseInt(hs) == 1);
    }
    if ((hs = atts.get(ATTR_ANTIALIAS_AMOUNT)) != null) {
        pFlame.setAntialiasAmount(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_ANTIALIAS_RADIUS)) != null) {
        pFlame.setAntialiasRadius(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_MOTIONBLUR_LENGTH)) != null) {
        int blurLen = Integer.parseInt(hs);
        pFlame.setMotionBlurLength(blurLen);
    }
    if ((hs = atts.get(ATTR_MOTIONBLUR_TIMESTEP)) != null) {
        double timestep = Double.parseDouble(hs);
        pFlame.setMotionBlurTimeStep(timestep);
    }
    if ((hs = atts.get(ATTR_MOTIONBLUR_DECAY)) != null) {
        pFlame.setMotionBlurDecay(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_TYPE)) != null) {
        try {
            pFlame.setPostSymmetryType(PostSymmetryType.valueOf(hs));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_ORDER)) != null) {
        pFlame.setPostSymmetryOrder(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_CENTREX)) != null) {
        pFlame.setPostSymmetryCentreX(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_CENTREY)) != null) {
        pFlame.setPostSymmetryCentreY(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_DISTANCE)) != null) {
        pFlame.setPostSymmetryDistance(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_POST_SYMMETRY_ROTATION)) != null) {
        pFlame.setPostSymmetryRotation(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_STEREO3D_MODE)) != null) {
        try {
            pFlame.setStereo3dMode(Stereo3dMode.valueOf(hs));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_STEREO3D_ANGLE)) != null) {
        pFlame.setStereo3dAngle(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_STEREO3D_EYE_DIST)) != null) {
        pFlame.setStereo3dEyeDist(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_STEREO3D_FOCAL_OFFSET)) != null) {
        pFlame.setStereo3dFocalOffset(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_STEREO3D_LEFT_EYE_COLOR)) != null) {
        try {
            pFlame.setStereo3dLeftEyeColor(Stereo3dColor.valueOf(hs));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_STEREO3D_RIGHT_EYE_COLOR)) != null) {
        try {
            pFlame.setStereo3dRightEyeColor(Stereo3dColor.valueOf(hs));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_STEREO3D_INTERPOLATED_IMAGE_COUNT)) != null) {
        pFlame.setStereo3dInterpolatedImageCount(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_STEREO3D_PREVIEW)) != null) {
        try {
            pFlame.setStereo3dPreview(Stereo3dPreview.valueOf(hs));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_STEREO3D_SWAP_SIDES)) != null) {
        pFlame.setStereo3dSwapSides(Integer.parseInt(hs) == 1);
    }
    if ((hs = atts.get(ATTR_FRAME)) != null) {
        pFlame.setFrame(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_FRAME_COUNT)) != null) {
        pFlame.setFrameCount(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_FPS)) != null) {
        int fps = Integer.parseInt(hs);
        if (fps >= 1)
            pFlame.setFps(fps);
    }
    if ((hs = atts.get(ATTR_POSTBLUR_RADIUS)) != null) {
        pFlame.setPostBlurRadius(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_POSTBLUR_FADE)) != null) {
        pFlame.setPostBlurFade(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_POSTBLUR_FALLOFF)) != null) {
        pFlame.setPostBlurFallOff(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_ZBUFFER_SCALE)) != null) {
        pFlame.setZBufferScale(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SLD_RENDER_ENABLED)) != null) {
        pFlame.getSolidRenderSettings().setSolidRenderingEnabled(Integer.parseInt(hs) == 1);
    } else {
        pFlame.getSolidRenderSettings().setSolidRenderingEnabled(false);
    }
    if (pFlame.getSolidRenderSettings().isSolidRenderingEnabled()) {
        if ((hs = atts.get(ATTR_SLD_RENDER_AO_ENABLED)) != null) {
            pFlame.getSolidRenderSettings().setAoEnabled(Integer.parseInt(hs) == 1);
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_AO_INTENSITY)) != null) {
            pFlame.getSolidRenderSettings().setAoIntensity(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_AO_SEARCH_RADIUS)) != null) {
            pFlame.getSolidRenderSettings().setAoSearchRadius(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_AO_BLUR_RADIUS)) != null) {
            pFlame.getSolidRenderSettings().setAoBlurRadius(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_AO_RADIUS_SAMPLES)) != null) {
            pFlame.getSolidRenderSettings().setAoRadiusSamples(Integer.parseInt(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_AO_AZIMUTH_SAMPLES)) != null) {
            pFlame.getSolidRenderSettings().setAoAzimuthSamples(Integer.parseInt(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_AO_FALLOFF)) != null) {
            pFlame.getSolidRenderSettings().setAoFalloff(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_AO_AFFECT_DIFFUSE)) != null) {
            pFlame.getSolidRenderSettings().setAoAffectDiffuse(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_SHADOW_TYPE)) != null) {
            try {
                pFlame.getSolidRenderSettings().setShadowType(ShadowType.valueOf(hs));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_SHADOW_SMOOTH_RADIUS)) != null) {
            pFlame.getSolidRenderSettings().setShadowSmoothRadius(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_SHADOWMAP_SIZE)) != null) {
            pFlame.getSolidRenderSettings().setShadowmapSize(Integer.parseInt(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_SHADOWMAP_BIAS)) != null) {
            pFlame.getSolidRenderSettings().setShadowmapBias(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_POST_BOKEH_FILTER_KERNEL)) != null) {
            try {
                pFlame.getSolidRenderSettings().setPostBokehFilterKernel(FilterKernelType.valueOf(hs));
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
        if ((hs = atts.get(ATTR_POST_BOKEH_INTENSITY)) != null) {
            pFlame.getSolidRenderSettings().setPostBokehIntensity(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_POST_BOKEH_BRIGHTNESS)) != null) {
            pFlame.getSolidRenderSettings().setPostBokehBrightness(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_POST_BOKEH_SIZE)) != null) {
            pFlame.getSolidRenderSettings().setPostBokehSize(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_POST_BOKEH_ACTIVATION)) != null) {
            pFlame.getSolidRenderSettings().setPostBokehActivation(Double.parseDouble(hs));
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_COUNT)) != null) {
            int materialCount = Integer.parseInt(hs);
            pFlame.getSolidRenderSettings().getMaterials().clear();
            for (int i = 0; i < materialCount; i++) {
                MaterialSettings material = new MaterialSettings();
                pFlame.getSolidRenderSettings().getMaterials().add(material);
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_DIFFUSE + i)) != null) {
                    material.setDiffuse(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_AMBIENT + i)) != null) {
                    material.setAmbient(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_PHONG + i)) != null) {
                    material.setPhong(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_PHONG_SIZE + i)) != null) {
                    material.setPhongSize(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_PHONG_RED + i)) != null) {
                    material.setPhongRed(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_PHONG_GREEN + i)) != null) {
                    material.setPhongGreen(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_PHONG_BLUE + i)) != null) {
                    material.setPhongBlue(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_LIGHT_DIFF_FUNC + i)) != null) {
                    try {
                        material.setLightDiffFunc(LightDiffFuncPreset.valueOf(hs));
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_REFL_MAP_INTENSITY + i)) != null) {
                    material.setReflMapIntensity(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_REFL_MAP_FILENAME + i)) != null) {
                    material.setReflMapFilename(hs);
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_MATERIAL_REFL_MAPPING + i)) != null) {
                    try {
                        material.setReflectionMapping(ReflectionMapping.valueOf(hs));
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        }
        if ((hs = atts.get(ATTR_SLD_RENDER_LIGHT_COUNT)) != null) {
            int lightCount = Integer.parseInt(hs);
            pFlame.getSolidRenderSettings().getLights().clear();
            for (int i = 0; i < lightCount; i++) {
                DistantLight light = new DistantLight();
                pFlame.getSolidRenderSettings().getLights().add(light);
                if ((hs = atts.get(ATTR_SLD_RENDER_LIGHT_ALTITUDE + i)) != null) {
                    light.setAltitude(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_LIGHT_AZIMUTH + i)) != null) {
                    light.setAzimuth(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_LIGHT_INTENSITY + i)) != null) {
                    light.setIntensity(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_LIGHT_SHADOW_INTENSITY + i)) != null) {
                    light.setShadowIntensity(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_LIGHT_RED + i)) != null) {
                    light.setRed(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_LIGHT_GREEN + i)) != null) {
                    light.setGreen(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_LIGHT_BLUE + i)) != null) {
                    light.setBlue(Double.parseDouble(hs));
                }
                if ((hs = atts.get(ATTR_SLD_RENDER_LIGHT_SHADOWS + i)) != null) {
                    light.setCastShadows(Integer.parseInt(hs) == 1);
                }
                {
                    MotionCurve curve = light.getAltitudeCurve();
                    String namePrefix = AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_ALTITUDE + i + "_";
                    readMotionCurveAttributes(atts, curve, namePrefix);
                }
                {
                    MotionCurve curve = light.getAzimuthCurve();
                    String namePrefix = AbstractFlameReader.ATTR_SLD_RENDER_LIGHT_AZIMUTH + i + "_";
                    readMotionCurveAttributes(atts, curve, namePrefix);
                }
            }
        }
    }
    readMotionCurves(pFlame, atts, null);
    if ((hs = atts.get(ATTR_CHANNEL_MIXER_MODE)) != null) {
        try {
            pFlame.setChannelMixerMode(ChannelMixerMode.valueOf(hs));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    switch(pFlame.getChannelMixerMode()) {
        case BRIGHTNESS:
            readMotionCurveAttributes(atts, pFlame.getMixerRRCurve(), ATTR_CHANNEL_MIXER_RR_CURVE + "_");
            break;
        case RGB:
            readMotionCurveAttributes(atts, pFlame.getMixerRRCurve(), ATTR_CHANNEL_MIXER_RR_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerGGCurve(), ATTR_CHANNEL_MIXER_GG_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerBBCurve(), ATTR_CHANNEL_MIXER_BB_CURVE + "_");
            break;
        case FULL:
            readMotionCurveAttributes(atts, pFlame.getMixerRRCurve(), ATTR_CHANNEL_MIXER_RR_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerRGCurve(), ATTR_CHANNEL_MIXER_RG_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerRBCurve(), ATTR_CHANNEL_MIXER_RB_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerGRCurve(), ATTR_CHANNEL_MIXER_GR_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerGGCurve(), ATTR_CHANNEL_MIXER_GG_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerGBCurve(), ATTR_CHANNEL_MIXER_GB_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerBRCurve(), ATTR_CHANNEL_MIXER_BR_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerBGCurve(), ATTR_CHANNEL_MIXER_BG_CURVE + "_");
            readMotionCurveAttributes(atts, pFlame.getMixerBBCurve(), ATTR_CHANNEL_MIXER_BB_CURVE + "_");
            break;
        default:
            break;
    }
    return atts;
}
Also used : DOFBlurShape(org.jwildfire.create.tina.render.dof.DOFBlurShape) FilterKernelType(org.jwildfire.create.tina.render.filter.FilterKernelType) MaterialSettings(org.jwildfire.create.tina.base.solidrender.MaterialSettings) FilteringType(org.jwildfire.create.tina.render.filter.FilteringType) XMLAttributes(org.jwildfire.base.Tools.XMLAttributes) MotionCurve(org.jwildfire.create.tina.base.motion.MotionCurve) VariationFuncList(org.jwildfire.create.tina.variation.VariationFuncList) List(java.util.List) DistantLight(org.jwildfire.create.tina.base.solidrender.DistantLight)

Example 7 with DistantLight

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

the class FlameControlsDelegate method solidRenderingLightColorBtn_clicked.

public void solidRenderingLightColorBtn_clicked() {
    DistantLight light = getSolidRenderingSelectedLight();
    if (light != null) {
        owner.undoManager.saveUndoPoint(getCurrFlame());
        ResourceManager rm = ResourceManager.all(FilePropertyEditor.class);
        String title = rm.getString("ColorPropertyEditor.title");
        Color selectedColor = JColorChooser.showDialog(rootPanel, title, new Color(Tools.roundColor(light.getRed() * GammaCorrectionFilter.COLORSCL), Tools.roundColor(light.getGreen() * GammaCorrectionFilter.COLORSCL), Tools.roundColor(light.getBlue() * GammaCorrectionFilter.COLORSCL)));
        setLightColor(light, selectedColor);
    }
}
Also used : Color(java.awt.Color) RGBColor(org.jwildfire.create.tina.palette.RGBColor) Stereo3dColor(org.jwildfire.create.tina.base.Stereo3dColor) DistantLight(org.jwildfire.create.tina.base.solidrender.DistantLight) ResourceManager(com.l2fprod.common.util.ResourceManager)

Example 8 with DistantLight

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

the class FlameControlsDelegate method randomizeLightColor.

public void randomizeLightColor() {
    DistantLight light = getSolidRenderingSelectedLight();
    if (light != null) {
        owner.undoManager.saveUndoPoint(getCurrFlame());
        List<RGBColor> rndColors = new AllRandomGradientGenerator().generateKeyFrames(7);
        RGBColor rndColor = rndColors.get((int) (Math.random() * rndColors.size()));
        Color selectedColor = new Color(rndColor.getRed(), rndColor.getGreen(), rndColor.getBlue());
        setLightColor(light, selectedColor);
    }
}
Also used : AllRandomGradientGenerator(org.jwildfire.create.tina.randomgradient.AllRandomGradientGenerator) Color(java.awt.Color) RGBColor(org.jwildfire.create.tina.palette.RGBColor) Stereo3dColor(org.jwildfire.create.tina.base.Stereo3dColor) RGBColor(org.jwildfire.create.tina.palette.RGBColor) DistantLight(org.jwildfire.create.tina.base.solidrender.DistantLight)

Example 9 with DistantLight

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

the class FlameControlsDelegate method randomizeLightPosition.

public void randomizeLightPosition() {
    if (!isNoRefresh()) {
        DistantLight light = getSolidRenderingSelectedLight();
        if (light != null) {
            owner.saveUndoPoint();
            light.setCastShadows(data.tinaSolidRenderingLightCastShadowsCBx.isSelected());
            light.setAltitude((0.5 - Math.random()) * 60.0);
            light.setAzimuth((0.5 - Math.random()) * 40.0);
            refreshLightPosControls(light);
            owner.refreshFlameImage(true, false, 1, true, !areShadowsEnabled());
        }
    }
}
Also used : DistantLight(org.jwildfire.create.tina.base.solidrender.DistantLight)

Example 10 with DistantLight

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

the class FlameControlsDelegate method solidRenderingLightCastShadowsCBx_changed.

public void solidRenderingLightCastShadowsCBx_changed() {
    if (!isNoRefresh()) {
        DistantLight light = getSolidRenderingSelectedLight();
        if (light != null) {
            owner.saveUndoPoint();
            light.setCastShadows(data.tinaSolidRenderingLightCastShadowsCBx.isSelected());
            enableControls();
            owner.refreshFlameImage(true, false, 1, true, true);
        }
    }
}
Also used : DistantLight(org.jwildfire.create.tina.base.solidrender.DistantLight)

Aggregations

DistantLight (org.jwildfire.create.tina.base.solidrender.DistantLight)11 MaterialSettings (org.jwildfire.create.tina.base.solidrender.MaterialSettings)4 Color (java.awt.Color)3 Stereo3dColor (org.jwildfire.create.tina.base.Stereo3dColor)3 RGBColor (org.jwildfire.create.tina.palette.RGBColor)3 LightDiffFuncPreset (org.jwildfire.create.tina.base.solidrender.LightDiffFuncPreset)2 DOFBlurShape (org.jwildfire.create.tina.render.dof.DOFBlurShape)2 ResourceManager (com.l2fprod.common.util.ResourceManager)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 XMLAttributes (org.jwildfire.base.Tools.XMLAttributes)1 RGBColorD (org.jwildfire.base.mathlib.VecMathLib.RGBColorD)1 UVPairD (org.jwildfire.base.mathlib.VecMathLib.UVPairD)1 VectorD (org.jwildfire.base.mathlib.VecMathLib.VectorD)1 MotionCurveAttribute (org.jwildfire.create.tina.animate.AnimationService.MotionCurveAttribute)1 Layer (org.jwildfire.create.tina.base.Layer)1 MotionCurve (org.jwildfire.create.tina.base.motion.MotionCurve)1 RasterPoint (org.jwildfire.create.tina.base.raster.RasterPoint)1 AllRandomGradientGenerator (org.jwildfire.create.tina.randomgradient.AllRandomGradientGenerator)1 FilterKernelType (org.jwildfire.create.tina.render.filter.FilterKernelType)1