public class SphericalRandomFlameGenerator extends RandomFlameGenerator {
@Override
protected Flame prepareFlame(RandomFlameGeneratorState pState) {
Flame flame = new Flame();
Layer layer = flame.getFirstLayer();
flame.setCentreX(0.0);
flame.setCentreY(0.0);
flame.setCamPitch(0.0);
flame.setCamRoll(90.0);
flame.setCamYaw(0.0);
flame.setCamZoom(2.4);
flame.setCamPerspective(0.32);
flame.setPixelsPerUnit(200);
layer.getFinalXForms().clear();
layer.getXForms().clear();
VariationFunc varFunc;
// 1st xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(4.0 + 12.0 * Math.random());
varFunc = VariationFuncList.getVariationFuncInstance("spherical3D", true);
xForm.addVariation(1.0, varFunc);
// XFormTransformService.rotate(xForm, Math.random() < 0.5 ? 90.0 : -90.0, false);
XFormTransformService.rotate(xForm, Math.random() < 0.5 ? Math.random() < 0.5 ? 180.0 : 90 : -90.0, false);
XFormTransformService.globalTranslate(xForm, 1.0, 0.0, false);
xForm.setColor(1.0);
xForm.setColorSymmetry(0.9 + Math.random() * 0.2);
}
// 2nd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(3.0 + 11.0 * Math.random());
varFunc = VariationFuncList.getVariationFuncInstance("spherical3D", true);
xForm.addVariation(1.0, varFunc);
// XFormTransformService.rotate(xForm, 90.0, false);
XFormTransformService.rotate(xForm, Math.random() < 0.5 ? Math.random() < 0.5 ? 180.0 : 90 : -90.0, false);
xForm.setColor(0.5);
xForm.setColorSymmetry(0.9 + Math.random() * 0.2);
}
// 3rd xForm
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.3 + 0.2 * Math.random());
varFunc = VariationFuncList.getVariationFuncInstance("linear3D", true);
xForm.addVariation(1.0, varFunc);
XFormTransformService.rotate(xForm, 90.0, false);
XFormTransformService.globalTranslate(xForm, (int) (2.0 + Math.random() * 2.0), 0.0, false);
xForm.setColor(Math.random());
xForm.setColorSymmetry(0);
}
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.2 + 0.15 * Math.random());
varFunc = VariationFuncList.getVariationFuncInstance("linear3D", true);
xForm.addVariation(1.0, varFunc);
XFormTransformService.rotate(xForm, 90.0, false);
XFormTransformService.globalTranslate(xForm, -(int) (2.0 + Math.random() * 2.0), 0.0, false);
xForm.setColor(Math.random());
xForm.setColorSymmetry(0);
}
int max = (int) (Math.random() * 4.0);
for (int i = 0; i < max; i++) {
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5 + 0.3 * Math.random());
String fncName = ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL[(int) (ExperimentalSimpleRandomFlameGenerator.FNCLST_EXPERIMENTAL.length * Math.random())];
varFunc = VariationFuncList.getVariationFuncInstance(fncName, true);
xForm.addVariation(1.0, varFunc);