Package org.jwildfire.create.tina.base.motion

Examples of org.jwildfire.create.tina.base.motion.MotionCurve


    return res;
  }

  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(false);
      refreshCurve(flame);
    }
  }
View Full Code Here


    if (owner.isUseUndoManager()) {
      owner.getOwner().undoManager.saveUndoPoint(flame);
    }

    MotionCurve curve = getCurve(flame);
    curve.assignFromEnvelope(ctrl.getCurrEnvelope());

    owner.getOwner().refreshFlameImage(false);
  }
View Full Code Here

                }
                // curve
                {
                  String namePrefix = rawName + "_" + pName + "_";
                  if (atts.get(namePrefix + AbstractFlameReader.CURVE_ATTR_POINT_COUNT) != null) {
                    MotionCurve curve = variation.getMotionCurve(pName);
                    if (curve == null) {
                      curve = variation.createMotionCurve(pName);
                    }
                    readMotionCurveAttributes(atts, curve, namePrefix);
                  }
View Full Code Here

    }
  }

  protected void readMotionCurves(Object source, XMLAttributes atts, String pNamePrefix) {
    for (MotionCurveAttribute attribute : AnimationService.getAllMotionCurves(source)) {
      MotionCurve curve = attribute.getMotionCurve();
      String namePrefix = pNamePrefix == null ? attribute.getName() + "_" : pNamePrefix + attribute.getName() + "_";
      readMotionCurveAttributes(atts, curve, namePrefix);
    }
  }
View Full Code Here

      }
      curve.setPoints(x, y);
    }
    if ((hs = atts.get(namePrefix + AbstractFlameReader.CURVE_ATTR_PARENT_CURVE)) != null) {
      String parentNamePrefix = hs + "_";
      MotionCurve parent = new MotionCurve();
      curve.setParent(parent);
      readMotionCurveAttributes(atts, parent, parentNamePrefix);
    }
  }
View Full Code Here

  private static void _evalMotionCurves(Object pObject, double pFrame) 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()) {
          double value = evalCurve(pFrame, curve);
          String propName = field.getName().substring(0, field.getName().length() - Tools.CURVE_POSTFIX.length());
          curve.getChangeHandler().processValueChange(pObject, propName, value);
          if (pObject instanceof RGBPalette) {
            curve.getChangeHandler().processValueChange(pObject, "modified", 1.0);
          }
          //setPropertyValue(pObject, propName, value);
          //          System.out.println(propName + " " + value);
        }
      }
      else if (field.getType().isAssignableFrom(ArrayList.class)) {
        List<?> childs = (List<?>) field.get(pObject);
        for (Object child : childs) {
          _evalMotionCurves(child, pFrame);
        }
      }
      else if (field.getType().isAssignableFrom(RGBPalette.class)) {
        RGBPalette gradient = (RGBPalette) field.get(pObject);
        _evalMotionCurves(gradient, pFrame);
      }
    }
    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()) {
          double value = evalCurve(pFrame, curve);
          try {
            func.setParameter(name, value);
          }
          catch (Exception ex) {
View Full Code Here

  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);
        }
      }
    }
  }
View Full Code Here

      }
    }
  }

  private 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;
  }
View Full Code Here

  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) {
View Full Code Here

  }

  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;
View Full Code Here

TOP

Related Classes of org.jwildfire.create.tina.base.motion.MotionCurve

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.