diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/camera/camera.cpp | 3 | ||||
-rw-r--r-- | src/mainwindow.cpp | 14 | ||||
-rw-r--r-- | src/raytracer/raytracer.cpp | 93 | ||||
-rw-r--r-- | src/settings.h | 4 |
4 files changed, 67 insertions, 47 deletions
diff --git a/src/camera/camera.cpp b/src/camera/camera.cpp index 69f2787..ae7fdd3 100644 --- a/src/camera/camera.cpp +++ b/src/camera/camera.cpp @@ -12,7 +12,8 @@ void Camera::updateViewMatrix(SceneCameraData cameraData) { m_viewMatrix = glm::rotate(m_viewMatrix, glm::radians(settings.xz), glm::vec3(0.f, 0.f, 1.f)); - // TODO: link sliders here. make them smaller changes since our objects are so small + // TODO: rename & link sliders here. also add one more for the fourth dimension. + // make them smaller intervals on the sliders since our objects are so small glm::vec4 uiTranslation = glm::vec4(settings.xw, settings.yw, 0.f, settings.zw); m_translationVector = -cameraData.pos + uiTranslation; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4eda325..ed5b32e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -26,25 +26,25 @@ void MainWindow::initialize() { font.setPointSize(12); font.setBold(true); QLabel *xy_label = new QLabel(); // XY label - xy_label->setText("Camera XY:"); + xy_label->setText("Rotation XY angle (J,L)"); xy_label->setFont(font); QLabel *xz_label = new QLabel(); // XZ label - xz_label->setText("Camera XZ:"); + xz_label->setText("Rotation XZ angle (I, M)"); xz_label->setFont(font); QLabel *xw_label = new QLabel(); // XW label - xw_label->setText("Camera XW:"); + xw_label->setText("Translate X (W,D)"); xw_label->setFont(font); QLabel *yz_label = new QLabel(); // YZ label - yz_label->setText("Camera YZ:"); + yz_label->setText("Rotation YZ angle (O, N):"); yz_label->setFont(font); QLabel *yw_label = new QLabel(); // YW label - yw_label->setText("Camera YW:"); + yw_label->setText("Translate Y (A, D)"); yw_label->setFont(font); QLabel *zw_label = new QLabel(); // ZW label - zw_label->setText("Camera ZW:"); + zw_label->setText("Translate W (R, F):"); zw_label->setFont(font); QLabel *w_label = new QLabel(); // W label - w_label->setText("W value:"); + w_label->setText("Vorex Depth:"); w_label->setFont(font); currTimeLabel = new QLabel(); // Current Time label diff --git a/src/raytracer/raytracer.cpp b/src/raytracer/raytracer.cpp index dbc1988..604d717 100644 --- a/src/raytracer/raytracer.cpp +++ b/src/raytracer/raytracer.cpp @@ -270,60 +270,79 @@ void RayTracer::sceneChanged(QLabel* imageLabel) { void RayTracer::keyPressEvent(QKeyEvent *event) { m_keyMap[Qt::Key(event->key())] = true; std::cout << "key pressed" << std::endl; - if (m_keyMap[Qt::Key_1]) { + + // J and L for xy rotation + if (m_keyMap[Qt::Key_J]) { std::cout << "key 1" << std::endl; - if (settings.negative) { - settings.xy -= settings.rotation; - } else { settings.xy += settings.rotation; - } + emit xyRotationChanged(settings.xy); + } + if (m_keyMap[Qt::Key_L]) { + settings.xy -= settings.rotation; emit xyRotationChanged(settings.xy); } - if (m_keyMap[Qt::Key_2]) { - if (settings.negative) { - settings.xz -= settings.rotation; - } else { - settings.xz += settings.rotation; - } + // I and M for xz rotation + if (m_keyMap[Qt::Key_I]) { + settings.xz += settings.rotation; emit xzRotationChanged(settings.xz); } - - if (m_keyMap[Qt::Key_3]) { - if (settings.negative) { - settings.xw -= settings.rotation; - } else { - settings.xw += settings.rotation; - } - emit xwRotationChanged(settings.xw); + if (m_keyMap[Qt::Key_M]) { + settings.xz -= settings.rotation; + emit xzRotationChanged(settings.xz); } - if (m_keyMap[Qt::Key_4]) { - if (settings.negative) { - settings.yz -= settings.rotation; - } else { - settings.yz += settings.rotation; - } + // O and N for yz rotation + if (m_keyMap[Qt::Key_O]) { + settings.yz += settings.rotation; + emit yzRotationChanged(settings.yz); + } + if (m_keyMap[Qt::Key_N]) { + settings.yz -= settings.rotation; emit yzRotationChanged(settings.yz); } - if (m_keyMap[Qt::Key_5]) { - if (settings.negative) { - settings.yw -= settings.rotation; - } else { - settings.yw += settings.rotation; - } + // W and S for x translation + if (m_keyMap[Qt::Key_W]) { + settings.xw += settings.translation; + emit xwRotationChanged(settings.xw); + } + if (m_keyMap[Qt::Key_S]) { + settings.xw -= settings.translation; + emit xwRotationChanged(settings.xw); + } + + // A and D for y translation + if (m_keyMap[Qt::Key_A]) { + settings.yw += settings.translation; + emit yzRotationChanged(settings.yw); + } + if (m_keyMap[Qt::Key_D]) { + settings.yw -= settings.translation; emit ywRotationChanged(settings.yw); } - if (m_keyMap[Qt::Key_6]) { - if (settings.negative) { - settings.zw -= settings.rotation; - } else { - settings.zw += settings.rotation; - } + // TODO: add slider for z translation + + // R & F for w translation using zw + if (m_keyMap[Qt::Key_R]) { + settings.zw += settings.translation; emit zwRotationChanged(settings.zw); } + if (m_keyMap[Qt::Key_F]) { + settings.zw -= settings.translation; + emit zwRotationChanged(settings.zw); + } + + // TODO: ONLY IF HAVE TIME, NOT NEEDED + // Space & V for vorex depth + if (m_keyMap[Qt::Key_Space]) { + settings.w += settings.rotation; + + } + if (m_keyMap[Qt::Key_V]) { + settings.w -= settings.rotation; + } } void RayTracer::keyReleaseEvent(QKeyEvent *event) { diff --git a/src/settings.h b/src/settings.h index 32c6484..8a9321f 100644 --- a/src/settings.h +++ b/src/settings.h @@ -12,8 +12,8 @@ struct Settings { float xw = 0.f; float yw = 0.f; float zw = 0.f; - float rotation = 0.f; - bool negative = false; + float rotation = 5.f; + float translation = .1f; float w = 0.f; int currentTime = 0; int maxTime = 0; |