aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/camera/camera.cpp22
-rw-r--r--src/mainwindow.cpp5
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/raytracer/raytracer.cpp42
-rw-r--r--src/raytracer/raytracer.h2
5 files changed, 48 insertions, 24 deletions
diff --git a/src/camera/camera.cpp b/src/camera/camera.cpp
index 9e8aef2..5097b6c 100644
--- a/src/camera/camera.cpp
+++ b/src/camera/camera.cpp
@@ -60,25 +60,3 @@ float Camera::getAperture() const {
return m_aperture;
}
-// int getPt(glm::vec3 n1 , glm::vec3 n2 , float perc )
-// {
-// int diff = n2 - n1;
-
-// return n1 + ( diff * perc );
-// }
-
-// for( float i = 0 ; i < 1 ; i += 0.01 )
-// {
-// glm::vec3 xa = getPt(P1, P2, i);
-// glm::vec3 xb = getPt(P2, P3, i);
-// glm::vec3 xc = getPt(P3, P4, i);
-
-// // Calculate points on the lines between the above points
-// glm::vec3 xm = getPt(xa, xb, i);
-// glm::vec3 xn = getPt(xb, xc, i);
-
-// // Calculate the final point on the Bezier curve
-// glm::vec3 pointOnCurve = getPt(xm, xn, i);
-
-
-// } \ No newline at end of file
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index f76f13a..973d5a7 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -284,6 +284,7 @@ void MainWindow::connectUIElements() {
connect(rayTracer, &RayTracer::ywRotationChanged, this, &MainWindow::updateYwSlider);
connect(rayTracer, &RayTracer::zwRotationChanged, this, &MainWindow::updateZwSlider);
connect(rayTracer, &RayTracer::rotationChanged, this, &MainWindow::updateRotationSlider);
+ connect(rayTracer, &RayTracer::cameraPositionChanged, this, &MainWindow::updateCameraPosition);
connectW();
}
@@ -561,3 +562,7 @@ void MainWindow::updateRotationSlider(float value) {
maxTimeSpinBox->setValue(value);
rayTracer->settingsChanged(imageLabel);
}
+
+void MainWindow::updateCameraPosition() {
+ rayTracer->wSliderChanged(imageLabel);
+}
diff --git a/src/mainwindow.h b/src/mainwindow.h
index 1c2485c..06f27be 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -86,4 +86,5 @@ private slots:
void updateRotationSlider(float newValue);
void onValChangeWSlider(int newValue);
void onValChangeWBox(double newValue);
+ void updateCameraPosition();
};
diff --git a/src/raytracer/raytracer.cpp b/src/raytracer/raytracer.cpp
index 8f4a190..d6fa14f 100644
--- a/src/raytracer/raytracer.cpp
+++ b/src/raytracer/raytracer.cpp
@@ -232,9 +232,47 @@ void RayTracer::settingsChanged(QLabel* imageLabel) {
m_image = image;
}
-// void RayTracer::wSliderChanged(QLabel* imageLabel) {
+glm::vec4 getPt(glm::vec3 n1 , glm::vec3 n2 , float perc )
+{
+ glm::vec3 diff = n2 - n1;
+
+ return glm::vec4(n1 + ( diff * perc ), 0.0f);
+}
+
+void RayTracer::wSliderChanged(QLabel* imageLabel) {
+ // auto P1 = cameraControlPoints[0];
+ // auto P2 = scene.getCamera().controlPoints[1];
+ // auto P3 = scene.getCamera().controlPoints[2];
+ // auto P4 = scene.getCamera().controlPoints[3];
+ // for( float i = 0 ; i < 1 ; i += 0.01 )
+ // {
+ // glm::vec3 xa = getPt(P1, P2, i);
+ // glm::vec3 xb = getPt(P2, P3, i);
+ // glm::vec3 xc = getPt(P3, P4, i);
+
+ // // Calculate points on the lines between the above points
+ // glm::vec3 xm = getPt(xa, xb, i);
+ // glm::vec3 xn = getPt(xb, xc, i);
+
+ // // Calculate the final point on the Bezier curve
+ // glm::vec3 pointOnCurve = getPt(xm, xn, i);
+
+ // // update the camera position
+ // m_metaData.cameraData.pos = pointOnCurve;
+ // RayTraceScene rtScene{ m_width, m_height, m_metaData, m_depth };
+ // this->render(m_imageData, rtScene);
+ // QTimer::singleShot(3500, this, [this, imageLabel]() {
+ // // This code will be executed after a 2-second delay
+ // // emit rotationChanged(settings.rotation);
+ // QImage flippedImage = m_image.mirrored(false, false);
+ // flippedImage = flippedImage.scaled(m_width, m_height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ // imageLabel->setPixmap(QPixmap::fromImage(flippedImage));
+ // });
+ // }
+
+ // emit cameraPositionChanged(m_metaData.cameraData.pos);
-// }
+}
void RayTracer::keyPressEvent(QKeyEvent *event) {
m_keyMap[Qt::Key(event->key())] = true;
diff --git a/src/raytracer/raytracer.h b/src/raytracer/raytracer.h
index da4ec2d..52fc05a 100644
--- a/src/raytracer/raytracer.h
+++ b/src/raytracer/raytracer.h
@@ -178,6 +178,7 @@ public:
QImage m_image;
void saveViewportImage(std::string filename);
+ void wSliderChanged(QLabel* imageLabel);
signals:
void xyRotationChanged(float value);
void xzRotationChanged(float value);
@@ -186,5 +187,6 @@ signals:
void ywRotationChanged(float value);
void zwRotationChanged(float value);
void rotationChanged(float value);
+ void cameraPositionChanged(glm::vec3 value);
};