Search in sources :

Example 1 with XFormScript

use of org.jwildfire.create.tina.animate.XFormScript in project JWildfire by thargor6.

the class TransformingDuckiesRandomMovieGenerator method prepareMovie.

@Override
protected FlameMovie prepareMovie(Prefs pPrefs) {
    FlameMovie movie = new FlameMovie(pPrefs);
    Flame flame = genRandomFlame(new DuckiesRandomFlameGenerator(), pPrefs);
    FlameMoviePart part = new FlameMoviePart();
    part.setFlame(flame);
    part.setFrameCount(320);
    part.setFrameMorphCount(0);
    movie.addPart(part);
    {
        double amplitude = -1.25 * Math.random() * 2.5;
        movie.getGlobalScripts()[0] = new GlobalScript(GlobalScriptType.ROTATE_ROLL, amplitude);
    }
    {
        double amplitude = Math.random() * 2.0 + 0.2;
        movie.getGlobalScripts()[1] = new GlobalScript(GlobalScriptType.MOVE_CAM_X, amplitude);
    }
    if (Math.random() < 0.5) {
        double amplitude = Math.random() * 0.25;
        movie.getGlobalScripts()[2] = new GlobalScript(GlobalScriptType.MOVE_CAM_Z, amplitude);
    }
    {
        double amplitude = -0.5 * Math.random() * 1.0;
        movie.getxFormScripts()[0] = new XFormScript(XFormScriptType.ROTATE_2ND_XFORM, amplitude);
    }
    return movie;
}
Also used : XFormScript(org.jwildfire.create.tina.animate.XFormScript) GlobalScript(org.jwildfire.create.tina.animate.GlobalScript) FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) DuckiesRandomFlameGenerator(org.jwildfire.create.tina.randomflame.DuckiesRandomFlameGenerator) FlameMoviePart(org.jwildfire.create.tina.animate.FlameMoviePart) Flame(org.jwildfire.create.tina.base.Flame)

Example 2 with XFormScript

use of org.jwildfire.create.tina.animate.XFormScript in project JWildfire by thargor6.

the class TinaSWFAnimatorController method getCurrFlame.

private Flame getCurrFlame() {
    int frame = swfAnimatorFrameSlider.getValue();
    Flame flame = currMovie.getFlame(frame);
    if (flame != null) {
        prepareFlame(flame);
        boolean oldNoRefresh = noRefresh;
        noRefresh = true;
        try {
            swfAnimatorFrameREd.setValue(frame);
        } finally {
            noRefresh = oldNoRefresh;
        }
        int frameCount = swfAnimatorFramesREd.getIntValue();
        double fps = swfAnimatorFramesPerSecondREd.getDoubleValue();
        int motionBlurLength = swfAnimatorMotionBlurLengthREd.getIntValue();
        double motionBlurTimeStep = swfAnimatorMotionBlurTimeStepREd.getDoubleValue();
        List<GlobalScript> editedGlobalScripts = new ArrayList<GlobalScript>();
        for (ScriptContainer container : globalScripts) {
            editedGlobalScripts.add(getGlobalScriptFromUI(container.getScriptCmb(), container.getScriptREd()));
        }
        List<XFormScript> editedXFormScripts = new ArrayList<XFormScript>();
        for (ScriptContainer container : xFormScripts) {
            editedXFormScripts.add(getXFormScriptFromUI(container.getScriptCmb(), container.getScriptREd()));
        }
        try {
            Flame res = flame.makeCopy();
            for (GlobalScript script : editedGlobalScripts) {
                AnimationService.addMotionCurve(res, script, frame, frameCount, fps);
            }
            for (XFormScript script : editedXFormScripts) {
                AnimationService.addMotionCurve(res, script, frame, frameCount, fps);
            }
            res.setFrame(frame);
            res.setMotionBlurLength(motionBlurLength);
            res.setMotionBlurTimeStep(motionBlurTimeStep);
            return res;
        } catch (Throwable ex) {
            ex.printStackTrace();
            return null;
        }
    } else {
        return null;
    }
}
Also used : XFormScript(org.jwildfire.create.tina.animate.XFormScript) GlobalScript(org.jwildfire.create.tina.animate.GlobalScript) ArrayList(java.util.ArrayList) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 3 with XFormScript

use of org.jwildfire.create.tina.animate.XFormScript in project JWildfire by thargor6.

the class TinaSWFAnimatorController method getXFormScriptFromUI.

private XFormScript getXFormScriptFromUI(JComboBox pCmb, JWFNumberField pField) {
    XFormScriptType scriptType = (XFormScriptType) pCmb.getSelectedItem();
    XFormScript res = new XFormScript(scriptType != null ? scriptType : XFormScriptType.NONE, pField.getDoubleValue());
    res.getAmplitudeCurve().assign(curves.get(pField.getMotionPropertyName()).getCurve());
    return res;
}
Also used : XFormScriptType(org.jwildfire.create.tina.animate.XFormScriptType) XFormScript(org.jwildfire.create.tina.animate.XFormScript)

Example 4 with XFormScript

use of org.jwildfire.create.tina.animate.XFormScript in project JWildfire by thargor6.

the class FlameMovieReader method parseMovieAttributes.

private void parseMovieAttributes(FlameMovie pMovie, String pXML) {
    XMLAttributes atts = Tools.parseAttributes(pXML);
    String hs;
    if ((hs = atts.get(ATTR_NAME)) != null) {
        pMovie.setName(hs);
    }
    if ((hs = atts.get(ATTR_SCRIPT_GLOBAL)) != null) {
        // legacy
        pMovie.getGlobalScripts()[0] = new GlobalScript(GlobalScriptType.valueOf(hs), 1.0);
    }
    for (int i = 0; i < FlameMovie.SCRIPT_COUNT; i++) {
        String idxStr = String.valueOf(i + 1);
        if ((hs = atts.get(ATTR_SCRIPT_GLOBAL + idxStr)) != null) {
            pMovie.getGlobalScripts()[i] = readGlobalScript(ATTR_SCRIPT_GLOBAL + idxStr, ATTR_SCRIPT_GLOBAL + idxStr + AMPLITUDE_POSTFIX, ATTR_SCRIPT_GLOBAL + idxStr + AMPLITUDE_CURVE_POSTFIX, atts);
        }
    }
    if ((hs = atts.get(ATTR_SCRIPT_XFORM)) != null) {
        // legacy
        pMovie.getxFormScripts()[0] = new XFormScript(XFormScriptType.valueOf(hs), 1.0);
    }
    for (int i = 0; i < FlameMovie.SCRIPT_COUNT; i++) {
        String idxStr = String.valueOf(i + 1);
        if ((hs = atts.get(ATTR_SCRIPT_XFORM + idxStr)) != null) {
            pMovie.getxFormScripts()[i] = readXFormScript(ATTR_SCRIPT_XFORM + idxStr, ATTR_SCRIPT_XFORM + idxStr + AMPLITUDE_POSTFIX, ATTR_SCRIPT_XFORM + idxStr + AMPLITUDE_CURVE_POSTFIX, atts);
        }
    }
    if ((hs = atts.get(ATTR_FRAME_WIDTH)) != null) {
        pMovie.setFrameWidth(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_FRAME_HEIGHT)) != null) {
        pMovie.setFrameHeight(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_FPS)) != null) {
        pMovie.setFramesPerSecond(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_QUALITY)) != null) {
        pMovie.setQuality(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_SEQUENCE_OUTPUT_TYPE)) != null) {
        try {
            pMovie.setSequenceOutputType(SequenceOutputType.valueOf(hs));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = atts.get(ATTR_MOTIONBLUR_LENGTH)) != null) {
        pMovie.setMotionBlurLength(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_MOTIONBLUR_TIMESTEP)) != null) {
        pMovie.setMotionBlurTimeStep(Double.parseDouble(hs));
    }
}
Also used : XFormScript(org.jwildfire.create.tina.animate.XFormScript) XMLAttributes(org.jwildfire.base.Tools.XMLAttributes) GlobalScript(org.jwildfire.create.tina.animate.GlobalScript)

Example 5 with XFormScript

use of org.jwildfire.create.tina.animate.XFormScript in project JWildfire by thargor6.

the class FlameMovieReader method readXFormScript.

private XFormScript readXFormScript(String pAttrScript, String pAttrScriptAmplitude, String pAttrScriptAmplitudeCurve, XMLAttributes pAtts) {
    XFormScript script = new XFormScript();
    String hs;
    if ((hs = pAtts.get(pAttrScript)) != null) {
        try {
            script.setScriptType(XFormScriptType.valueOf(hs));
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    if ((hs = pAtts.get(pAttrScriptAmplitude)) != null) {
        script.setAmplitude(Double.parseDouble(hs));
    }
    AbstractFlameReader.readMotionCurveAttributes(pAtts, script.getAmplitudeCurve(), pAttrScript + Tools.CURVE_POSTFIX + "_");
    return script;
}
Also used : XFormScript(org.jwildfire.create.tina.animate.XFormScript)

Aggregations

XFormScript (org.jwildfire.create.tina.animate.XFormScript)6 GlobalScript (org.jwildfire.create.tina.animate.GlobalScript)4 Flame (org.jwildfire.create.tina.base.Flame)3 FlameMovie (org.jwildfire.create.tina.animate.FlameMovie)2 FlameMoviePart (org.jwildfire.create.tina.animate.FlameMoviePart)2 ArrayList (java.util.ArrayList)1 XMLAttributes (org.jwildfire.base.Tools.XMLAttributes)1 XFormScriptType (org.jwildfire.create.tina.animate.XFormScriptType)1 BubblesRandomFlameGenerator (org.jwildfire.create.tina.randomflame.BubblesRandomFlameGenerator)1 DuckiesRandomFlameGenerator (org.jwildfire.create.tina.randomflame.DuckiesRandomFlameGenerator)1 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)1