use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class Variation method createMotionCurve.
public MotionCurve createMotionCurve(String pName) {
if (getMotionCurve(pName) != null) {
throw new RuntimeException("Motion curve <" + pName + "> already exists");
}
MotionCurve curve = new MotionCurve();
motionCurves.put(pName, curve);
return curve;
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class Variation method assign.
@Override
public void assign(Variation var) {
amount = var.amount;
amountCurve.assign(var.amountCurve);
// motionCurves
motionCurves.clear();
for (String name : var.motionCurves.keySet()) {
MotionCurve copy = new MotionCurve();
copy.assign(var.motionCurves.get(name));
motionCurves.put(name, copy);
}
// variation function
func = var.func.makeCopy();
priority = var.priority;
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class Variation method getClonedMotionCurves.
public Map<String, MotionCurve> getClonedMotionCurves() {
Map<String, MotionCurve> res = new HashMap<String, MotionCurve>();
for (Entry<String, MotionCurve> curveToCopy : motionCurves.entrySet()) {
MotionCurve copy = new MotionCurve();
copy.assign(curveToCopy.getValue());
res.put(curveToCopy.getKey(), copy);
}
return res;
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class AnimationService method evalCurve.
public static double evalCurve(double pFrame, MotionCurve curve) {
MotionCurve currCurve = curve;
double value = 0.0;
while (currCurve != null) {
Envelope envelope = currCurve.toEnvelope();
value += envelope.evaluate(pFrame);
currCurve = currCurve.getParent();
}
return value;
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class AnimationService method _disableMotionCurves.
private static void _disableMotionCurves(Object pObject) throws IllegalAccessException {
Class<?> cls = pObject.getClass();
for (Field field : cls.getDeclaredFields()) {
field.setAccessible(true);
if (field.getType() == MotionCurve.class && field.getName().endsWith(Tools.CURVE_POSTFIX)) {
MotionCurve curve = (MotionCurve) field.get(pObject);
if (curve.isEnabled()) {
curve.setEnabled(false);
}
} else if (field.getType().isAssignableFrom(ArrayList.class)) {
List<?> childs = (List<?>) field.get(pObject);
for (Object child : childs) {
_disableMotionCurves(child);
}
} else if (field.getType().isAssignableFrom(RGBPalette.class)) {
RGBPalette gradient = (RGBPalette) field.get(pObject);
_disableMotionCurves(gradient);
}
}
if (pObject instanceof Variation) {
Variation var = (Variation) pObject;
VariationFunc func = var.getFunc();
for (String name : func.getParameterNames()) {
MotionCurve curve = var.getMotionCurve(name);
if (curve != null && curve.isEnabled()) {
curve.setEnabled(false);
}
}
}
}
Aggregations