use of org.jwildfire.create.tina.animate.FlameMoviePart in project JWildfire by thargor6.
the class RotatingMandelbrotRandomMovieGenerator method prepareMovie.
@Override
protected FlameMovie prepareMovie(Prefs pPrefs) {
FlameMovie movie = new FlameMovie(pPrefs);
Flame flame = genRandomFlame(new MandelbrotRandomFlameGenerator(), pPrefs);
flame.setCamPerspective(0.1 + 0.2 * Math.random());
if (Math.random() < 0.5) {
flame.setCamDOF(0.05 + 0.1 * Math.random());
}
FlameMoviePart part = new FlameMoviePart();
part.setFlame(flame);
part.setFrameCount(320);
part.setFrameMorphCount(0);
movie.addPart(part);
{
double amplitude = -0.75 * Math.random() * 1.5;
movie.getGlobalScripts()[0] = (new GlobalScript(GlobalScriptType.ROTATE_YAW, amplitude));
}
{
double amplitude = -0.25 * Math.random() * 0.5;
movie.getGlobalScripts()[1] = new GlobalScript(GlobalScriptType.ROTATE_ROLL, amplitude);
}
{
double amplitude = -0.125 * Math.random() * 0.25;
movie.getGlobalScripts()[2] = new GlobalScript(GlobalScriptType.ROTATE_PITCH, amplitude);
}
{
double amplitude = 0.2 + Math.random() * 0.6;
movie.getGlobalScripts()[2] = new GlobalScript(GlobalScriptType.MOVE_CAM_Z, amplitude);
}
{
double amplitude = 0.2 + Math.random() * 1.4;
movie.getGlobalScripts()[2] = new GlobalScript(GlobalScriptType.MOVE_CAM_Y, amplitude);
}
return movie;
}
use of org.jwildfire.create.tina.animate.FlameMoviePart 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;
}
use of org.jwildfire.create.tina.animate.FlameMoviePart 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.FlameMoviePart in project JWildfire by thargor6.
the class FlameMovieWriter method getMovieXML.
public String getMovieXML(FlameMovie pMovie) throws Exception {
SimpleXMLBuilder xb = new SimpleXMLBuilder();
// Flame
List<SimpleXMLBuilder.Attribute<?>> attrList = new ArrayList<SimpleXMLBuilder.Attribute<?>>();
attrList.add(xb.createAttr(ATTR_APPLICATION, Tools.APP_TITLE + " " + Tools.APP_VERSION));
attrList.add(xb.createAttr(ATTR_MOVIE_VERSION, MOVIE_VERSION));
for (int i = 0; i < pMovie.getGlobalScripts().length; i++) {
String idxStr = String.valueOf(i + 1);
addGlobalScript(pMovie.getGlobalScripts()[i], ATTR_SCRIPT_GLOBAL + idxStr, ATTR_SCRIPT_GLOBAL + idxStr + AMPLITUDE_POSTFIX, ATTR_SCRIPT_GLOBAL + idxStr + AMPLITUDE_CURVE_POSTFIX, attrList, xb);
}
for (int i = 0; i < pMovie.getxFormScripts().length; i++) {
String idxStr = String.valueOf(i + 1);
addXFormScript(pMovie.getxFormScripts()[i], ATTR_SCRIPT_XFORM + idxStr, ATTR_SCRIPT_XFORM + idxStr + AMPLITUDE_POSTFIX, ATTR_SCRIPT_XFORM + idxStr + AMPLITUDE_CURVE_POSTFIX, attrList, xb);
}
String xName = pMovie.getName().replaceAll("\"", "");
if (!xName.equals("")) {
attrList.add(xb.createAttr(ATTR_NAME, xName));
}
attrList.add(xb.createAttr(ATTR_FRAME_WIDTH, pMovie.getFrameWidth()));
attrList.add(xb.createAttr(ATTR_FRAME_HEIGHT, pMovie.getFrameHeight()));
attrList.add(xb.createAttr(ATTR_FPS, pMovie.getFramesPerSecond()));
attrList.add(xb.createAttr(ATTR_QUALITY, pMovie.getQuality()));
attrList.add(xb.createAttr(ATTR_SEQUENCE_OUTPUT_TYPE, pMovie.getSequenceOutputType().toString()));
attrList.add(xb.createAttr(AbstractFlameReader.ATTR_MOTIONBLUR_LENGTH, pMovie.getMotionBlurLength()));
attrList.add(xb.createAttr(AbstractFlameReader.ATTR_MOTIONBLUR_TIMESTEP, pMovie.getMotionBlurTimeStep()));
xb.beginElement(TAG_JWF_MOVIE, attrList);
for (FlameMoviePart part : pMovie.getParts()) {
addPart(xb, part);
}
xb.endElement(TAG_JWF_MOVIE);
return xb.buildXML();
}
use of org.jwildfire.create.tina.animate.FlameMoviePart 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;
}
Aggregations