use of org.jwildfire.create.tina.animate.GlobalScript 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.GlobalScript 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.GlobalScript 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;
}
}
use of org.jwildfire.create.tina.animate.GlobalScript in project JWildfire by thargor6.
the class FlameMovieReader method readGlobalScript.
private GlobalScript readGlobalScript(String pAttrScript, String pAttrScriptAmplitude, String pAttrScriptAmplitudeCurve, XMLAttributes pAtts) {
GlobalScript script = new GlobalScript();
String hs;
if ((hs = pAtts.get(pAttrScript)) != null) {
try {
script.setScriptType(GlobalScriptType.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;
}
use of org.jwildfire.create.tina.animate.GlobalScript 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));
}
}
Aggregations