use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class AnimationService method addMotionCurve.
public static void addMotionCurve(Flame pFlame, GlobalScript pScript, int pFrame, int pFrameCount, double pFPS) {
if (pScript != null && pScript.getScriptType() != null && !GlobalScriptType.NONE.equals(pScript.getScriptType()) && fabs(pScript.getAmplitude()) > EPSILON) {
EnvelopePoints points;
MotionCurve curve = null;
switch(pScript.getScriptType()) {
case ROTATE_PITCH:
curve = pFlame.getCamPitchCurve();
points = new EnvelopePoints(pScript, pFrameCount, pFPS, EnvelopePointsShape.RAMP, 360.0);
break;
case ROTATE_ROLL:
curve = pFlame.getCamRollCurve();
points = new EnvelopePoints(pScript, pFrameCount, pFPS, EnvelopePointsShape.RAMP, 360.0);
break;
case ROTATE_YAW:
curve = pFlame.getCamYawCurve();
points = new EnvelopePoints(pScript, pFrameCount, pFPS, EnvelopePointsShape.RAMP, 360.0);
break;
case MOVE_CAM_X:
curve = pFlame.getCamPosXCurve();
points = new EnvelopePoints(pScript, pFrameCount, pFPS, EnvelopePointsShape.SINE, 1.0);
break;
case MOVE_CAM_Y:
curve = pFlame.getCamPosYCurve();
points = new EnvelopePoints(pScript, pFrameCount, pFPS, EnvelopePointsShape.SINE, 1.0);
break;
case MOVE_CAM_Z:
curve = pFlame.getCamPosZCurve();
points = new EnvelopePoints(pScript, pFrameCount, pFPS, EnvelopePointsShape.SINE, 1.0);
break;
default:
throw new IllegalArgumentException(pScript.toString());
}
addEnvelope(pFrameCount, curve, points.getEnvX(), points.getEnvY());
}
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class AnimationService method getPropertyCurve.
public static <T> MotionCurve getPropertyCurve(T pSource, String pName) {
@SuppressWarnings("unchecked") Class<T> cls = (Class<T>) pSource.getClass();
Field field;
try {
field = cls.getDeclaredField(pName + Tools.CURVE_POSTFIX);
field.setAccessible(true);
Class<?> fieldCls = field.getType();
if (fieldCls == MotionCurve.class) {
return (MotionCurve) field.get(pSource);
} else {
throw new IllegalStateException(fieldCls.getName());
}
} catch (Throwable ex) {
throw new RuntimeException(ex);
}
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class AnimationService method getAllMotionCurves.
public static List<MotionCurveAttribute> getAllMotionCurves(Object pObject) {
try {
List<MotionCurveAttribute> res = new ArrayList<MotionCurveAttribute>();
for (Field field : getMotionCurveProperties(pObject)) {
MotionCurve curve = (MotionCurve) field.get(pObject);
res.add(new MotionCurveAttribute(field.getName(), curve));
}
return res;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class ChannelMixerPanelDelegate method editCurve.
protected void editCurve(ActionEvent e) {
Flame flame = owner.getOwner().getCurrFlame();
MotionCurve curve = getCurve(flame);
Envelope envelope = curve.toEnvelope();
EnvelopeDialog dlg = new EnvelopeDialog(SwingUtilities.getWindowAncestor(rootPanel), owner.getErrorHandler(), envelope, false);
dlg.setFlameToPreview(EnvelopeDialogFlamePreviewType.COLOR_CURVE, flame, curve);
dlg.setTitle("Editing motion curve");
dlg.setModal(true);
dlg.setVisible(true);
if (dlg.isConfirmed()) {
if (owner.isUseUndoManager()) {
owner.getOwner().undoManager.saveUndoPoint(flame);
}
curve.assignFromEnvelope(envelope);
owner.getOwner().refreshFlameImage(true, false, 1, true, true);
refreshCurve(flame);
}
}
use of org.jwildfire.create.tina.base.motion.MotionCurve in project JWildfire by thargor6.
the class AbstractControlsDelegate method enableControl.
public void enableControl(JWFNumberField pSender, String pPropertyName, boolean pDisabled) {
boolean controlEnabled = false;
boolean curveBtnEnabled = false;
boolean spinnerEnabled = false;
boolean hasCurve = false;
if (!pDisabled && isEnabled()) {
controlEnabled = true;
if (pPropertyName != null && pPropertyName.length() > 0) {
MotionCurve curve = getCurveToEdit(pPropertyName);
curveBtnEnabled = true;
spinnerEnabled = !curve.isEnabled();
hasCurve = curve.isEnabled();
} else {
curveBtnEnabled = false;
spinnerEnabled = true;
}
}
pSender.setEnabled(controlEnabled);
pSender.enableMotionCurveBtn(controlEnabled && curveBtnEnabled);
pSender.enableSpinnerField(controlEnabled && spinnerEnabled);
setupStyle(pSender, hasCurve);
if (pSender.getLinkedMotionControl() != null) {
pSender.getLinkedMotionControl().setEnabled(controlEnabled && spinnerEnabled);
}
}
Aggregations