Commit a2b2740c authored by Mike Kremer's avatar Mike Kremer
Browse files

Some small changes:

- Changed "Ego-Shooter" into "First-Person"
- Defined moveForward, moveBack, etc. in QtBaseViewer
- Updated first person mode such that it takes a mouse click to navigate around

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7021 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 12756b97
...@@ -284,10 +284,10 @@ void CoreWidget::setupMenuBar() ...@@ -284,10 +284,10 @@ void CoreWidget::setupMenuBar()
viewMenu_->addSeparator(); viewMenu_->addSeparator();
QAction* navigationSwitchAction = new QAction( tr("Ego-shooter Navigation"), viewMenu_ ); QAction* navigationSwitchAction = new QAction( tr("First-person Navigation"), viewMenu_ );
navigationSwitchAction->setCheckable( true ); navigationSwitchAction->setCheckable( true );
navigationSwitchAction->setStatusTip( tr("Switch between normal and ego-shooter navigation mode.")); navigationSwitchAction->setStatusTip( tr("Switch between normal and first-person navigation mode."));
navigationSwitchAction->setWhatsThis( tr("Switch between normal and ego-shooter navigation mode.")); navigationSwitchAction->setWhatsThis( tr("Switch between normal and first-person navigation mode."));
navigationSwitchAction->setChecked( false ); navigationSwitchAction->setChecked( false );
connect( navigationSwitchAction, SIGNAL( toggled(bool) ), this, SLOT( slotSwitchNavigation(bool) ) ); connect( navigationSwitchAction, SIGNAL( toggled(bool) ), this, SLOT( slotSwitchNavigation(bool) ) );
......
...@@ -129,7 +129,7 @@ void CoreWidget::slotSwitchNavigation(bool _egomode) { ...@@ -129,7 +129,7 @@ void CoreWidget::slotSwitchNavigation(bool _egomode) {
std::vector< glViewer* >::iterator it = examiner_widgets_.begin(); std::vector< glViewer* >::iterator it = examiner_widgets_.begin();
for(; it != examiner_widgets_.end(); it++) { for(; it != examiner_widgets_.end(); it++) {
_egomode ? (*it)->navigationMode(glViewer::EGOSHOOTER_NAVIGATION) : _egomode ? (*it)->navigationMode(glViewer::FIRSTPERSON_NAVIGATION) :
(*it)->navigationMode(glViewer::NORMAL_NAVIGATION); (*it)->navigationMode(glViewer::NORMAL_NAVIGATION);
} }
} }
...@@ -608,20 +608,19 @@ void CoreWidget::slotSetViewingDirection(QAction* _action) { ...@@ -608,20 +608,19 @@ void CoreWidget::slotSetViewingDirection(QAction* _action) {
} }
void CoreWidget::moveBack() { void CoreWidget::moveBack() {
// examiner_widgets_[PluginFunctions::activeExaminer()]-> examiner_widgets_[PluginFunctions::activeExaminer()]->moveBack();
std::cerr << "move Back" << std::endl;
} }
void CoreWidget::moveForward() { void CoreWidget::moveForward() {
std::cerr << "move Forward" << std::endl; examiner_widgets_[PluginFunctions::activeExaminer()]->moveForward();
} }
void CoreWidget::strafeLeft() { void CoreWidget::strafeLeft() {
std::cerr << "move Left" << std::endl; examiner_widgets_[PluginFunctions::activeExaminer()]->strafeLeft();
} }
void CoreWidget::strafeRight() { void CoreWidget::strafeRight() {
std::cerr << "move Right" << std::endl; examiner_widgets_[PluginFunctions::activeExaminer()]->strafeRight();
} }
//============================================================================= //=============================================================================
...@@ -161,6 +161,7 @@ glViewer::glViewer( QGraphicsScene* _scene, ...@@ -161,6 +161,7 @@ glViewer::glViewer( QGraphicsScene* _scene,
// state // state
orthoWidth_ = 2.0; orthoWidth_ = 2.0;
isRotating_ = false; isRotating_ = false;
lookAround_ = false;
near_ = 0.1; near_ = 0.1;
far_ = 100.0; far_ = 100.0;
fovy_ = 45.0; fovy_ = 45.0;
...@@ -336,7 +337,7 @@ void glViewer::projectionMode(ProjectionMode _p) ...@@ -336,7 +337,7 @@ void glViewer::projectionMode(ProjectionMode _p)
void glViewer::toggleNavigationMode() void glViewer::toggleNavigationMode()
{ {
if (navigationMode_ == NORMAL_NAVIGATION) if (navigationMode_ == NORMAL_NAVIGATION)
navigationMode(EGOSHOOTER_NAVIGATION); navigationMode(FIRSTPERSON_NAVIGATION);
else else
navigationMode(NORMAL_NAVIGATION); navigationMode(NORMAL_NAVIGATION);
} }
...@@ -1706,15 +1707,15 @@ void glViewer::viewMouseEvent(QMouseEvent* _event) { ...@@ -1706,15 +1707,15 @@ void glViewer::viewMouseEvent(QMouseEvent* _event) {
treatNormalNavigation(_event); treatNormalNavigation(_event);
} else if (navigationMode_ == EGOSHOOTER_NAVIGATION) { } else if (navigationMode_ == FIRSTPERSON_NAVIGATION) {
treatEgoShooterNavigation(_event); treatFirstPersonNavigation(_event);
} }
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) { void glViewer::treatFirstPersonNavigation( QMouseEvent* _event) {
// Ego-shooter navigation mode is selected // Ego-shooter navigation mode is selected
QPointF f(mapFromScene(QPointF(_event->pos().x(), _event->pos().y()))); QPointF f(mapFromScene(QPointF(_event->pos().x(), _event->pos().y())));
...@@ -1722,6 +1723,12 @@ void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) { ...@@ -1722,6 +1723,12 @@ void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) {
switch (_event->type()) { switch (_event->type()) {
case QEvent::MouseButtonPress: {
lastPoint2D_ = pos;
lookAround_ = true;
break;
}
case QEvent::MouseButtonDblClick: { case QEvent::MouseButtonDblClick: {
if (allowRotation_) if (allowRotation_)
flyTo(_event->pos(), _event->button() == Qt::MidButton); flyTo(_event->pos(), _event->button() == Qt::MidButton);
...@@ -1730,6 +1737,8 @@ void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) { ...@@ -1730,6 +1737,8 @@ void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) {
case QEvent::MouseMove: { case QEvent::MouseMove: {
if(!lookAround_) break;
// Considering center point of screen as origin // Considering center point of screen as origin
QPoint newpos = QPoint(pos.x() - glWidth() / 2, glHeight() / 2 - pos.y()); QPoint newpos = QPoint(pos.x() - glWidth() / 2, glHeight() / 2 - pos.y());
QPoint oldpos = QPoint(lastPoint2D_.x() - glWidth() / 2, glHeight() / 2 - lastPoint2D_.y()); QPoint oldpos = QPoint(lastPoint2D_.x() - glWidth() / 2, glHeight() / 2 - lastPoint2D_.y());
...@@ -1762,6 +1771,11 @@ void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) { ...@@ -1762,6 +1771,11 @@ void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) {
break; break;
} }
case QEvent::MouseButtonRelease: {
lookAround_ = false;
break;
}
default: // avoid warning default: // avoid warning
break; break;
} }
...@@ -2227,6 +2241,33 @@ void glViewer::updateCursorPosition (QPointF _scenePos) ...@@ -2227,6 +2241,33 @@ void glViewer::updateCursorPosition (QPointF _scenePos)
} }
} }
//-----------------------------------------------------------------------------
void glViewer::moveForward() {
if(navigationMode_ == FIRSTPERSON_NAVIGATION) {
std::cerr << "Move forward" << std::endl;
}
}
void glViewer::moveBack() {
if(navigationMode_ == FIRSTPERSON_NAVIGATION) {
std::cerr << "Move back" << std::endl;
}
}
void glViewer::strafeLeft() {
if(navigationMode_ == FIRSTPERSON_NAVIGATION) {
std::cerr << "Strafe left" << std::endl;
}
}
void glViewer::strafeRight() {
if(navigationMode_ == FIRSTPERSON_NAVIGATION) {
std::cerr << "Strafe right" << std::endl;
}
}
//============================================================================= //=============================================================================
//============================================================================= //=============================================================================
...@@ -194,7 +194,7 @@ public: ...@@ -194,7 +194,7 @@ public:
/// Navigation mode /// Navigation mode
enum NavigationMode { enum NavigationMode {
NORMAL_NAVIGATION, //!< Normal mode NORMAL_NAVIGATION, //!< Normal mode
EGOSHOOTER_NAVIGATION //!< Egoshooter mode FIRSTPERSON_NAVIGATION //!< First person mode
}; };
/// Changes the projection mode and updates the projection matrix. /// Changes the projection mode and updates the projection matrix.
...@@ -316,6 +316,18 @@ public: ...@@ -316,6 +316,18 @@ public:
/// will be called from CursorPainter to inform the viewer that the cursor position changed /// will be called from CursorPainter to inform the viewer that the cursor position changed
void updateCursorPosition (QPointF _scenePos); void updateCursorPosition (QPointF _scenePos);
/// First person navigation: Move forward
void moveForward();
/// First person navigation: Move back
void moveBack();
/// First person navigation: Strafe left
void strafeLeft();
/// First person navigation: Strafe Right
void strafeRight();
//---------------------------------------------------------------- public slots //---------------------------------------------------------------- public slots
public slots: public slots:
...@@ -526,6 +538,7 @@ protected: ...@@ -526,6 +538,7 @@ protected:
// helper // helper
bool isRotating_; bool isRotating_;
bool lookAround_;
//---------------------------------------------------------------- private data //---------------------------------------------------------------- private data
...@@ -849,8 +862,8 @@ private: ...@@ -849,8 +862,8 @@ private:
/// virtual trackball: map 2D screen point to unit sphere /// virtual trackball: map 2D screen point to unit sphere
bool mapToSphere(const QPoint& _p, ACG::Vec3d& _result) const; bool mapToSphere(const QPoint& _p, ACG::Vec3d& _result) const;
/// Navigate through scene if ego-shooter mode has been selected /// Navigate through scene if first person mode has been selected
void treatEgoShooterNavigation( QMouseEvent* _event); void treatFirstPersonNavigation( QMouseEvent* _event);
/// Navigate through scene if normal mode has been selected /// Navigate through scene if normal mode has been selected
void treatNormalNavigation( QMouseEvent* _event); void treatNormalNavigation( QMouseEvent* _event);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment