Example #1
0
  public Flame createRenderFlame(Flame pSrc) {
    Flame res = pSrc.makeCopy();

    //    res.setBGTransparency(false);
    //    res.setGamma(1.5);
    //    res.setBrightness(3.36);
    //    res.getPalette().setModRed(90);
    //    res.getPalette().setModRed(60);
    //    res.getPalette().setModBlue(-60);
    //    res.setSampleDensity(2 * prefs.getTinaRenderRealtimeQuality());
    //    res.setSpatialFilterRadius(0.75);

    res.setBGTransparency(false);
    //    res.setGamma(res.getGamma() - 0.5);
    //    res.getPalette().setModSaturation(-24);
    //    res.setGamma(2.5);
    //    res.setBrightness(5.0);
    //    res.getPalette().setModRed(30);
    // res.getPalette().setModSaturation(-160);
    //    res.getPalette().setModRed(20);
    //    res.getPalette().setModBlue(-20);
    if (res.getSolidRenderSettings().isSolidRenderingEnabled()) {
      res.getSolidRenderSettings().setAoEnabled(false);
      res.getSolidRenderSettings().setShadowType(ShadowType.OFF);
      res.setCamDOF(0.0);
      res.setSampleDensity(prefs.getTinaRenderRealtimeQuality());
    } else {
      res.setSampleDensity(2 * prefs.getTinaRenderRealtimeQuality());
    }

    return res;
  }
 public void loadFlameButton_clicked() {
   try {
     JFileChooser chooser = new FlameFileChooser(prefs);
     if (prefs.getInputFlamePath() != null) {
       try {
         chooser.setCurrentDirectory(new File(prefs.getInputFlamePath()));
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     }
     chooser.setMultiSelectionEnabled(true);
     if (chooser.showOpenDialog(poolFlamePreviewPnl) == JFileChooser.APPROVE_OPTION) {
       for (File file : chooser.getSelectedFiles()) {
         List<Flame> newFlames = new FlameReader(prefs).readFlames(file.getAbsolutePath());
         prefs.setLastInputFlameFile(file);
         if (newFlames != null && newFlames.size() > 0) {
           for (Flame newFlame : newFlames) {
             project.getFlames().add(validateDancingFlame(newFlame));
           }
         }
       }
       refreshProjectFlames();
       enableControls();
     }
   } catch (Throwable ex) {
     errorHandler.handleError(ex);
   }
 }
 public void stopRender() throws Exception {
   if (renderThread != null) {
     if (doRecordCBx.isSelected()) {
       actionRecorder.recordStop();
     }
     renderThread.setForceAbort(true);
     if (doRecordCBx.isSelected()) {
       JFileChooser chooser = new FlameFileChooser(prefs);
       if (prefs.getOutputFlamePath() != null) {
         try {
           chooser.setCurrentDirectory(new File(prefs.getOutputFlamePath()));
         } catch (Exception ex) {
           ex.printStackTrace();
         }
       }
       if (chooser.showSaveDialog(flameRootPanel) == JFileChooser.APPROVE_OPTION) {
         File file = chooser.getSelectedFile();
         prefs.setLastOutputFlameFile(file);
         PostRecordFlameGenerator generator =
             new PostRecordFlameGenerator(
                 Prefs.getPrefs(), project, actionRecorder, renderThread, project.getFFT());
         generator.createRecordedFlameFiles(file.getAbsolutePath());
       }
     }
     renderThread = null;
     actionRecorder = null;
   }
 }
 public void dancingFlamesSaveProjectBtn_clicked() {
   try {
     JFileChooser chooser = new JWFDanceFileChooser(prefs);
     if (prefs.getOutputJWFMoviePath() != null) {
       try {
         chooser.setCurrentDirectory(new File(prefs.getOutputJWFMoviePath()));
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     }
     if (chooser.showSaveDialog(poolFlamePreviewPnl) == JFileChooser.APPROVE_OPTION) {
       File file = chooser.getSelectedFile();
       new JWFDanceWriter().writeProject(project, file.getAbsolutePath());
       prefs.setLastOutputJWFMovieFile(file);
     }
   } catch (Throwable ex) {
     errorHandler.handleError(ex);
   }
 }
 public void loadSoundButton_clicked() {
   try {
     JFileChooser chooser = new SoundFileChooser(prefs);
     if (prefs.getInputSoundFilePath() != null) {
       try {
         chooser.setCurrentDirectory(new File(prefs.getInputSoundFilePath()));
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     }
     if (chooser.showOpenDialog(flameRootPanel) == JFileChooser.APPROVE_OPTION) {
       File file = chooser.getSelectedFile();
       prefs.setLastInputSoundFile(file);
       project.setSoundFilename(jLayer, file.getAbsolutePath());
       enableControls();
     }
   } catch (Throwable ex) {
     errorHandler.handleError(ex);
   }
 }
 public void dancingFlamesLoadProjectBtn_clicked() {
   try {
     JFileChooser chooser = new JWFDanceFileChooser(prefs);
     if (prefs.getInputJWFMoviePath() != null) {
       try {
         chooser.setCurrentDirectory(new File(prefs.getInputJWFMoviePath()));
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     }
     if (chooser.showOpenDialog(poolFlamePreviewPnl) == JFileChooser.APPROVE_OPTION) {
       File file = chooser.getSelectedFile();
       project = new JWFDanceReader().readProject(file.getAbsolutePath());
       refreshProjectFlames();
       enableControls();
     }
   } catch (Throwable ex) {
     errorHandler.handleError(ex);
   }
 }
  protected void parseFlameAttributes(Flame pFlame, String pXML) {
    XMLAttributes atts = Tools.parseAttributes(pXML);
    String hs;
    if ((hs = atts.get(ATTR_NAME)) != null) {
      pFlame.setName(hs);
    }
    if ((hs = atts.get(ATTR_SIZE)) != null) {
      String s[] = hs.split(" ");
      pFlame.setWidth(Integer.parseInt(s[0]));
      pFlame.setHeight(Integer.parseInt(s[1]));
    }
    if ((hs = atts.get(ATTR_CENTER)) != null) {
      String s[] = hs.split(" ");
      pFlame.setCentreX(Double.parseDouble(s[0]));
      pFlame.setCentreY(Double.parseDouble(s[1]));
    }
    if ((hs = atts.get(ATTR_SCALE)) != null) {
      pFlame.setPixelsPerUnit(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_ROTATE)) != null) {
      //      pFlame.setCamRoll(-Double.parseDouble(hs) * 180.0 / Math.PI);
      pFlame.setCamRoll(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_FILTER)) != null) {
      pFlame.setSpatialFilterRadius(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_FILTER_KERNEL)) != null) {
      try {
        FilterKernelType kernel = FilterKernelType.valueOf(hs);
        pFlame.setSpatialFilterKernel(kernel);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    // Disable DE filter and check if it is set explicitely on. There are lots of Apo flames out
    // there
    // which are carrying DE settings, but they were never used and may look terrible (e. g. DE max
    // radius 9.0)
    pFlame.setDeFilterEnabled(false);
    if ((hs = atts.get(ATTR_DE_FILTER_ENABLED)) != null) {
      pFlame.setDeFilterEnabled(Integer.parseInt(hs) == 1);
    }
    if ((hs = atts.get(ATTR_DE_FILTER_MAX_RADIUS)) != null) {
      pFlame.setDeFilterMaxRadius(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_DE_FILTER_MIN_RADIUS)) != null) {
      pFlame.setDeFilterMinRadius(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_DE_FILTER_CURVE)) != null) {
      pFlame.setDeFilterCurve(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_DE_FILTER_KERNEL)) != null) {
      try {
        FilterKernelType kernel = FilterKernelType.valueOf(hs);
        pFlame.setDeFilterKernel(kernel);
      } catch (Exception ex) {
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_QUALITY)) != null) {
      pFlame.setSampleDensity(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_BACKGROUND)) != null) {
      String s[] = hs.split(" ");
      pFlame.setBGColorRed(Tools.roundColor(255.0 * Double.parseDouble(s[0])));
      pFlame.setBGColorGreen(Tools.roundColor(255.0 * Double.parseDouble(s[1])));
      pFlame.setBGColorBlue(Tools.roundColor(255.0 * Double.parseDouble(s[2])));
    }
    if ((hs = atts.get(ATTR_BRIGHTNESS)) != null) {
      pFlame.setBrightness(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_BG_TRANSPARENCY)) != null) {
      pFlame.setBGTransparency(Integer.parseInt(hs) == 1);
    } else {
      pFlame.setBGTransparency(prefs.isTinaDefaultBGTransparency());
    }
    if ((hs = atts.get(ATTR_GAMMA)) != null) {
      pFlame.setGamma(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_GAMMA_THRESHOLD)) != null) {
      pFlame.setGammaThreshold(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_VIBRANCY)) != null) {
      pFlame.setVibrancy(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CONTRAST)) != null) {
      pFlame.setContrast(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_PERSP)) != null) {
      pFlame.setCamPerspective(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_PERSPECTIVE)) != null) {
      pFlame.setCamPerspective(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_ZPOS)) != null) {
      pFlame.setCamZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_XFOCUS)) != null) {
      pFlame.setFocusX(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_YFOCUS)) != null) {
      pFlame.setFocusY(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_ZFOCUS)) != null) {
      pFlame.setFocusZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_ZDIMISH)) != null) {
      pFlame.setDimishZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF)) != null) {
      pFlame.setCamDOF(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF_AREA)) != null) {
      pFlame.setCamDOFArea(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_DOF_EXPONENT)) != null) {
      pFlame.setCamDOFExponent(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_CAM_PITCH)) != null) {
      pFlame.setCamPitch(Double.parseDouble(hs) * 180.0 / Math.PI);
    }
    if ((hs = atts.get(ATTR_CAM_YAW)) != null) {
      pFlame.setCamYaw(Double.parseDouble(hs) * 180.0 / Math.PI);
    }
    if ((hs = atts.get(ATTR_CAM_ZOOM)) != null) {
      pFlame.setCamZoom(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_NEW_DOF)) != null) {
      pFlame.setNewCamDOF("1".equals(hs));
    }
    // preserve-z
    if ((hs = atts.get(ATTR_PRESERVE_Z)) != null) {
      pFlame.setPreserveZ("1".equals(hs));
    }
    // profiles
    if ((hs = atts.get(ATTR_RESOLUTION_PROFILE)) != null) {
      pFlame.setResolutionProfile(hs);
    }
    if ((hs = atts.get(ATTR_QUALITY_PROFILE)) != null) {
      pFlame.setQualityProfile(hs);
    }
    // Shading
    if ((hs = atts.get(ATTR_SHADING_SHADING)) != null) {
      try {
        pFlame.getShadingInfo().setShading(Shading.valueOf(hs));
      } catch (Exception ex) {
        pFlame.getShadingInfo().setShading(Shading.FLAT);
        ex.printStackTrace();
      }
    }
    if ((hs = atts.get(ATTR_SHADING_AMBIENT)) != null) {
      pFlame.getShadingInfo().setAmbient(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DIFFUSE)) != null) {
      pFlame.getShadingInfo().setDiffuse(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_PHONG)) != null) {
      pFlame.getShadingInfo().setPhong(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_PHONGSIZE)) != null) {
      pFlame.getShadingInfo().setPhongSize(Double.parseDouble(hs));
    }
    int lightCount;
    if ((hs = atts.get(ATTR_SHADING_LIGHTCOUNT)) != null) {
      lightCount = Integer.parseInt(hs);
    } else {
      lightCount = 0;
    }
    for (int i = 0; i < lightCount; i++) {
      if ((hs = atts.get(ATTR_SHADING_LIGHTPOSX_ + i)) != null) {
        pFlame.getShadingInfo().setLightPosX(i, Double.parseDouble(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTPOSY_ + i)) != null) {
        pFlame.getShadingInfo().setLightPosY(i, Double.parseDouble(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTPOSZ_ + i)) != null) {
        pFlame.getShadingInfo().setLightPosZ(i, Double.parseDouble(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTRED_ + i)) != null) {
        pFlame.getShadingInfo().setLightRed(i, Integer.parseInt(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTGREEN_ + i)) != null) {
        pFlame.getShadingInfo().setLightGreen(i, Integer.parseInt(hs));
      }
      if ((hs = atts.get(ATTR_SHADING_LIGHTBLUE_ + i)) != null) {
        pFlame.getShadingInfo().setLightBlue(i, Integer.parseInt(hs));
      }
    }
    if ((hs = atts.get(ATTR_SHADING_BLUR_RADIUS)) != null) {
      pFlame.getShadingInfo().setBlurRadius(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_BLUR_FADE)) != null) {
      pFlame.getShadingInfo().setBlurFade(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_BLUR_FALLOFF)) != null) {
      pFlame.getShadingInfo().setBlurFallOff(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_NEW_LINEAR)) != null) {
      pFlame.setPreserveZ(hs.length() > 0 && Integer.parseInt(hs) == 1);
    }

    if ((hs = atts.get(ATTR_ANTIALIAS_AMOUNT)) != null) {
      pFlame.setAntialiasAmount(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_ANTIALIAS_RADIUS)) != null) {
      pFlame.setAntialiasRadius(Double.parseDouble(hs));
    }

    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_RADIUS)) != null) {
      pFlame.getShadingInfo().setDistanceColorRadius(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_SCALE)) != null) {
      pFlame.getShadingInfo().setDistanceColorScale(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_EXPONENT)) != null) {
      pFlame.getShadingInfo().setDistanceColorExponent(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_OFFSETX)) != null) {
      pFlame.getShadingInfo().setDistanceColorOffsetX(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_OFFSETY)) != null) {
      pFlame.getShadingInfo().setDistanceColorOffsetY(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_OFFSETZ)) != null) {
      pFlame.getShadingInfo().setDistanceColorOffsetZ(Double.parseDouble(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_STYLE)) != null) {
      pFlame.getShadingInfo().setDistanceColorStyle(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_COORDINATE)) != null) {
      pFlame.getShadingInfo().setDistanceColorCoordinate(Integer.parseInt(hs));
    }
    if ((hs = atts.get(ATTR_SHADING_DISTANCE_COLOR_SHIFT)) != null) {
      pFlame.getShadingInfo().setDistanceColorShift(Double.parseDouble(hs));
    }
  }
  public DancingFractalsController(
      TinaController pParent,
      ErrorHandler pErrorHandler,
      JTabbedPane pRootTabbedPane,
      JPanel pRealtimeFlamePnl,
      JPanel pRealtimeGraph1Pnl,
      JButton pLoadSoundBtn,
      JButton pAddFromClipboardBtn,
      JButton pAddFromEditorBtn,
      JButton pAddFromDiscBtn,
      JWFNumberField pRandomCountIEd,
      JButton pGenRandFlamesBtn,
      JComboBox pRandomGenCmb,
      JPanel pPoolFlamePreviewPnl,
      JSlider pBorderSizeSlider,
      JButton pFlameToEditorBtn,
      JButton pDeleteFlameBtn,
      JTextField pFramesPerSecondIEd,
      JTextField pMorphFrameCountIEd,
      JButton pStartShowButton,
      JButton pStopShowButton,
      JCheckBox pDoRecordCBx,
      JComboBox pFlamesCmb,
      JCheckBox pDrawTrianglesCbx,
      JCheckBox pDrawFFTCbx,
      JCheckBox pDrawFPSCbx,
      JTree pFlamePropertiesTree,
      JPanel pMotionPropertyRootPnl,
      JTable pMotionTable,
      JComboBox pAddMotionCmb,
      JButton pAddMotionBtn,
      JButton pDeleteMotionBtn,
      JButton pLinkMotionBtn,
      JButton pUnlinkMotionBtn,
      JComboBox pCreateMotionsCmb,
      JButton pClearMotionsBtn,
      JButton pLoadProjectBtn,
      JButton pSaveProjectBtn,
      JTable pMotionLinksTable,
      JButton pReplaceFlameFromEditorBtn,
      JButton pRenameFlameBtn,
      JButton pRenameMotionBtn,
      JCheckBox pMutedCbx) {
    flamePropertiesTreeService = new FlamePropertiesTreeService();

    rootTabbedPane = pRootTabbedPane;
    parentCtrl = pParent;
    errorHandler = pErrorHandler;
    prefs = Prefs.getPrefs();
    flameRootPanel = pRealtimeFlamePnl;
    graph1RootPanel = pRealtimeGraph1Pnl;
    loadSoundBtn = pLoadSoundBtn;
    addFromClipboardBtn = pAddFromClipboardBtn;
    addFromEditorBtn = pAddFromEditorBtn;
    addFromDiscBtn = pAddFromDiscBtn;
    randomCountIEd = pRandomCountIEd;
    genRandFlamesBtn = pGenRandFlamesBtn;
    randomGenCmb = pRandomGenCmb;
    poolFlamePreviewPnl = pPoolFlamePreviewPnl;
    borderSizeSlider = pBorderSizeSlider;
    flameToEditorBtn = pFlameToEditorBtn;
    deleteFlameBtn = pDeleteFlameBtn;
    framesPerSecondIEd = pFramesPerSecondIEd;
    morphFrameCountIEd = pMorphFrameCountIEd;
    startShowButton = pStartShowButton;
    stopShowButton = pStopShowButton;
    doRecordCBx = pDoRecordCBx;
    flamesCmb = pFlamesCmb;
    drawTrianglesCbx = pDrawTrianglesCbx;
    drawFFTCbx = pDrawFFTCbx;
    drawFPSCbx = pDrawFPSCbx;
    motionPropertyRootPnl = pMotionPropertyRootPnl;
    motionTable = pMotionTable;
    addMotionCmb = pAddMotionCmb;
    addMotionBtn = pAddMotionBtn;
    deleteMotionBtn = pDeleteMotionBtn;
    renameMotionBtn = pRenameMotionBtn;
    linkMotionBtn = pLinkMotionBtn;
    unlinkMotionBtn = pUnlinkMotionBtn;
    createMotionsCmb = pCreateMotionsCmb;
    clearMotionsBtn = pClearMotionsBtn;
    loadProjectBtn = pLoadProjectBtn;
    saveProjectBtn = pSaveProjectBtn;
    motionLinksTable = pMotionLinksTable;
    replaceFlameFromEditorBtn = pReplaceFlameFromEditorBtn;
    renameFlameBtn = pRenameFlameBtn;
    mutedCbx = pMutedCbx;

    addMotionCmb.addItem(MotionType.FFT);
    addMotionCmb.addItem(MotionType.SAWTOOTH);
    addMotionCmb.addItem(MotionType.SINE);
    addMotionCmb.addItem(MotionType.SPLINE);
    addMotionCmb.setSelectedItem(MotionType.FFT);
    createMotionsCmb.addItem(MotionCreatorType.DEFAULT);
    createMotionsCmb.setSelectedItem(MotionCreatorType.DEFAULT);

    flamePropertiesTree = pFlamePropertiesTree;
    poolFlameHolder = new PoolFlameHolder();

    refreshProjectFlames();

    enableControls();
  }