use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.
the class BokehMutation method execute.
@Override
public void execute(Layer pLayer) {
Flame flame = pLayer.getOwner();
flame.setCamDOF(0.1 + Math.random() * 0.3);
flame.setNewCamDOF(true);
flame.setCamPitch(30 + Math.random() * 20.0);
flame.setCamYaw(15 - Math.random() * 30.0);
flame.setCamPerspective(0.05 + Math.random() * 0.2);
flame.setCamDOFArea(0.2 + Math.random() * 0.5);
for (Layer layer : flame.getLayers()) {
Variation crackle = null;
for (XForm xform : layer.getXForms()) {
for (int i = xform.getVariationCount() - 1; i >= 0; i--) {
Variation var = xform.getVariation(i);
if (var.getFunc().getName().equals(CrackleFunc.VAR_NAME)) {
VariationFunc varFunc = var.getFunc();
double scale = (Double) varFunc.getParameter(CrackleFunc.PARAM_SCALE);
if (MathLib.fabs(scale) < MathLib.EPSILON) {
crackle = var;
xform.setColor(Math.random());
break;
}
}
}
}
if (crackle == null) {
XForm xform = new XForm();
xform.setWeight(0.5);
layer.getXForms().add(xform);
crackle = xform.addVariation(1.0, VariationFuncList.getVariationFuncInstance(CrackleFunc.VAR_NAME));
crackle.getFunc().setParameter(CrackleFunc.PARAM_SCALE, 0.0);
}
crackle.setAmount(1.0 + Math.random() * 2.0);
crackle.getFunc().setParameter(CrackleFunc.PARAM_DISTORT, 1.5 + Math.random() * 1.5);
crackle.getFunc().setParameter(CrackleFunc.PARAM_CELLSIZE, 0.5 + Math.random() * 2.0);
if (Math.random() < 0.33) {
flame.setFocusX(0.33 - Math.random() * 0.66);
flame.setFocusY(0.25 - Math.random() * 0.50);
flame.setFocusZ(0.1 - Math.random() * 0.2);
} else {
flame.setFocusX(0.0);
flame.setFocusY(0.0);
flame.setFocusZ(0.0);
}
flame.setCamDOFScale(1.5 + Math.random() * 2.0);
flame.setCamDOFAngle(20.0 * Math.random());
flame.setCamDOFParam1(0);
flame.setCamDOFParam2(0);
flame.setCamDOFParam3(0);
flame.setCamDOFParam4(0);
flame.setCamDOFParam5(0);
double rnd = Math.random();
if (rnd < 0.08) {
flame.setCamDOFShape(DOFBlurShapeType.BUBBLE);
flame.setCamDOFFade(0.6 + Math.random() * 0.4);
} else if (rnd < 0.16) {
flame.setCamDOFShape(DOFBlurShapeType.HEART);
if (Math.random() < 0.25) {
flame.setCamDOFFade(0.2 + Math.random() * 0.8);
} else {
flame.setCamDOFFade(0.0);
}
} else if (rnd < 0.24) {
flame.setCamDOFShape(DOFBlurShapeType.CANNABISCURVE);
if (Math.random() < 0.25) {
flame.setCamDOFFade(0.2 + Math.random() * 0.8);
} else {
flame.setCamDOFFade(0.0);
}
} else if (rnd < 0.32) {
flame.setCamDOFShape(DOFBlurShapeType.NBLUR);
flame.setCamDOFFade(0.0);
// num edges
flame.setCamDOFParam1(3 + Math.random() * 5);
if (Math.random() < 0.33) {
// num stripes
flame.setCamDOFParam2(2 + Math.random() * 5);
// ratio stripes
flame.setCamDOFParam3(1);
// ratio hole
flame.setCamDOFParam4(0);
// circum circle
flame.setCamDOFParam5(Math.random() < 0.33 ? 1 : 0);
}
} else if (rnd < 0.40) {
flame.setCamDOFShape(DOFBlurShapeType.FLOWER);
flame.setCamDOFFade(0.0);
// holes
flame.setCamDOFParam1(0.3 + Math.random() * 0.2);
// petals
flame.setCamDOFParam2(5 + Math.random() * 5);
} else if (rnd < 0.48) {
flame.setCamDOFShape(DOFBlurShapeType.CLOVERLEAF);
if (Math.random() < 0.25) {
flame.setCamDOFFade(0.2 + Math.random() * 0.8);
} else {
flame.setCamDOFFade(0.0);
}
} else if (rnd < 0.56) {
flame.setCamDOFShape(DOFBlurShapeType.SINEBLUR);
flame.setCamDOFFade(0.0);
flame.setCamDOFParam1(1.2 + Math.random());
} else if (rnd < 0.64) {
flame.setCamDOFShape(DOFBlurShapeType.PERLIN_NOISE);
flame.setCamDOFFade(0.0);
// shape
flame.setCamDOFParam1(Math.random());
// freqs
flame.setCamDOFParam2(1.2 + Math.random() * 1.8);
// amp
flame.setCamDOFParam3(0.1 + Math.random() * 0.4);
} else if (rnd < 0.72) {
flame.setCamDOFFade(0.2 + Math.random() * 0.8);
flame.setCamDOFShape(DOFBlurShapeType.STARBLUR);
// power
flame.setCamDOFParam1(4 + Math.random() * 6);
// range
flame.setCamDOFParam2(0.40162283177245455973959534526548);
} else if (rnd < 0.80) {
flame.setCamDOFAngle(0.0);
flame.setCamDOFFade(0.);
flame.setCamDOFShape(DOFBlurShapeType.TAURUS);
// r
flame.setCamDOFParam1(2.5 + Math.random());
// n
flame.setCamDOFParam2(4 + Math.random() * 3.0);
// inv
flame.setCamDOFParam3(1.25 * Math.random() * 0.5);
// sor
flame.setCamDOFParam4(0.9 + Math.random() * 0.2);
} else if (rnd < 0.9) {
flame.setCamDOFShape(DOFBlurShapeType.RECT);
flame.setCamDOFFade(0.0);
flame.setCamDOFParam1(0.4 + Math.random() * 0.4);
}
}
}
use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.
the class AnimationModelService method addXFormToModel.
@SuppressWarnings("unchecked")
private static void addXFormToModel(PropertyModel pNode, boolean pIsFinal, int pIndex, XForm pXForm, PropertyVisitor pVisitor, VisitState pState) {
Class<?> cls = pXForm.getClass();
String fieldname = pIsFinal ? PROPNAME_FINALXFORM : PROPNAME_XFORM;
PropertyModel xFormNode = new PropertyModel(pNode, fieldname + (pIndex + 1), cls);
pNode.getChields().add(xFormNode);
for (String propName : ADD_XFORM_PROPS) {
if (pState.isCancelSignalled()) {
return;
}
PlainProperty property = new PlainProperty(xFormNode, propName, Double.class);
xFormNode.getProperties().add(property);
if (pVisitor != null) {
pState.updateState(pVisitor.accept(pXForm, propName, property));
}
}
for (Field field : cls.getDeclaredFields()) {
if (pState.isCancelSignalled()) {
return;
}
field.setAccessible(true);
if (field.getAnnotation(AnimAware.class) != null) {
Class<?> fCls = field.getType();
if (isPrimitiveProperty(fCls)) {
PlainProperty property = new PlainProperty(xFormNode, field.getName(), cls);
xFormNode.getProperties().add(property);
if (pVisitor != null) {
pState.updateState(pVisitor.accept(pXForm, field, property));
}
} else if (fCls == List.class) {
ParameterizedType listType = (ParameterizedType) field.getGenericType();
Class<?> listSubClass = (Class<?>) listType.getActualTypeArguments()[0];
if (listSubClass.isAssignableFrom(Variation.class)) {
List<Variation> variations;
try {
variations = (List<Variation>) field.get(pXForm);
} catch (Exception e) {
variations = null;
e.printStackTrace();
}
if (variations != null) {
for (Variation variation : variations) {
addVariationToModel(xFormNode, variation, pVisitor, pState);
}
}
}
}
}
}
}
use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.
the class SolidShadowsRandomFlameGenerator method postProcessFlameAfterRendering.
@Override
protected Flame postProcessFlameAfterRendering(RandomFlameGeneratorState pState, Flame pFlame) {
pFlame.setCamZoom(0.5 + Math.random() * 0.25);
pFlame.setCamPerspective(0.05 + Math.random() * 0.15);
pFlame.setCamPitch(-5.0 - Math.random() * 30.0);
pFlame.setCamYaw(-25.0 + Math.random() * 50.0);
pFlame.setCamRoll(0.0);
XForm xform0 = pFlame.getFirstLayer().getXForms().get(0);
Variation var0 = xform0.getVariation(0);
var0.setAmount(var0.getAmount() * (0.25 + Math.random() * 0.25));
Layer layer = new Layer();
layer.setWeight(0.25 + Math.random() * 0.5);
pFlame.getLayers().add(layer);
new RandomGradientMutation().execute(layer);
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.5);
if (Math.random() < 0.5) {
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("plane_wf", true);
varFunc.setParameter("axis", 2);
varFunc.setParameter("position", Math.random() * 2.0 - 0.25);
varFunc.setParameter("color_mode", Tools.FTOI(4 * Math.random()));
xForm.addVariation(1.0 + Math.random(), varFunc);
} else {
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("checkerboard_wf", true);
varFunc.setParameter("axis", 2);
varFunc.setParameter("position", Math.random() * 2.0 - 0.25);
varFunc.setParameter("checker_size", 0.05 + Math.random() * 0.1);
varFunc.setParameter("displ_amount", 0.005 + Math.random() * 0.03);
varFunc.setParameter("with_sides", Math.random() > 0.25 ? 1 : 0);
xForm.addVariation(1.0 + Math.random(), varFunc);
}
}
pFlame.getSolidRenderSettings().setShadowType(Math.random() < 0.5 ? ShadowType.SMOOTH : ShadowType.FAST);
return pFlame;
}
use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.
the class FlameMorphService method prepareMorphXForm.
private static void prepareMorphXForm(XForm pXForm) {
int i = 0;
while (i < pXForm.getVariationCount()) {
Variation var = pXForm.getVariation(i);
if (var.getFunc() instanceof Spherical3DWFFunc) {
Object invert = var.getFunc().getParameter(Spherical3DWFFunc.PARAM_INVERT);
if (invert != null && ((Integer) invert) == 1) {
var.getFunc().setParameter(Spherical3DWFFunc.PARAM_INVERT, 0);
var.setAmount(-var.getAmount());
}
} else if (var.getFunc() instanceof PostMirrorWFFunc) {
pXForm.removeVariation(var);
i--;
}
i++;
}
}
use of org.jwildfire.create.tina.variation.Variation in project JWildfire by thargor6.
the class XForm method assign.
@Override
public void assign(XForm pXForm) {
weight = pXForm.weight;
weightCurve.assign(pXForm.weightCurve);
color = pXForm.color;
colorCurve.assign(pXForm.colorCurve);
colorSymmetry = pXForm.colorSymmetry;
colorSymmetryCurve.assign(pXForm.colorSymmetryCurve);
material = pXForm.material;
materialCurve.assign(pXForm.materialCurve);
materialSpeed = pXForm.materialSpeed;
materialSymmetryCurve.assign(pXForm.materialSymmetryCurve);
modGamma = pXForm.modGamma;
modGammaSpeed = pXForm.modGammaSpeed;
modContrast = pXForm.modContrast;
modContrastSpeed = pXForm.modContrastSpeed;
modSaturation = pXForm.modSaturation;
modSaturationSpeed = pXForm.modSaturationSpeed;
modHue = pXForm.modHue;
modHueSpeed = pXForm.modHueSpeed;
xyCoeff00 = pXForm.xyCoeff00;
xyCoeff00Curve.assign(pXForm.xyCoeff00Curve);
xyCoeff01 = pXForm.xyCoeff01;
xyCoeff01Curve.assign(pXForm.xyCoeff01Curve);
xyCoeff10 = pXForm.xyCoeff10;
xyCoeff10Curve.assign(pXForm.xyCoeff10Curve);
xyCoeff11 = pXForm.xyCoeff11;
xyCoeff11Curve.assign(pXForm.xyCoeff11Curve);
xyCoeff20 = pXForm.xyCoeff20;
xyCoeff20Curve.assign(pXForm.xyCoeff20Curve);
xyCoeff21 = pXForm.xyCoeff21;
xyCoeff21Curve.assign(pXForm.xyCoeff21Curve);
xyPostCoeff00 = pXForm.xyPostCoeff00;
xyPostCoeff00Curve.assign(pXForm.xyPostCoeff00Curve);
xyPostCoeff01 = pXForm.xyPostCoeff01;
xyPostCoeff01Curve.assign(pXForm.xyPostCoeff01Curve);
xyPostCoeff10 = pXForm.xyPostCoeff10;
xyPostCoeff10Curve.assign(pXForm.xyPostCoeff10Curve);
xyPostCoeff11 = pXForm.xyPostCoeff11;
xyPostCoeff11Curve.assign(pXForm.xyPostCoeff11Curve);
xyPostCoeff20 = pXForm.xyPostCoeff20;
xyPostCoeff20Curve.assign(pXForm.xyPostCoeff20Curve);
xyPostCoeff21 = pXForm.xyPostCoeff21;
xyPostCoeff21Curve.assign(pXForm.xyPostCoeff21Curve);
yzCoeff00 = pXForm.yzCoeff00;
yzCoeff00Curve.assign(pXForm.yzCoeff00Curve);
yzCoeff01 = pXForm.yzCoeff01;
yzCoeff01Curve.assign(pXForm.yzCoeff01Curve);
yzCoeff10 = pXForm.yzCoeff10;
yzCoeff10Curve.assign(pXForm.yzCoeff10Curve);
yzCoeff11 = pXForm.yzCoeff11;
yzCoeff11Curve.assign(pXForm.yzCoeff11Curve);
yzCoeff20 = pXForm.yzCoeff20;
yzCoeff20Curve.assign(pXForm.yzCoeff20Curve);
yzCoeff21 = pXForm.yzCoeff21;
yzCoeff21Curve.assign(pXForm.yzCoeff21Curve);
yzPostCoeff00 = pXForm.yzPostCoeff00;
yzPostCoeff00Curve.assign(pXForm.yzPostCoeff00Curve);
yzPostCoeff01 = pXForm.yzPostCoeff01;
yzPostCoeff01Curve.assign(pXForm.yzPostCoeff01Curve);
yzPostCoeff10 = pXForm.yzPostCoeff10;
yzPostCoeff10Curve.assign(pXForm.yzPostCoeff10Curve);
yzPostCoeff11 = pXForm.yzPostCoeff11;
yzPostCoeff11Curve.assign(pXForm.yzPostCoeff11Curve);
yzPostCoeff20 = pXForm.yzPostCoeff20;
yzPostCoeff20Curve.assign(pXForm.yzPostCoeff20Curve);
yzPostCoeff21 = pXForm.yzPostCoeff21;
yzPostCoeff21Curve.assign(pXForm.yzPostCoeff21Curve);
zxCoeff00 = pXForm.zxCoeff00;
zxCoeff00Curve.assign(pXForm.zxCoeff00Curve);
zxCoeff01 = pXForm.zxCoeff01;
zxCoeff01Curve.assign(pXForm.zxCoeff01Curve);
zxCoeff10 = pXForm.zxCoeff10;
zxCoeff10Curve.assign(pXForm.zxCoeff10Curve);
zxCoeff11 = pXForm.zxCoeff11;
zxCoeff11Curve.assign(pXForm.zxCoeff11Curve);
zxCoeff20 = pXForm.zxCoeff20;
zxCoeff20Curve.assign(pXForm.zxCoeff20Curve);
zxCoeff21 = pXForm.zxCoeff21;
zxCoeff21Curve.assign(pXForm.zxCoeff21Curve);
zxPostCoeff00 = pXForm.zxPostCoeff00;
zxPostCoeff00Curve.assign(pXForm.zxPostCoeff00Curve);
zxPostCoeff01 = pXForm.zxPostCoeff01;
zxPostCoeff01Curve.assign(pXForm.zxPostCoeff01Curve);
zxPostCoeff10 = pXForm.zxPostCoeff10;
zxPostCoeff10Curve.assign(pXForm.zxPostCoeff10Curve);
zxPostCoeff11 = pXForm.zxPostCoeff11;
zxPostCoeff11Curve.assign(pXForm.zxPostCoeff11Curve);
zxPostCoeff20 = pXForm.zxPostCoeff20;
zxPostCoeff20Curve.assign(pXForm.zxPostCoeff20Curve);
zxPostCoeff21 = pXForm.zxPostCoeff21;
zxPostCoeff21Curve.assign(pXForm.zxPostCoeff21Curve);
xyRotateCurve.assign(pXForm.xyRotateCurve);
xyScaleCurve.assign(pXForm.xyScaleCurve);
xyPostRotateCurve.assign(pXForm.xyPostRotateCurve);
xyPostScaleCurve.assign(pXForm.xyPostScaleCurve);
yzRotateCurve.assign(pXForm.yzRotateCurve);
yzScaleCurve.assign(pXForm.yzScaleCurve);
yzPostRotateCurve.assign(pXForm.yzPostRotateCurve);
yzPostScaleCurve.assign(pXForm.yzPostScaleCurve);
zxRotateCurve.assign(pXForm.zxRotateCurve);
zxScaleCurve.assign(pXForm.zxScaleCurve);
zxPostRotateCurve.assign(pXForm.zxPostRotateCurve);
zxPostScaleCurve.assign(pXForm.zxPostScaleCurve);
mirrorPrePostTranslations = pXForm.mirrorPrePostTranslations;
hasXYPostCoeffs = pXForm.hasXYPostCoeffs;
hasXYCoeffs = pXForm.hasXYCoeffs;
hasYZPostCoeffs = pXForm.hasYZPostCoeffs;
hasYZCoeffs = pXForm.hasYZCoeffs;
hasZXPostCoeffs = pXForm.hasZXPostCoeffs;
hasZXCoeffs = pXForm.hasZXCoeffs;
variations.clear();
for (Variation var : pXForm.variations) {
Variation newVar = new Variation();
newVar.assign(var);
variations.add(newVar);
}
System.arraycopy(pXForm.modifiedWeights, 0, modifiedWeights, 0, pXForm.modifiedWeights.length);
opacity = pXForm.opacity;
opacityCurve.assign(pXForm.opacityCurve);
drawMode = pXForm.drawMode;
name = pXForm.name;
}
Aggregations