Search in sources :

Example 6 with FlameMovie

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

the class FlameMovieReader method readMovieFromXML.

public FlameMovie readMovieFromXML(String pXML) {
    // extract movie xml
    String movieXML;
    {
        int ps = pXML.indexOf("<" + TAG_JWF_MOVIE + " ");
        if (ps < 0)
            return null;
        int pe = pXML.indexOf("</" + TAG_JWF_MOVIE + ">", ps + 1);
        if (pe < 0)
            return null;
        movieXML = pXML.substring(ps, pe);
    }
    FlameMovie movie = new FlameMovie(prefs);
    // Movie attributes
    {
        int ps = movieXML.indexOf("<" + TAG_JWF_MOVIE + " ");
        int pe = -1;
        boolean qt = false;
        for (int i = ps + 1; i < movieXML.length(); i++) {
            if (movieXML.charAt(i) == '\"') {
                qt = !qt;
            } else if (!qt && movieXML.charAt(i) == '>') {
                pe = i;
                break;
            }
        }
        String hs = movieXML.substring(ps + 7, pe);
        parseMovieAttributes(movie, hs);
    }
    // parts
    {
        int p = 0;
        while (true) {
            int ps = movieXML.indexOf("<" + TAG_JWF_MOVIE_PART + " ", p + 1);
            if (ps < 0)
                break;
            int pe = movieXML.indexOf("</" + TAG_JWF_MOVIE_PART + ">", ps + 1);
            if (pe < 0) {
                pe = movieXML.indexOf("/>", ps + 1);
            }
            String hs = movieXML.substring(ps + TAG_JWF_MOVIE_PART.length() + 1, pe);
            FlameMoviePart part = new FlameMoviePart();
            movie.addPart(part);
            int psFlame = hs.indexOf("<flame ");
            if (psFlame > 0) {
                int peFlame = hs.indexOf("</flame>", psFlame + 1);
                String flameXML = hs.substring(psFlame, peFlame + 8);
                Flame flame = new FlameReader(prefs).readFlamesfromXML(flameXML).get(0);
                part.setFlame(flame);
                // System.out.println(flameXML);
                hs = hs.substring(0, psFlame);
            } else {
                psFlame = hs.indexOf("<jwf-flame ");
                if (psFlame > 0) {
                    int peFlame = hs.indexOf("</jwf-flame>", psFlame + 1);
                    String flameXML = hs.substring(psFlame, peFlame + 12);
                    Flame flame = new FlameReader(prefs).readFlamesfromXML(flameXML).get(0);
                    part.setFlame(flame);
                    // System.out.println(flameXML);
                    hs = hs.substring(0, psFlame);
                }
            }
            parseMoviePartAttributes(part, hs);
            p = pe + 2;
        }
    }
    return movie;
}
Also used : FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) FlameMoviePart(org.jwildfire.create.tina.animate.FlameMoviePart) Flame(org.jwildfire.create.tina.base.Flame)

Example 7 with FlameMovie

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

the class TransformingBubblesRandomMovieGenerator method prepareMovie.

@Override
protected FlameMovie prepareMovie(Prefs pPrefs) {
    FlameMovie movie = new FlameMovie(pPrefs);
    Flame flame = genRandomFlame(new BubblesRandomFlameGenerator(), 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_FIRST_XFORM, amplitude);
    }
    return movie;
}
Also used : XFormScript(org.jwildfire.create.tina.animate.XFormScript) GlobalScript(org.jwildfire.create.tina.animate.GlobalScript) BubblesRandomFlameGenerator(org.jwildfire.create.tina.randomflame.BubblesRandomFlameGenerator) FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) FlameMoviePart(org.jwildfire.create.tina.animate.FlameMoviePart) Flame(org.jwildfire.create.tina.base.Flame)

Example 8 with FlameMovie

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

the class JWFMovieFilePreview method createThumbnail.

public void createThumbnail() {
    if (currFile == null) {
        currThumbnail = null;
        return;
    }
    try {
        if (currFile.exists()) {
            FlameMovie movie = new FlameMovieReader(prefs).readMovie(currFile.getAbsolutePath());
            Flame flame = null;
            if (movie != null) {
                for (FlameMoviePart part : movie.getParts()) {
                    if (part.getFlame() != null) {
                        flame = part.getFlame();
                        break;
                    }
                }
            }
            if (flame != null) {
                int imgWidth = this.getPreferredSize().width;
                int imgHeight = this.getPreferredSize().height;
                double wScl = (double) imgWidth / (double) flame.getWidth();
                double hScl = (double) imgHeight / (double) flame.getHeight();
                flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
                flame.setWidth(imgWidth);
                flame.setHeight(imgHeight);
                FlameRenderer renderer = new FlameRenderer(flame, prefs, false, true);
                renderer.setProgressUpdater(null);
                flame.setSampleDensity(50);
                flame.setSpatialFilterRadius(0.0);
                RenderInfo info = new RenderInfo(imgWidth, imgHeight, RenderMode.PREVIEW);
                RenderedFlame res = renderer.renderFlame(info);
                currThumbnail = new ImageIcon(res.getImage().getBufferedImg());
            }
        }
    } catch (Exception ex) {
        currThumbnail = null;
        if (ex.getCause() != null) {
            ex.getCause().printStackTrace();
        } else {
            ex.printStackTrace();
        }
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) FlameMovieReader(org.jwildfire.create.tina.io.FlameMovieReader) FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) FlameRenderer(org.jwildfire.create.tina.render.FlameRenderer) RenderInfo(org.jwildfire.create.tina.render.RenderInfo) FlameMoviePart(org.jwildfire.create.tina.animate.FlameMoviePart) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame) Flame(org.jwildfire.create.tina.base.Flame) RenderedFlame(org.jwildfire.create.tina.render.RenderedFlame)

Example 9 with FlameMovie

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

the class TinaSWFAnimatorController method clearCurrentPreview.

private void clearCurrentPreview() {
    for (int i = 0; i < randomBatch.size(); i++) {
        FlameMovie bMovie = randomBatch.get(i).getMovie();
        if (bMovie == currMovie) {
            randomBatch.get(i).preview = null;
            ImagePanel pnl = randomBatch.get(i).getImgPanel();
            if (pnl != null) {
                pnl.replaceImage(randomBatch.get(i).getPreview(prefs.getTinaRenderPreviewQuality() / 2));
                pnl.repaint();
            }
            break;
        }
    }
}
Also used : FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) ImagePanel(org.jwildfire.swing.ImagePanel)

Example 10 with FlameMovie

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

the class TinaSWFAnimatorController method movieFromClipboardButton_clicked.

public void movieFromClipboardButton_clicked() {
    try {
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        Transferable clipData = clipboard.getContents(clipboard);
        if (clipData != null) {
            if (clipData.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                String xml = (String) (clipData.getTransferData(DataFlavor.stringFlavor));
                FlameMovie movie = new FlameMovieReader(prefs).readMovieFromXML(xml);
                if (movie != null) {
                    randomBatch.add(0, new MovieThumbnail(movie, null));
                    currMovie = movie;
                    updateThumbnails();
                }
                refreshControls();
                previewFlameImage();
            }
        }
    } catch (Throwable ex) {
        errorHandler.handleError(ex);
    }
}
Also used : FlameMovieReader(org.jwildfire.create.tina.io.FlameMovieReader) Transferable(java.awt.datatransfer.Transferable) FlameMovie(org.jwildfire.create.tina.animate.FlameMovie) Clipboard(java.awt.datatransfer.Clipboard)

Aggregations

FlameMovie (org.jwildfire.create.tina.animate.FlameMovie)10 FlameMoviePart (org.jwildfire.create.tina.animate.FlameMoviePart)5 Flame (org.jwildfire.create.tina.base.Flame)5 GlobalScript (org.jwildfire.create.tina.animate.GlobalScript)3 FlameMovieReader (org.jwildfire.create.tina.io.FlameMovieReader)3 XFormScript (org.jwildfire.create.tina.animate.XFormScript)2 Clipboard (java.awt.datatransfer.Clipboard)1 Transferable (java.awt.datatransfer.Transferable)1 File (java.io.File)1 ImageIcon (javax.swing.ImageIcon)1 JFileChooser (javax.swing.JFileChooser)1 BubblesRandomFlameGenerator (org.jwildfire.create.tina.randomflame.BubblesRandomFlameGenerator)1 DuckiesRandomFlameGenerator (org.jwildfire.create.tina.randomflame.DuckiesRandomFlameGenerator)1 MandelbrotRandomFlameGenerator (org.jwildfire.create.tina.randomflame.MandelbrotRandomFlameGenerator)1 FlameRenderer (org.jwildfire.create.tina.render.FlameRenderer)1 RenderInfo (org.jwildfire.create.tina.render.RenderInfo)1 RenderedFlame (org.jwildfire.create.tina.render.RenderedFlame)1 ImagePanel (org.jwildfire.swing.ImagePanel)1