diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/camera/camera.cpp | 22 | ||||
-rw-r--r-- | src/mainwindow.cpp | 5 | ||||
-rw-r--r-- | src/mainwindow.h | 1 | ||||
-rw-r--r-- | src/raytracer/raytracer.cpp | 42 | ||||
-rw-r--r-- | src/raytracer/raytracer.h | 2 |
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 f096b7e..ef15b61 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -274,6 +274,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(); } @@ -539,4 +540,8 @@ void MainWindow::updateRotationSlider(float value) { rotationSlider->setValue(int(value*100.f)); rotationBox->setValue(value); // rayTracer->settingsChanged(imageLabel); +} + +void MainWindow::updateCameraPosition() { + rayTracer->wSliderChanged(imageLabel); }
\ No newline at end of file diff --git a/src/mainwindow.h b/src/mainwindow.h index d6a929b..34656e2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -83,4 +83,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 f831f82..4d1e14a 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); }; |