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;
}
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;
}
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();
}
}
}
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;
}
}
}
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);
}
}
Aggregations