aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Bottone <nick@bottone.io>2023-12-13 02:02:13 -0500
committerNicholas Bottone <nick@bottone.io>2023-12-13 02:02:15 -0500
commit9f0490eab74aafd867ba2a82d7180f89faedcbf7 (patch)
treed14ddfbe9ebf09d69d2348b546eb280e9c09c07d
parent0ca7dd86d311886fc99accd5aa2b8a5382278603 (diff)
Add bulk rendering functionality
-rw-r--r--.gitignore1
-rw-r--r--src/mainwindow.cpp20
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/raytracer/raytracer.cpp4
-rw-r--r--src/settings.h2
5 files changed, 25 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index bd664f2..bdc990e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,4 @@
build/
.vscode/
.DS_Store
+**/.DS_Store
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index d96314c..f76f13a 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -216,7 +216,7 @@ void MainWindow::initialize() {
QHBoxLayout *lw = new QHBoxLayout();
wSlider = new QSlider(Qt::Orientation::Horizontal); // XY value slider
- wSlider->setTickInterval(0.01);
+ wSlider->setTickInterval(1);
wSlider->setMinimum(-10000);
wSlider->setMaximum(10000);
wSlider->setValue(0);
@@ -268,6 +268,7 @@ void MainWindow::finish() {
void MainWindow::connectUIElements() {
connectUploadFile();
connectSaveImage();
+ connectBulkRender();
connectxy();
connectxz();
connectxw();
@@ -294,6 +295,10 @@ void MainWindow::connectSaveImage() {
connect(saveImage, &QPushButton::clicked, this, &MainWindow::onSaveImage);
}
+void MainWindow::connectBulkRender() {
+ connect(bulkRender, &QPushButton::clicked, this, &MainWindow::onBulkRender);
+}
+
void MainWindow::connectxy() {
connect(xySlider, &QSlider::valueChanged, this, &MainWindow::onValChangexySlider);
connect(xyBox, static_cast<void(QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
@@ -383,6 +388,19 @@ void MainWindow::onSaveImage() {
rayTracer->saveViewportImage(filePath.toStdString());
}
+void MainWindow::onBulkRender() {
+ // if (settings.sceneFilePath.empty()) {
+ // std::cout << "No scene file loaded." << std::endl;
+ // return;
+ // }
+ std::string sceneName = settings.sceneFilePath.substr(0, settings.sceneFilePath.find_last_of("."));
+ sceneName = sceneName.substr(sceneName.find_last_of("/")+1);
+ QString folderPath = QFileDialog::getExistingDirectory(this, tr("Select Directory for Bulk Render"),
+ QDir::currentPath());
+ std::cout << "Setting bulk output path to: \"" << folderPath.toStdString() << "\"." << std::endl;
+ settings.bulkOutputFolderPath = folderPath.toStdString();
+}
+
void MainWindow::onValChangexySlider(int newValue) {
//wSlider->setValue(newValue);
xyBox->setValue(newValue/100.f);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index db7b096..1c2485c 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -23,6 +23,7 @@ private:
void connectUIElements();
void connectUploadFile();
void connectSaveImage();
+ void connectBulkRender();
void connectxy();
void connectxz();
void connectxw();
@@ -60,6 +61,7 @@ private:
private slots:
void onUploadFile();
void onSaveImage();
+ void onBulkRender();
void onValChangexySlider(int newValue);
void onValChangexyBox(double newValue);
void onValChangexzSlider(int newValue);
diff --git a/src/raytracer/raytracer.cpp b/src/raytracer/raytracer.cpp
index f831f82..8f4a190 100644
--- a/src/raytracer/raytracer.cpp
+++ b/src/raytracer/raytracer.cpp
@@ -69,9 +69,9 @@ void RayTracer::render(RGBA *imageData, const RayTraceScene &scene) {
}
}
- if (settings.bulkOutputFilePath.size() > 0) { // means we are doing bulk rendering
+ if (settings.bulkOutputFolderPath.size() > 0) { // means we are doing bulk rendering
// save the image to the bulk directory
- std::string filePath = settings.bulkOutputFilePath + QDir::separator().toLatin1() + std::to_string(settings.currentTime) + ".png";
+ std::string filePath = settings.bulkOutputFolderPath + QDir::separator().toLatin1() + std::to_string(settings.currentTime) + ".png";
saveViewportImage(filePath);
if (settings.currentTime < settings.maxTime) { // still more to render
// render the next frame
diff --git a/src/settings.h b/src/settings.h
index 0865e44..32c6484 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -17,7 +17,7 @@ struct Settings {
float w = 0.f;
int currentTime = 0;
int maxTime = 0;
- std::string bulkOutputFilePath;
+ std::string bulkOutputFolderPath;
};