use of org.jwildfire.create.tina.meshgen.render.RenderPointCloudThread in project JWildfire by thargor6.
the class MeshGenController method generateButton_clicked.
public void generateButton_clicked() {
if (renderSlicesThread != null) {
renderSlicesThread.setForceAbort();
while (renderSlicesThread.isFinished()) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
renderSlicesThread = null;
enableControls();
} else if (currBaseFlame != null) {
try {
JFileChooser chooser;
if (isPointCloudMode()) {
chooser = new PointCloudOutputFileChooser(Tools.FILEEXT_PLY);
if (prefs.getTinaMeshPath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getTinaMeshPath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
} else {
chooser = new ImageFileChooser(Tools.FILEEXT_PNG);
if (prefs.getOutputImagePath() != null) {
try {
chooser.setCurrentDirectory(new File(prefs.getOutputImagePath()));
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
if (chooser.showSaveDialog(rootPanel) == JFileChooser.APPROVE_OPTION) {
final File file = chooser.getSelectedFile();
prefs.setLastOutputImageFile(file);
MeshGenGenerateThreadFinishEvent finishEvent = new MeshGenGenerateThreadFinishEvent() {
@Override
public void succeeded(double pElapsedTime) {
try {
tinaController.getMessageHelper().showStatusMessage(currBaseFlame, "render time: " + Tools.doubleToString(pElapsedTime) + "s");
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
renderSlicesThread = null;
enableControls();
}
@Override
public void failed(Throwable exception) {
errorHandler.handleError(exception);
renderSlicesThread = null;
enableControls();
}
};
Flame flame = currBaseFlame.makeCopy();
switch(getOutputType()) {
case VOXELSTACK:
{
String outfilenamePattern = SequenceFilenameGen.createFilenamePattern(file);
Flame grayFlame = flame.makeCopy();
RGBPalette gradient = new RGBPalette();
for (int i = 0; i < RGBPalette.PALETTE_SIZE; i++) {
gradient.setColor(i, 225, 225, 225);
}
grayFlame.getFirstLayer().setPalette(gradient);
renderSlicesThread = new RenderSlicesThread(prefs, grayFlame, outfilenamePattern, finishEvent, renderSequenceProgressUpdater, renderWidthREd.getIntValue(), renderHeightREd.getIntValue(), sliceCountREd.getIntValue(), slicesPerRenderREd.getIntValue(), renderQualityREd.getIntValue(), zminREd.getDoubleValue(), zmaxREd.getDoubleValue());
lastRenderedSequenceOutFilePattern = outfilenamePattern;
break;
}
case POINTCLOUD:
{
renderSlicesThread = new RenderPointCloudThread(prefs, flame, file.getAbsolutePath(), finishEvent, renderSequenceProgressUpdater, renderWidthREd.getIntValue(), renderHeightREd.getIntValue(), renderQualityREd.getIntValue(), zminREd.getDoubleValue(), zmaxREd.getDoubleValue(), meshGenCellSizeREd.getDoubleValue());
break;
}
}
enableControls();
new Thread(renderSlicesThread).start();
}
} catch (Throwable ex) {
errorHandler.handleError(ex);
}
}
}
Aggregations