/*
JWildfire - an image and animation processor written in Java
Copyright (C) 1995-2017 Andreas Maschke
This is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this software;
if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jwildfire.create.tina.randomflame;
import org.jwildfire.create.tina.base.EditPlane;
import org.jwildfire.create.tina.base.Flame;
import org.jwildfire.create.tina.base.Layer;
import org.jwildfire.create.tina.base.XForm;
import org.jwildfire.create.tina.transform.XFormTransformService;
import org.jwildfire.create.tina.variation.VariationFunc;
import org.jwildfire.create.tina.variation.VariationFuncList;
public class MachineRandomFlameGenerator extends RandomFlameGenerator {
@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
Flame flame = new Flame();
Layer layer = flame.getFirstLayer();
flame.setCentreX(Math.random() - 0.5);
flame.setCentreY(Math.random() - 0.5);
flame.setCamRoll(0);
flame.setCamPitch(0);
flame.setCamYaw(0);
flame.setCamPerspective(0);
flame.setCamZoom(1);
flame.setPixelsPerUnit(200);
layer.getFinalXForms().clear();
layer.getXForms().clear();
// 1st xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(32.16406573);
xForm.setColor(0.74488914);
xForm.setColorSymmetry(0);
xForm.setMaterial(0);
xForm.setMaterialSpeed(0);
xForm.setCoeff00(1); // a
xForm.setCoeff10(0); // b
xForm.setCoeff20(1.82382673); // e
xForm.setCoeff01(0); // c
xForm.setCoeff11(1); // d
xForm.setCoeff21(-1.8206164); // f
xForm.setPostCoeff00(1);
xForm.setPostCoeff10(0);
xForm.setPostCoeff01(0);
xForm.setPostCoeff11(1);
xForm.setPostCoeff20(0);
xForm.setPostCoeff21(0);
// variation 1
{
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true);
xForm.addVariation(1, varFunc);
}
flame.setEditPlane(EditPlane.XY);
XFormTransformService.scale(xForm, 1.25 - Math.random() * 0.5, true, true, false);
XFormTransformService.rotate(xForm, 360.0 * Math.random(), false);
XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
}
// 2nd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(257.3608644);
xForm.setColor(0.90312262);
xForm.setColorSymmetry(0.95);
xForm.setMaterial(0);
xForm.setMaterialSpeed(0);
xForm.setCoeff00(0.82496229); // a
xForm.setCoeff10(0.55902149); // b
xForm.setCoeff20(0.05455807); // e
xForm.setCoeff01(-0.55902149); // c
xForm.setCoeff11(0.82496229); // d
xForm.setCoeff21(0.73105973); // f
xForm.setPostCoeff00(1);
xForm.setPostCoeff10(0);
xForm.setPostCoeff01(0);
xForm.setPostCoeff11(1);
xForm.setPostCoeff20(0);
xForm.setPostCoeff21(0);
// change relative weights
xForm.getModifiedWeights()[0] = 0.54127492;
// variation 1
{
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("yin_yang", true);
varFunc.setParameter("radius", 0.25 + Math.random() * 0.5);
varFunc.setParameter("ang1", 0);
varFunc.setParameter("ang2", 0.1 + Math.random() * 0.5);
varFunc.setParameter("dual_t", 1);
varFunc.setParameter("outside", 1);
xForm.addVariation(0.75 + Math.random() * 0.5, varFunc);
}
flame.setEditPlane(EditPlane.XY);
XFormTransformService.scale(xForm, 1.25 - Math.random() * 0.5, true, true, false);
XFormTransformService.rotate(xForm, 360.0 * Math.random(), false);
XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
}
flame.getFirstLayer().randomizeColors();
return flame;
}
@Override
public String getName() {
return "Machine";
}
@Override
public boolean isUseFilter(RandomFlameGeneratorState pState) {
return true;
}
@Override
protected Flame postProcessFlameBeforeRendering(RandomFlameGeneratorState pState, Flame pFlame) {
return pFlame;
}
@Override
protected Flame postProcessFlameAfterRendering(RandomFlameGeneratorState pState, Flame pFlame) {
return pFlame;
}
}