use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class ParPlot2DWFFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
if (evaluator == null) {
return;
}
double randU, randV;
if (solid == 0) {
randU = pAffineTP.x;
randV = pAffineTP.y;
} else {
randU = pContext.random();
randV = pContext.random();
}
double u = _umin + randU * _du;
double v = _vmin + randV * _dv;
double x = evaluator.evaluateX(u, v);
double y = evaluator.evaluateY(u, v);
double z = evaluator.evaluateZ(u, v);
if (displacementMapHolder.isActive()) {
double epsu = _du / 100.0;
double u1 = u + epsu;
double x1 = evaluator.evaluateX(u1, v);
double y1 = evaluator.evaluateY(u1, v);
double z1 = evaluator.evaluateZ(u1, v);
double epsv = _dv / 100.0;
double v1 = v + epsv;
double x2 = evaluator.evaluateX(u, v1);
double y2 = evaluator.evaluateY(u, v1);
double z2 = evaluator.evaluateZ(u, v1);
VectorD av = new VectorD(x1 - x, y1 - y, z1 - z);
VectorD bv = new VectorD(x2 - x, y2 - y, z2 - z);
VectorD n = VectorD.cross(av, bv);
n.normalize();
double iu = GfxMathLib.clamp(randU * (displacementMapHolder.getDisplacementMapWidth() - 1.0), 0.0, displacementMapHolder.getDisplacementMapWidth() - 1.0);
double iv = GfxMathLib.clamp(displacementMapHolder.getDisplacementMapHeight() - 1.0 - randV * (displacementMapHolder.getDisplacementMapHeight() - 1.0), 0, displacementMapHolder.getDisplacementMapHeight() - 1.0);
int ix = (int) trunc(iu);
int iy = (int) trunc(iv);
double d = displacementMapHolder.calculateImageDisplacement(ix, iy, iu, iv) * _displ_amount;
pVarTP.x += pAmount * n.x * d;
pVarTP.y += pAmount * n.y * d;
pVarTP.z += pAmount * n.z * d;
}
if (direct_color > 0) {
switch(color_mode) {
case CM_V:
pVarTP.color = (v - _vmin) / _dv;
break;
case CM_U:
pVarTP.color = (u - _umin) / _du;
break;
case CM_COLORMAP:
if (colorMapHolder.isActive()) {
double iu = GfxMathLib.clamp(randU * (colorMapHolder.getColorMapWidth() - 1.0), 0.0, colorMapHolder.getColorMapWidth() - 1.0);
double iv = GfxMathLib.clamp(colorMapHolder.getColorMapHeight() - 1.0 - randV * (colorMapHolder.getColorMapHeight() - 1.0), 0, colorMapHolder.getColorMapHeight() - 1.0);
int ix = (int) MathLib.trunc(iu);
int iy = (int) MathLib.trunc(iv);
colorMapHolder.applyImageColor(pVarTP, ix, iy, iu, iv);
pVarTP.color = getUVColorIdx(Tools.FTOI(pVarTP.redColor), Tools.FTOI(pVarTP.greenColor), Tools.FTOI(pVarTP.blueColor));
}
break;
default:
case CM_UV:
pVarTP.color = (v - _vmin) / _dv * (u - _umin) / _du;
break;
}
if (pVarTP.color < 0.0)
pVarTP.color = 0.0;
else if (pVarTP.color > 1.0)
pVarTP.color = 1.0;
}
pVarTP.x += pAmount * x;
pVarTP.y += pAmount * y;
pVarTP.z += pAmount * z;
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class YPlot2DWFFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
if (evaluator == null) {
return;
}
double randU = pContext.random();
double randV = pContext.random();
double x = _xmin + randU * _dx;
double z = _zmin + randV * _dz;
double y = evaluator.evaluate(x);
if (displacementMapHolder.isActive()) {
double eps = _dx / 100.0;
double x1 = x + eps;
double y1 = evaluator.evaluate(x1);
VectorD av = new VectorD(eps, y1 - y, 0);
VectorD bv = new VectorD(0.0, 0.0, 1.0);
VectorD n = VectorD.cross(av, bv);
n.normalize();
double iu = GfxMathLib.clamp(randU * (displacementMapHolder.getDisplacementMapWidth() - 1.0), 0.0, displacementMapHolder.getDisplacementMapWidth() - 1.0);
double iv = GfxMathLib.clamp(displacementMapHolder.getDisplacementMapHeight() - 1.0 - randV * (displacementMapHolder.getDisplacementMapHeight() - 1.0), 0, displacementMapHolder.getDisplacementMapHeight() - 1.0);
int ix = (int) MathLib.trunc(iu);
int iy = (int) MathLib.trunc(iv);
double d = displacementMapHolder.calculateImageDisplacement(ix, iy, iu, iv) * _displ_amount;
pVarTP.x += pAmount * n.x * d;
pVarTP.y += pAmount * n.y * d;
pVarTP.z += pAmount * n.z * d;
}
if (direct_color > 0) {
switch(color_mode) {
case CM_COLORMAP:
if (colorMapHolder.isActive()) {
double iu = GfxMathLib.clamp(randU * (colorMapHolder.getColorMapWidth() - 1.0), 0.0, colorMapHolder.getColorMapWidth() - 1.0);
double iv = GfxMathLib.clamp(colorMapHolder.getColorMapHeight() - 1.0 - randV * (colorMapHolder.getColorMapHeight() - 1.0), 0, colorMapHolder.getColorMapHeight() - 1.0);
int ix = (int) MathLib.trunc(iu);
int iy = (int) MathLib.trunc(iv);
colorMapHolder.applyImageColor(pVarTP, ix, iy, iu, iv);
pVarTP.color = getUVColorIdx(Tools.FTOI(pVarTP.redColor), Tools.FTOI(pVarTP.greenColor), Tools.FTOI(pVarTP.blueColor));
}
break;
case CM_Y:
pVarTP.color = (y - _ymin) / _dy;
break;
default:
case CM_X:
pVarTP.color = (x - _xmin) / _dx;
break;
}
if (pVarTP.color < 0.0)
pVarTP.color = 0.0;
else if (pVarTP.color > 1.0)
pVarTP.color = 1.0;
}
pVarTP.x += pAmount * x;
pVarTP.y += pAmount * y;
pVarTP.z += pAmount * z;
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class WedgeJuliaFunc method transform.
@Override
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
double wedgeJulia_cf = 1.0 - angle * count * M_1_PI * 0.5;
double wedgeJulia_rN = fabs(power);
double wedgeJulia_cn = dist / power / 2.0;
/* wedge_julia from apo plugin pack */
double r = pAmount * pow(pAffineTP.getPrecalcSumsq(), wedgeJulia_cn);
int t_rnd = (int) ((wedgeJulia_rN) * pContext.random());
double a = (pAffineTP.getPrecalcAtanYX() + 2.0 * M_PI * t_rnd) / power;
double c = floor((count * a + M_PI) * M_1_PI * 0.5);
a = a * wedgeJulia_cf + c * angle;
double sa = sin(a);
double ca = cos(sa);
pVarTP.x += r * ca;
pVarTP.y += r * sa;
if (pContext.isPreserveZCoordinate()) {
pVarTP.z += pAmount * pAffineTP.z;
}
}
use of org.jwildfire.create.tina.base.XYZPoint in project JWildfire by thargor6.
the class WoggleFunc method transform.
public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) {
// Woggle Reference:
// http://paulbourke.net/fractals/woggle/roger14.c
double x, y;
double r = MathLib.sqrt(1.25) * MathLib.sqrt((double) m);
int c = (int) ((double) m * pContext.random());
double ra = 1.0 / (MathLib.sqrt(3.0) * MathLib.sqrt(pAffineTP.x * pAffineTP.x + pAffineTP.y * pAffineTP.y));
if (c % 2 == 0) {
x = -pAffineTP.x / r + ra * pAffineTP.y / r + a[c];
y = -ra * pAffineTP.x / r - pAffineTP.y / r + b[c];
} else {
x = pAffineTP.x / r + ra * pAffineTP.y / r + a[c];
y = -ra * pAffineTP.x / r + pAffineTP.y / r + b[c];
}
pVarTP.x += x * pAmount;
pVarTP.y += y * pAmount;
if (pContext.isPreserveZCoordinate()) {
pVarTP.z += pAmount * pAffineTP.z;
}
}
use of org.jwildfire.create.tina.base.XYZPoint 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);
}
Aggregations