Brad Stefanov
Horn variation with 8 variables. This does not work with GPU since I am not sure how to do it (if someone wants to do it feel free).
package org.jwildfire.create.tina.variation; import org.jwildfire.create.tina.base.XForm; import org.jwildfire.create.tina.base.XYZPoint; import org.jwildfire.create.tina.variation.FlameTransformationContext; import static org.jwildfire.base.mathlib.MathLib.*; public class HornFunc extends VariationFunc implements SupportsGPU { private static final long serialVersionUID = 1L; private static final String PARAM_A = "param_a"; private static final String PARAM_B = "param_b"; private static final String PARAM_C = "param_c"; private static final String PARAM_D = "param_d"; private static final String PARAM_E = "param_e"; private static final String PARAM_F = "param_f"; private static final String PARAM_G = "param_g"; private static final String PARAM_H = "param_h"; private static final String[] paramNames = {PARAM_A, PARAM_B, PARAM_C, PARAM_D, PARAM_E, PARAM_F, PARAM_G, PARAM_H}; private double param_a = 1.0; private double param_b = 1.0; private double param_c = 1.0; private double param_d = 1.0; private double param_e = M_2PI; private double param_f = 0.0; private double param_g = 0.0; private double param_h = 0.0; public void transform(FlameTransformationContext pContext, XForm pXForm, XYZPoint pAffineTP, XYZPoint pVarTP, double pAmount) { final double rad = sqrt(pContext.random()+param_f); double a = pContext.random() * param_e; double s = sin(a); double c = cos(a); pVarTP.y+= pAmount * c *rad* param_a; pVarTP.z += pAmount * s*param_b ; pVarTP.x += pAmount * rad*param_c+param_g; pVarTP.z += pAmount / rad*param_d+param_h; } @Override public String[] getParameterNames() { return paramNames; } @Override public Object[] getParameterValues() { return new Object[]{param_a, param_b, param_c, param_d, param_e, param_f, param_g, param_h}; } @Override public void setParameter(String pName, double pValue) { if (PARAM_A.equalsIgnoreCase(pName)) { param_a = pValue; } else if (PARAM_B.equalsIgnoreCase(pName)) { param_b = pValue; } else if (PARAM_C.equalsIgnoreCase(pName)) { param_c = pValue; } else if (PARAM_D.equalsIgnoreCase(pName)) { param_d = pValue; } else if (PARAM_E.equalsIgnoreCase(pName)) { param_e = pValue; } else if (PARAM_F.equalsIgnoreCase(pName)) { param_f = pValue; } else if (PARAM_G.equalsIgnoreCase(pName)) { param_g = pValue; } else if (PARAM_H.equalsIgnoreCase(pName)) { param_h = pValue; } else { System.out.println("pName not recognized: " + pName); throw new IllegalArgumentException(pName); } } public String getName() { return "horn"; } /* public String getGPUCode(FlameTransformationContext context) { // 1. don't use comments INSIDE the code // 2. use individual names for custom variations by changing the constant inside getName()-function // 3. use this name to specify the amount-parameter in the form __[name] // 4. pAffine.x, pAffine.y, pAffine.z are __x, __y, __z // 5. pVar.x, pVar.y, pVar.z are __px, __py, __pz // 6. color-index for dc_-variation is __pal // 7. mathematical functions are postfixed with f, e.g. use sinf, cosf, logf, ... instead of sin, cos, log, ... // 8. a random number may be generated by using RANDFLOAT() // 9. you can NOT use global variables // 10. see the numerious existing variations for inspiration return "__px += __linear3D_dynamic * __x;\n" + "__py += __linear3D_dynamic * __y;\n" + (context.isPreserveZCoordinate() ? "__pz += __linear3D_dynamic * __z;" : ""); } */ }