diff --git a/src/qtgui/common.h b/src/qtgui/common.h index bc794914..400c838b 100644 --- a/src/qtgui/common.h +++ b/src/qtgui/common.h @@ -10,10 +10,15 @@ using namespace mitsuba; enum EConnectionType { - ESSHConnection, + ESSHConnection = 0, EDirectConnection }; +enum ENavigationMode { + EFlythroughFixedYaw = 0, + EFlythrough +}; + namespace mitsuba { class RemoteWorker; }; diff --git a/src/qtgui/glwidget.cpp b/src/qtgui/glwidget.cpp index 98b5c450..d1050316 100644 --- a/src/qtgui/glwidget.cpp +++ b/src/qtgui/glwidget.cpp @@ -29,6 +29,7 @@ GLWidget::GLWidget(QWidget *parent) : connect(m_preview, SIGNAL(statusMessage(const QString &)), this, SIGNAL(statusMessage(const QString &)), Qt::QueuedConnection); m_invertMouse = false; + m_navigationMode = EFlythroughFixedYaw; m_ignoreMouseEvent = QPoint(0, 0); m_didSetCursor = false; m_softwareFallback = false; @@ -558,6 +559,14 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event) { PinholeCamera *camera = static_cast(m_context->scene->getCamera()); Point p = camera->getInverseViewTransform()(Point(0,0,0)); Vector direction = camera->getInverseViewTransform()(Vector(0,0,1)); + Vector up; + + if (m_navigationMode == EFlythrough) + up = camera->getInverseViewTransform()(Vector(0,1,0)); + else if (m_navigationMode == EFlythroughFixedYaw) + up = m_context->up; + else + SLog(EError, "Unknown navigation mode encountered!"); bool didMove = false; @@ -573,10 +582,10 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event) { direction = trafo.inverse()(Vector(0,0,1)); if (camera->getViewTransform().det3x3() < 0) { - camera->setInverseViewTransform(Transform::lookAt(p, p+direction, m_context->up)); + camera->setInverseViewTransform(Transform::lookAt(p, p+direction, up)); } else { camera->setInverseViewTransform( - Transform::lookAt(p, p+direction, m_context->up) * + Transform::lookAt(p, p+direction, up) * Transform::scale(Vector(-1,1,1)) ); } @@ -588,10 +597,10 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event) { Float fovChange = rel.y() * m_mouseSensitivity * .03f; if (camera->getViewTransform().det3x3() < 0) { - m_context->up = Transform::rotate(direction, roll)(m_context->up); + m_context->up = Transform::rotate(direction, roll)(up); camera->setInverseViewTransform(Transform::lookAt(p, p+direction, m_context->up)); } else { - m_context->up = Transform::rotate(direction, -roll)(m_context->up); + m_context->up = Transform::rotate(direction, -roll)(up); camera->setInverseViewTransform( Transform::lookAt(p, p+direction, m_context->up) * Transform::scale(Vector(-1,1,1)) @@ -633,7 +642,7 @@ void GLWidget::wheelEvent(QWheelEvent *event) { if (!bar->isVisible() || !m_preview->isRunning()) return; - + int oldStep = bar->singleStep(); bar->setSingleStep(event->delta()/4); #if defined(__OSX__) diff --git a/src/qtgui/glwidget.h b/src/qtgui/glwidget.h index 04efb968..0b8cc639 100644 --- a/src/qtgui/glwidget.h +++ b/src/qtgui/glwidget.h @@ -32,6 +32,8 @@ public: inline bool getInvertMouse() const { return m_invertMouse; } void setInvertMouse(bool invert) { m_invertMouse = invert; } + inline ENavigationMode getNavigationMode() const { return m_navigationMode; } + void setNavigationMode(ENavigationMode mode) { m_navigationMode = mode; } inline int getMouseSensitivity() const { return m_mouseSensitivity; } void setMouseSensitivity(int sensitivity) { m_mouseSensitivity = sensitivity; } void setScrollBars(QScrollBar *hScroll, QScrollBar *vScroll); @@ -119,6 +121,7 @@ private: QTimer *m_movementTimer, *m_redrawTimer; QScrollBar *m_hScroll, *m_vScroll; ref m_clock; + ENavigationMode m_navigationMode; bool m_invertMouse, m_didSetCursor; bool m_ignoreScrollEvents, m_ignoreResizeEvents; int m_mouseSensitivity, m_softwareFallback; diff --git a/src/qtgui/mainwindow.cpp b/src/qtgui/mainwindow.cpp index d265f3bb..13bcdca8 100644 --- a/src/qtgui/mainwindow.cpp +++ b/src/qtgui/mainwindow.cpp @@ -146,6 +146,8 @@ MainWindow::MainWindow(QWidget *parent) : /* Load defaults from app settings file */ ui->glView->setInvertMouse(settings.value("invertMouse", false).toBool()); ui->glView->setMouseSensitivity(settings.value("mouseSensitivity", 3).toInt()); + ui->glView->setNavigationMode((ENavigationMode) settings.value("navigationMode", + EFlythroughFixedYaw).toInt()); m_searchPaths = settings.value("searchPaths", QStringList()).toStringList(); m_blockSize = settings.value("blockSize", 32).toInt(); m_listenPort = settings.value("listenPort", MTS_DEFAULT_PORT).toInt(); @@ -1016,6 +1018,7 @@ void MainWindow::on_actionSettings_triggered() { d.setWindowModality(Qt::ApplicationModal); d.setLogLevel(logger->getLogLevel()); d.setInvertMouse(ui->glView->getInvertMouse()); + d.setNavigationMode(ui->glView->getNavigationMode()); d.setMouseSensitivity(ui->glView->getMouseSensitivity()); d.setBlockSize(m_blockSize); d.setSearchPaths(m_searchPaths); @@ -1042,10 +1045,12 @@ void MainWindow::on_actionSettings_triggered() { settings.setValue("mouseSensitivity", d.getMouseSensitivity()); settings.setValue("listenPort", d.getListenPort()); settings.setValue("nodeName", d.getNodeName()); + settings.setValue("navigationMode", (int) d.getNavigationMode()); logger->setLogLevel(d.getLogLevel()); ui->glView->setInvertMouse(d.getInvertMouse()); ui->glView->setMouseSensitivity(d.getMouseSensitivity()); + ui->glView->setNavigationMode(d.getNavigationMode()); m_blockSize = d.getBlockSize(); m_searchPaths = d.getSearchPaths(); m_checkForUpdates = d.getCheckForUpdates(); diff --git a/src/qtgui/programsettingsdlg.h b/src/qtgui/programsettingsdlg.h index a7527dc9..380df740 100644 --- a/src/qtgui/programsettingsdlg.h +++ b/src/qtgui/programsettingsdlg.h @@ -37,6 +37,14 @@ public: return ui->invertMouseBox->checkState() == Qt::Checked; } + inline ENavigationMode getNavigationMode() const { + return (ENavigationMode) ui->navigationModeBox->currentIndex(); + } + + inline void setNavigationMode(ENavigationMode mode) const { + ui->navigationModeBox->setCurrentIndex(mode); + } + inline void setInvertMouse(bool value) { ui->invertMouseBox->setCheckState(value ? Qt::Checked : Qt::Unchecked); } diff --git a/src/qtgui/programsettingsdlg.ui b/src/qtgui/programsettingsdlg.ui index 237ab0b9..b7ac37ea 100644 --- a/src/qtgui/programsettingsdlg.ui +++ b/src/qtgui/programsettingsdlg.ui @@ -6,8 +6,8 @@ 0 0 - 354 - 485 + 377 + 480 @@ -51,7 +51,7 @@ General - + 15 @@ -186,7 +186,7 @@ system load, especially when much of the work is done over the network. - + @@ -199,7 +199,7 @@ system load, especially when much of the work is done over the network. - + 6 @@ -286,50 +286,6 @@ system load, especially when much of the work is done over the network. - - - - Specifies the threshold for displaying log messages. -For instance, setting this to "Info" means that everything -above and including "Info" is written to the console. - - - Log verbosity : - - - logVerbosityBox - - - - - - - Specifies the threshold for displaying log messages. -For instance, setting this to "Info" means that everything -above and including "Info" is written to the console. - - - - Trace - - - - - Debug - - - - - Info - - - - - Warn - - - - @@ -343,7 +299,7 @@ above and including "Info" is written to the console. - + true @@ -415,7 +371,7 @@ release via Internet every time it is started. - + Specifies how sensitive the mouse should react to @@ -450,7 +406,7 @@ movements while navigating in the realt-time preview. - + Specifies how sensitive the mouse should react to @@ -461,7 +417,7 @@ movements while navigating in the realt-time preview. - + Should the preview navigation flip the Y axis of the mouse? @@ -474,7 +430,7 @@ movements while navigating in the realt-time preview. - + Should the preview navigation flip the Y axis of the mouse? @@ -493,6 +449,96 @@ movements while navigating in the realt-time preview. + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This option specifies the camera behavior when navigating within the realtime preview.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Fly-through (Fix yaw)</span>: Always yaw around a fixed &quot;up&quot; axis, which is determined when a scene is loaded. This is intuitive and similar to a person walking through a scene, but assumes that the camera has already been set up correctly.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Fly-through</span>: Always yaw around the current camera &quot;up&quot; axis.</p></body></html> + + + Navigation : + + + navigationModeBox + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This option specifies the camera behavior when navigating within the realtime preview.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Fly-through (Fix yaw)</span>: Always yaw around a fixed &quot;up&quot; axis, which is determined when a scene is loaded. This is intuitive and similar to a person walking through a scene, but assumes that the camera has already been set up correctly.</p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Fly-through</span>: Always yaw around the current camera &quot;up&quot; axis.</p></body></html> + + + + Fly-through (Fix yaw) + + + + + Fly-through + + + + + + + + Specifies the threshold for displaying log messages. +For instance, setting this to "Info" means that everything +above and including "Info" is written to the console. + + + + Trace + + + + + Debug + + + + + Info + + + + + Warn + + + + + + + + Specifies the threshold for displaying log messages. +For instance, setting this to "Info" means that everything +above and including "Info" is written to the console. + + + Log verbosity : + + + logVerbosityBox + + + @@ -757,9 +803,10 @@ connections. The default setting is 7554. blockSizeBox localWorkerBox checkForUpdatesBox + logVerbosityBox + navigationModeBox invertMouseBox sensitivitySlider - logVerbosityBox searchPathList removePathButton addPathButton @@ -782,8 +829,8 @@ connections. The default setting is 7554. reject() - 280 - 412 + 286 + 475 141 @@ -798,8 +845,8 @@ connections. The default setting is 7554. accept() - 309 - 412 + 315 + 475 318 @@ -831,7 +878,7 @@ connections. The default setting is 7554. 175 - 100 + 90 26 @@ -846,8 +893,8 @@ connections. The default setting is 7554. refresh() - 224 - 74 + 175 + 62 291