use of org.jwildfire.create.tina.base.XForm in project JWildfire by thargor6.
the class XenomorphRandomFlameGenerator method prepareFlame.
@Override
public Flame prepareFlame(RandomFlameGeneratorState pState) {
Flame flame = new Flame();
Layer layer = flame.getFirstLayer();
flame.setCentreX(0.0);
flame.setCentreY(0.0);
flame.setPixelsPerUnit(200);
layer.getFinalXForms().clear();
layer.getXForms().clear();
// create transform 1
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.1 + Math.random() * 0.4);
xForm.setColor(0.74488914);
xForm.setColorSymmetry(0);
// a
xForm.setCoeff00(0.75610133);
// b
xForm.setCoeff10(-0.74186252);
// e
xForm.setCoeff20(5.25778565);
// c
xForm.setCoeff01(0.74186252);
// d
xForm.setCoeff11(0.75610133);
// f
xForm.setCoeff21(-0.34949139);
xForm.setPostCoeff00(-0.42606416);
xForm.setPostCoeff10(0.44290131);
xForm.setPostCoeff01(-0.10610689);
xForm.setPostCoeff11(-0.40885976);
xForm.setPostCoeff20(-2.81712);
xForm.setPostCoeff21(7.390367);
// variation 1
xForm.addVariation(1.43, VariationFuncList.getVariationFuncInstance("bubble", true));
// variation 2
xForm.addVariation(0.012, VariationFuncList.getVariationFuncInstance("linear", true));
// variation 3
if (Math.random() > 0.6) {
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("radial_blur", true);
varFunc.setParameter("angle", 0.609835);
xForm.addVariation(-0.249, varFunc);
} else {
xForm.addVariation(Math.random() < 0.5 ? -0.249 : 0.5 - Math.random(), VariationFuncList.getVariationFuncInstance(VariationFuncList.getRandomVariationname(), true));
}
// variation 4
xForm.addVariation(1, VariationFuncList.getVariationFuncInstance("power", true));
// random affine transforms (uncomment to play around)
// 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);
// random affine post transforms (uncomment to play around)
// XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
// XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
// XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
}
// create transform 2
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(10.0 + Math.random() * 8.0);
xForm.setColor(0.90312262);
xForm.setColorSymmetry(0.95);
// a
xForm.setCoeff00(-0.85421287);
// b
xForm.setCoeff10(-0.63343313);
// e
xForm.setCoeff20(1.09379129);
// c
xForm.setCoeff01(-0.63343313);
// d
xForm.setCoeff11(0.85421287);
// f
xForm.setCoeff21(-0.20406326);
xForm.setPostCoeff00(0.84389756);
xForm.setPostCoeff10(-0.35800434);
xForm.setPostCoeff01(0.43174917);
xForm.setPostCoeff11(0.89637273);
xForm.setPostCoeff20(-0.945758);
xForm.setPostCoeff21(-0.4502584);
// change relative weights
xForm.getModifiedWeights()[0] = 2.05;
xForm.getModifiedWeights()[1] = 1.25;
xForm.getModifiedWeights()[2] = 0.9;
// variation 1
xForm.addVariation(0.008, VariationFuncList.getVariationFuncInstance("linear", true));
// variation 2
xForm.addVariation(10.72, VariationFuncList.getVariationFuncInstance("spherical", true));
// random affine transforms (uncomment to play around)
XFormTransformService.scale(xForm, 1.25 - Math.random() * 0.5, true, true, false);
XFormTransformService.rotate(xForm, 36.0 * Math.random(), false);
XFormTransformService.localTranslate(xForm, 1.0 - 2.0 * Math.random(), 1.0 - 2.0 * Math.random(), false);
// random affine post transforms (uncomment to play around)
// XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
// XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
// XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
}
// create transform 3
{
XForm xForm = new XForm();
layer.getXForms().add(xForm);
xForm.setWeight(0.7);
xForm.setColor(0.47272985);
xForm.setColorSymmetry(0);
// a
xForm.setCoeff00(0.68724662);
// b
xForm.setCoeff10(-0.72642418);
// e
xForm.setCoeff20(-2.14812602);
// c
xForm.setCoeff01(0.72642418);
// d
xForm.setCoeff11(0.68724662);
// f
xForm.setCoeff21(2.39994214);
xForm.setPostCoeff00(0.60646395);
xForm.setPostCoeff10(0.79511098);
xForm.setPostCoeff01(-0.79511098);
xForm.setPostCoeff11(0.60646395);
xForm.setPostCoeff20(-1.06135064);
xForm.setPostCoeff21(-0.6369509);
// variation 1
{
VariationFunc varFunc = VariationFuncList.getVariationFuncInstance("bipolar", true);
varFunc.setParameter("shift", 0);
xForm.addVariation(1, varFunc);
}
// random affine transforms (uncomment to play around)
// 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);
// random affine post transforms (uncomment to play around)
// XFormTransformService.scale(xForm, 1.25-Math.random()*0.5, true, true, true);
// XFormTransformService.rotate(xForm, 360.0*Math.random(), true);
// XFormTransformService.localTranslate(xForm, 1.0-2.0*Math.random(), 1.0-2.0*Math.random(), true);
}
return flame;
}
use of org.jwildfire.create.tina.base.XForm in project JWildfire by thargor6.
the class DefaultRenderIterationState method iterateNext.
public void iterateNext(List<RenderSlice> pSlices) {
int nextXForm = randGen.random(Constants.NEXT_APPLIED_XFORM_TABLE_SIZE);
xf = xf.getNextAppliedXFormTable()[nextXForm];
if (xf == null) {
return;
}
transformPoint();
if (xf.getDrawMode() == DrawMode.HIDDEN)
return;
else if ((xf.getDrawMode() == DrawMode.OPAQUE) && (randGen.random() > xf.getOpacity()))
return;
List<XForm> finalXForms = layer.getFinalXForms();
if (finalXForms.size() > 0) {
applyFinalTransforms(finalXForms);
} else {
applyEmptyFinalTransform();
}
if (setupSliceRaster(q, pSlices)) {
projector.projectPoint(q);
}
}
use of org.jwildfire.create.tina.base.XForm in project JWildfire by thargor6.
the class SubFlameWFFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
int iter = 0;
final int MAX_ITER = 1000;
if (p.isInfinite() || p.isNaN()) {
prefuseIter(pContext);
}
while (xf != null) {
if (++iter > MAX_ITER) {
return;
}
xf = xf.getNextAppliedXFormTable()[pContext.random(Constants.NEXT_APPLIED_XFORM_TABLE_SIZE)];
if (xf == null) {
return;
}
// double parentColor = pAffineTP.color;
a.clear();
v.clear();
xf.transformPoint(pContext, a, v, p, p);
if (xf.getDrawMode() == DrawMode.HIDDEN)
continue;
else if ((xf.getDrawMode() == DrawMode.OPAQUE) && (pContext.random() > xf.getOpacity()))
continue;
Layer layer = flame.getFirstLayer();
List<XForm> finalXForms = layer.getFinalXForms();
if (finalXForms.size() > 0) {
finalXForms.get(0).transformPoint(pContext, pAffineTP, pVarTP, p, q);
for (int i = 1; i < finalXForms.size(); i++) {
finalXForms.get(i).transformPoint(pContext, pAffineTP, pVarTP, q, q);
}
} else {
q.assign(p);
}
// pVarTP.color -= 1.0;
break;
}
if (!q.doHide) {
pVarTP.doHide = false;
pVarTP.x += q.x + offset_x;
pVarTP.y += q.y + offset_y;
pVarTP.z += q.z + offset_z + colorscale_z * q.color;
if (color_mode != CM_OFF) {
if (q.rgbColor) {
pVarTP.rgbColor = true;
pVarTP.redColor = q.redColor;
pVarTP.greenColor = q.greenColor;
pVarTP.blueColor = q.blueColor;
}
switch(color_mode) {
case CM_DIRECT:
pVarTP.color = q.color;
break;
case CM_RED:
pVarTP.color = pVarTP.redColor / 255.0;
break;
case CM_GREEN:
pVarTP.color = pVarTP.greenColor / 255.0;
break;
case CM_BLUE:
pVarTP.color = pVarTP.blueColor / 255.0;
break;
case CM_BRIGHTNESS:
pVarTP.color = (0.2990 * pVarTP.redColor + 0.5880 * pVarTP.greenColor + 0.1130 * pVarTP.blueColor) / 255.0;
break;
}
}
} else {
pVarTP.doHide = true;
}
}
use of org.jwildfire.create.tina.base.XForm in project JWildfire by thargor6.
the class Boarders2Test method testTransformYbigYPos.
@Test
public void testTransformYbigYPos() {
XYZPoint pt = new XYZPoint();
pt.y = .4;
pt.x = .2;
pt.z = 1;
XYZPoint pt2 = new XYZPoint();
pt2.y = .4;
pt2.x = .2;
pt2.z = 1;
Boarders2Func bf = new Boarders2Func();
bf.init(null, null, new XForm(), 10);
Flame f = new Flame();
f.setHeight(500);
f.setWidth(500);
f.setName("test1");
bf.transform(new FlameTransformationContext(new FlameRenderer(f, Prefs.getPrefs(), true, false), new ZigguratRandomGenerator(), 1), new XForm(), pt, pt2, 10);
}
use of org.jwildfire.create.tina.base.XForm in project JWildfire by thargor6.
the class PolylogarithmTest method visual.
@Test
@Ignore
public void visual() throws Exception {
int side = 400;
ResolutionProfile respro = new ResolutionProfile(true, side, side);
int quality = 200;
Flame f = new Flame();
f.setWidth(side);
f.setHeight(side);
f.setGamma(4.0);
f.setBGTransparency(false);
f.setAntialiasAmount(.1);
f.setAntialiasRadius(.1);
Layer l = new Layer();
XForm xf = new XForm();
SquishFunc df = new SquishFunc();
df.setParameter("power", 10);
xf.addVariation(1, df);
PolylogarithmFunc bf = new PolylogarithmFunc();
bf.setParameter("n", 2);
bf.setParameter("zpow", 1);
xf.addVariation(.1, bf);
f.setCamZoom(6);
xf.setWeight(10);
l.getXForms().add(xf);
RGBPalette pal = new RGBPalette();
for (int i = 0; i < 256; i++) pal.addColor(0, i, 255);
pal.setFlam3Name("PolylogarithmFunc");
l.setPalette(pal);
f.setResolutionProfile(respro);
f.getLayers().clear();
f.getLayers().add(l);
f.setPixelsPerUnit(43.75);
new FlameWriter().writeFlame(f, "/dev/shm/PolylogarithmFunc.flame");
JobRenderThreadController controller = new HeadlessBatchRendererController();
List<Job> joblist = new ArrayList<>();
Job j = new Job();
j.setCustomHeight(side);
j.setCustomWidth(side);
j.setCustomQuality(quality);
j.setFlameFilename("/dev/shm/PolylogarithmFunc.flame");
joblist.add(j);
QualityProfile qualpro = new QualityProfile();
qualpro.setQuality(quality);
JobRenderThread job = new JobRenderThread(controller, joblist, respro, qualpro, true);
job.run();
}
Aggregations