Commit 4f9217cc authored by Mike Kremer's avatar Mike Kremer

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 a1adc2c3
......@@ -284,10 +284,10 @@ void CoreWidget::setupMenuBar()
viewMenu_->addSeparator();
QAction* navigationSwitchAction = new QAction( tr("Ego-shooter Navigation"), viewMenu_ );
QAction* navigationSwitchAction = new QAction( tr("First-person Navigation"), viewMenu_ );
navigationSwitchAction->setCheckable( true );
navigationSwitchAction->setStatusTip( tr("Switch between normal and ego-shooter navigation mode."));
navigationSwitchAction->setWhatsThis( 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 first-person navigation mode."));
navigationSwitchAction->setChecked( false );
connect( navigationSwitchAction, SIGNAL( toggled(bool) ), this, SLOT( slotSwitchNavigation(bool) ) );
......
......@@ -129,7 +129,7 @@ void CoreWidget::slotSwitchNavigation(bool _egomode) {
std::vector< glViewer* >::iterator it = examiner_widgets_.begin();
for(; it != examiner_widgets_.end(); it++) {
_egomode ? (*it)->navigationMode(glViewer::EGOSHOOTER_NAVIGATION) :
_egomode ? (*it)->navigationMode(glViewer::FIRSTPERSON_NAVIGATION) :
(*it)->navigationMode(glViewer::NORMAL_NAVIGATION);
}
}
......@@ -608,20 +608,19 @@ void CoreWidget::slotSetViewingDirection(QAction* _action) {
}
void CoreWidget::moveBack() {
// examiner_widgets_[PluginFunctions::activeExaminer()]->
std::cerr << "move Back" << std::endl;
examiner_widgets_[PluginFunctions::activeExaminer()]->moveBack();
}
void CoreWidget::moveForward() {
std::cerr << "move Forward" << std::endl;
examiner_widgets_[PluginFunctions::activeExaminer()]->moveForward();
}
void CoreWidget::strafeLeft() {
std::cerr << "move Left" << std::endl;
examiner_widgets_[PluginFunctions::activeExaminer()]->strafeLeft();
}
void CoreWidget::strafeRight() {
std::cerr << "move Right" << std::endl;
examiner_widgets_[PluginFunctions::activeExaminer()]->strafeRight();
}
//=============================================================================
......@@ -161,6 +161,7 @@ glViewer::glViewer( QGraphicsScene* _scene,
// state
orthoWidth_ = 2.0;
isRotating_ = false;
lookAround_ = false;
near_ = 0.1;
far_ = 100.0;
fovy_ = 45.0;
......@@ -336,7 +337,7 @@ void glViewer::projectionMode(ProjectionMode _p)
void glViewer::toggleNavigationMode()
{
if (navigationMode_ == NORMAL_NAVIGATION)
navigationMode(EGOSHOOTER_NAVIGATION);
navigationMode(FIRSTPERSON_NAVIGATION);
else
navigationMode(NORMAL_NAVIGATION);
}
......@@ -1706,15 +1707,15 @@ void glViewer::viewMouseEvent(QMouseEvent* _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
QPointF f(mapFromScene(QPointF(_event->pos().x(), _event->pos().y())));
......@@ -1722,6 +1723,12 @@ void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) {
switch (_event->type()) {
case QEvent::MouseButtonPress: {
lastPoint2D_ = pos;
lookAround_ = true;
break;
}
case QEvent::MouseButtonDblClick: {
if (allowRotation_)
flyTo(_event->pos(), _event->button() == Qt::MidButton);
......@@ -1730,6 +1737,8 @@ void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) {
case QEvent::MouseMove: {
if(!lookAround_) break;
// Considering center point of screen as origin
QPoint newpos = QPoint(pos.x() - glWidth() / 2, glHeight() / 2 - pos.y());
QPoint oldpos = QPoint(lastPoint2D_.x() - glWidth() / 2, glHeight() / 2 - lastPoint2D_.y());
......@@ -1762,6 +1771,11 @@ void glViewer::treatEgoShooterNavigation( QMouseEvent* _event) {
break;
}
case QEvent::MouseButtonRelease: {
lookAround_ = false;
break;
}
default: // avoid warning
break;
}
......@@ -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:
/// Navigation mode
enum NavigationMode {
NORMAL_NAVIGATION, //!< Normal mode
EGOSHOOTER_NAVIGATION //!< Egoshooter mode
FIRSTPERSON_NAVIGATION //!< First person mode
};
/// Changes the projection mode and updates the projection matrix.
......@@ -316,6 +316,18 @@ public:
/// will be called from CursorPainter to inform the viewer that the cursor position changed
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:
......@@ -526,6 +538,7 @@ protected:
// helper
bool isRotating_;
bool lookAround_;
//---------------------------------------------------------------- private data
......@@ -849,8 +862,8 @@ private:
/// virtual trackball: map 2D screen point to unit sphere
bool mapToSphere(const QPoint& _p, ACG::Vec3d& _result) const;
/// Navigate through scene if ego-shooter mode has been selected
void treatEgoShooterNavigation( QMouseEvent* _event);
/// Navigate through scene if first person mode has been selected
void treatFirstPersonNavigation( QMouseEvent* _event);
/// Navigate through scene if normal mode has been selected
void treatNormalNavigation( QMouseEvent* _event);
......
Markdown is supported
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