Search in sources :

Example 21 with MotionCurve

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());
    }
}
Also used : MotionCurve(org.jwildfire.create.tina.base.motion.MotionCurve)

Example 22 with MotionCurve

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);
    }
}
Also used : Field(java.lang.reflect.Field) MotionCurve(org.jwildfire.create.tina.base.motion.MotionCurve)

Example 23 with MotionCurve

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);
    }
}
Also used : Field(java.lang.reflect.Field) MotionCurve(org.jwildfire.create.tina.base.motion.MotionCurve) ArrayList(java.util.ArrayList)

Example 24 with MotionCurve

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);
    }
}
Also used : MotionCurve(org.jwildfire.create.tina.base.motion.MotionCurve) Envelope(org.jwildfire.envelope.Envelope) Flame(org.jwildfire.create.tina.base.Flame)

Example 25 with MotionCurve

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);
    }
}
Also used : MotionCurve(org.jwildfire.create.tina.base.motion.MotionCurve)

Aggregations

MotionCurve (org.jwildfire.create.tina.base.motion.MotionCurve)26 Field (java.lang.reflect.Field)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 Variation (org.jwildfire.create.tina.variation.Variation)5 VariationFunc (org.jwildfire.create.tina.variation.VariationFunc)4 MotionCurveAttribute (org.jwildfire.create.tina.animate.AnimationService.MotionCurveAttribute)3 Flame (org.jwildfire.create.tina.base.Flame)3 Envelope (org.jwildfire.envelope.Envelope)3 Map (java.util.Map)2 XMLAttributes (org.jwildfire.base.Tools.XMLAttributes)2 RGBPalette (org.jwildfire.create.tina.palette.RGBPalette)2 VariationFuncList (org.jwildfire.create.tina.variation.VariationFuncList)2 HashMap (java.util.HashMap)1 ImageIcon (javax.swing.ImageIcon)1 XMLAttribute (org.jwildfire.base.Tools.XMLAttribute)1 XForm (org.jwildfire.create.tina.base.XForm)1 DistantLight (org.jwildfire.create.tina.base.solidrender.DistantLight)1 MaterialSettings (org.jwildfire.create.tina.base.solidrender.MaterialSettings)1 SolidRenderSettings (org.jwildfire.create.tina.base.solidrender.SolidRenderSettings)1