Ejemplo n.º 1
0
 private static void morphFlameValues(Flame pFlame1, Flame pFlame2, double fScl, Flame res) {
   res.setCamDOF(morphValue(pFlame1.getCamDOF(), pFlame2.getCamDOF(), fScl));
   res.setCamPerspective(
       morphValue(pFlame1.getCamPerspective(), pFlame2.getCamPerspective(), fScl));
   res.setCamPitch(morphValue(pFlame1.getCamPitch(), pFlame2.getCamPitch(), fScl));
   res.setCamYaw(morphValue(pFlame1.getCamYaw(), pFlame2.getCamYaw(), fScl));
   res.setCamRoll(morphValue(pFlame1.getCamRoll(), pFlame2.getCamRoll(), fScl));
   res.setFocusZ(morphValue(pFlame1.getFocusZ(), pFlame2.getFocusZ(), fScl));
   res.setCamZoom(morphValue(pFlame1.getCamZoom(), pFlame2.getCamZoom(), fScl));
   res.setBGColorRed(morphColorValue(pFlame1.getBGColorRed(), pFlame2.getBGColorRed(), fScl));
   res.setBGColorGreen(
       morphColorValue(pFlame1.getBGColorGreen(), pFlame2.getBGColorGreen(), fScl));
   res.setBGColorBlue(morphColorValue(pFlame1.getBGColorBlue(), pFlame2.getBGColorBlue(), fScl));
   res.setBrightness(morphValue(pFlame1.getBrightness(), pFlame2.getBrightness(), fScl));
   res.setCentreX(morphValue(pFlame1.getCentreX(), pFlame2.getCentreX(), fScl));
   res.setCentreY(morphValue(pFlame1.getCentreY(), pFlame2.getCentreY(), fScl));
   res.setContrast(morphValue(pFlame1.getContrast(), pFlame2.getContrast(), fScl));
   res.setGamma(morphValue(pFlame1.getGamma(), pFlame2.getGamma(), fScl));
   res.setGammaThreshold(
       morphValue(pFlame1.getGammaThreshold(), pFlame2.getGammaThreshold(), fScl));
   res.setPixelsPerUnit(morphValue(pFlame1.getPixelsPerUnit(), pFlame2.getPixelsPerUnit(), fScl));
   res.setWidth(morphValue(pFlame1.getWidth(), pFlame2.getWidth(), fScl));
   res.setHeight(morphValue(pFlame1.getHeight(), pFlame2.getHeight(), fScl));
   res.setPreserveZ(morphValue(pFlame1.isPreserveZ(), pFlame2.isPreserveZ(), fScl));
   res.setSpatialFilterRadius(
       morphValue(pFlame1.getSpatialFilterRadius(), pFlame2.getSpatialFilterRadius(), fScl));
   res.setVibrancy(morphValue(pFlame1.getVibrancy(), pFlame2.getVibrancy(), fScl));
   res.setWhiteLevel(morphValue(pFlame1.getWhiteLevel(), pFlame2.getWhiteLevel(), fScl));
 }
 public void refreshPoolPreviewFlameImage(Flame flame) {
   FlamePanel imgPanel = getPoolPreviewFlamePanel();
   if (imgPanel == null) return;
   Rectangle bounds = imgPanel.getImageBounds();
   int width = bounds.width;
   int height = bounds.height;
   if (width >= 16 && height >= 16) {
     RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
     if (flame != null) {
       imgPanel.setDrawTriangles(false);
       double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
       double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
       flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
       flame.setWidth(info.getImageWidth());
       flame.setHeight(info.getImageHeight());
       Flame renderFlame = new FlamePreparer(prefs).createRenderFlame(flame);
       FlameRenderer renderer = new FlameRenderer(renderFlame, prefs, false, false);
       renderer.setProgressUpdater(null);
       RenderedFlame res = renderer.renderFlame(info);
       imgPanel.setImage(res.getImage());
     } else {
       imgPanel.setImage(new SimpleImage(width, height));
     }
   } else {
     imgPanel.setImage(new SimpleImage(width, height));
   }
   poolFlamePreviewPnl.repaint();
 }
  public void refreshFlameImage(
      Flame flame, boolean pDrawTriangles, double pFPS, long pFrame, boolean pDrawFPS) {
    FlamePanel imgPanel = getFlamePanel();
    if (imgPanel == null) return;
    Rectangle bounds = imgPanel.getImageBounds();
    int width = bounds.width;
    int height = bounds.height;
    if (width >= 16 && height >= 16) {
      RenderInfo info = new RenderInfo(width, height, RenderMode.PREVIEW);
      if (flame != null) {
        double oldSpatialFilterRadius = flame.getSpatialFilterRadius();
        double oldSampleDensity = flame.getSampleDensity();
        imgPanel.setDrawTriangles(pDrawTriangles);
        try {
          double wScl = (double) info.getImageWidth() / (double) flame.getWidth();
          double hScl = (double) info.getImageHeight() / (double) flame.getHeight();
          flame.setPixelsPerUnit((wScl + hScl) * 0.5 * flame.getPixelsPerUnit());
          flame.setWidth(info.getImageWidth());
          flame.setHeight(info.getImageHeight());

          Flame renderFlame = new FlamePreparer(prefs).createRenderFlame(flame);
          FlameRenderer renderer = new FlameRenderer(renderFlame, prefs, false, false);
          renderer.setProgressUpdater(null);
          RenderedFlame res = renderer.renderFlame(info);
          SimpleImage img = res.getImage();
          if (pDrawFPS) {
            TextTransformer txt = new TextTransformer();
            txt.setText1(
                "fps: "
                    + Tools.doubleToString(pFPS)
                    + ", time: "
                    + Tools.doubleToString(pFrame / 1000.0)
                    + "s");
            txt.setAntialiasing(false);
            txt.setColor(Color.LIGHT_GRAY);
            txt.setMode(Mode.NORMAL);
            txt.setFontStyle(FontStyle.PLAIN);
            txt.setFontName("Arial");
            txt.setFontSize(10);
            txt.setHAlign(HAlignment.LEFT);
            txt.setVAlign(VAlignment.BOTTOM);
            txt.transformImage(img);
          }
          imgPanel.setImage(img);
        } finally {
          flame.setSpatialFilterRadius(oldSpatialFilterRadius);
          flame.setSampleDensity(oldSampleDensity);
        }
      }
    } else {
      try {
        imgPanel.setImage(new SimpleImage(width, height));
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    flameRootPanel.repaint();
  }